• Stars
    star
    6
  • Rank 2,539,965 (Top 51 %)
  • Language
    Crystal
  • License
    MIT License
  • Created over 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Crystal bindings for Hunspell.

crystal-hunspell

CI GitHub release License

Crystal bindings for Hunspell.

Installation

Before installing crystal-hunspell ensure you have hunspell already installed:

  1. Add the dependency to your shard.yml:

    dependencies:
      hunspell:
        github: mamantoha/crystal-hunspell
  2. Run shards install

Usage

The library has been tested with Hunspell version 1.7.2.

require "hunspell"

Open a dictionary:

hunspell = Hunspell.new("/usr/share/hunspell/en_US.aff", "/usr/share/hunspell/en_US.dic")

or

hunspell = Hunspell.new("en_US")

Ensure to close Hunspell instance after using.

hunspell.close

Below are some simple examples for how to use the repository.

Spelling

It's a simple task to ask if a particular word is in the dictionary.

hunspell.spell?("correct")
# => true

hunspell.spell?("incorect")
# => false

This will only ever return true or false, and won't give suggestions about why it might be wrong. It also depends on your choice of dictionary.

Suggestions

If you want to get a suggestion from Hunspell, it can provide a corrected label given a basestring input.

hunspell.suggest("arbitrage")
# => ["arbitrage", "arbitrages", "arbitrager", "arbitraged", "arbitrate"]

Suffix Match

hunspell.suffix_suggest("do")
# => ["doing", "doth", "doer", "dos", "do's", "doings", "doers"]

Stemming

The module can also stem words, providing the stems for pluralization and other inflections.

hunsell.stem("fishing")
# => ["fishing", "fish"]

Analyze

Like stemming but return morphological analysis of the input instead.

hunspell.analyze("permanently")
# => [" st:permanent fl:Y"]

Bulk Requests

You can also request bulk actions against Hunspell. Currently suggest, suffix_suggest, stem, and analyze are bulk requestable.

hunspell.bulk_suggest(["correct", "incorect"])
# => {"correct"  => ["correct", "corrects", "cor rect", "cor-rect"],
#     "incorect" => ["incorrect", "correction", "corrector", "injector", "correct"]}

hunspell.bulk_suffix_suggest(["cat", "do"])
# => {"cat" => ["cats", "cat's"],
#     "do"  => ["doing", "doth", "doer", "dos", "do's", "doings", "doers"]}

hunspell.bulk_stem(["stems", "currencies"])
# => {"stems" => ["stem"], "currencies" => ["currency"]}

hunspell.bulk_analyze(["dog", "permanently"])
# => {"dog" => [" st:dog"], "permanently" => [" st:permanent fl:Y"]}

Development

sudo apt install libclang-dev libhunspell-dev

Generate new bindings for Hunspell

crystal ./lib/crystal_lib/src/main.cr src/hunspell/lib_hunspell.cr.in > src/hunspell/lib_hunspell.cr

Contributing

  1. Fork it (https://github.com/mamantoha/crystal-hunspell/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

More Repositories

1

crest

HTTP and REST client for Crystal
Crystal
234
star
2

omniauth-vkontakte

Vkontakte OAuth2 Strategy for OmniAuth
Ruby
141
star
3

zipstream

A command line tool that allows you to easily share files and directories over the network
Crystal
60
star
4

nanoid.cr

Crystal implementation of Nanoid, secure URL-friendly unique ID generator.
Crystal
41
star
5

http_proxy

A HTTP Proxy server and client written in Crystal
Crystal
39
star
6

shards-info

Source code of https://shards.info/
Crystal
38
star
7

humanize_time

Adds the humanize method to reports the approximate distance in time between two Time. humanize supports i18n translations too so it can be used in internationalized apps.
Crystal
23
star
8

vkontakte_client

VKontakte API Client for Ruby
Ruby
22
star
9

mpd_client

Simple Music Player Daemon library written entirely in Ruby
Ruby
16
star
10

cryMPD

A minimalistic web-based MPD client
Crystal
14
star
11

twitter-crystal

A library to access the Twitter API using Crystal
Crystal
14
star
12

uaenv

UaEnv - модуль для роботи з українським текстом в Ruby. Головна ціль UaEnv - полегшити розробку україномовних програм на Ruby
Ruby
11
star
13

crystal_mpd

Concurrent MPD client written in Crystal
Crystal
10
star
14

xml_converter

Create hashes from XML documents easily.
Crystal
8
star
15

time_zone

A helper to work with time zones in Crystal
Crystal
8
star
16

iso_codes

🌐 Lists of various ISO standards (ISO 3166-1 for countries and ISO 639-2 for languages) with translations for Crystal
Crystal
8
star
17

zci

Zendesk and Crowdin integration Command Line Interface (CLI)
Ruby
7
star
18

dotfiles

Shell
6
star
19

crystal-cmark-gfm

Minimal C bindings for parsing and rendering with cmark-gfm
Crystal
6
star
20

zendesk_help_center_api_client_rb

Zendesk Help Center REST API Client
Ruby
6
star
21

lifecell_api

lifecell_api is used to interact with the lifecell API from Ruby
Ruby
6
star
22

foaas_client

A Crystal client for FOAAS - a modern, RESTful, scalable solution to the common problem of telling people to fuck off
Crystal
5
star
23

mongo-sinatra-admin

Web-based MongoDB admin interface written with Ruby and Sinatra
Ruby
5
star
24

detransport_ternopil_telegram

Public transport in Ternopil 🇺🇦
Crystal
5
star
25

bytes_ext

Byte Conversion Library for Crystal
Crystal
5
star
26

detransport_lviv_telegram

Public transport in Lviv 🇺🇦
Crystal
4
star
27

telegram_bot

Telegram Bot API Wrapper for Crystal 💎
Crystal
4
star
28

shards_spec

A shard.yml parser for the Crystal language
Crystal
3
star
29

resolv-crystal

A DNS resolver library written in Crystal
Crystal
3
star
30

http-client-digest_auth

An implementation of RFC 2617 Digest Access Authentication for Crystal
Crystal
2
star
31

crystal-exif

Crystal bindings for libexif
Crystal
2
star
32

rbtorstat

rbtorstat is a simple web page generator, written in Ruby, which shows status information about the rTorrent bittorrent client
Ruby
2
star
33

fci

Freshdesk and Crowdin integration Command Line Interface (CLI)
Ruby
2
star
34

time_duration

Provides a structured and convenient way to work with durations of time in the Crystal programming language
Crystal
2
star
35

air_alert_map_ua_wallpaper

A CLI tool for setting the Air Raid Alert Map of Ukraine as a desktop background
Crystal
2
star
36

ydokey

A simple command-line utility for Linux to convert key commands to raw keycodes which used in ydotool
Crystal
2
star
37

crystal-hidapi

A Crystal interface to HIDAPI library.
Crystal
2
star
38

matiuky_regexp

A collection of usefull regular expressions for matiuky
Ruby
2
star
39

crystal-bplist

Generate and parse Apple binary .plist files with Crystal
Crystal
1
star
40

i18n_plural_rules

Custom plural rules support for i18n.cr library.
Crystal
1
star
41

uz-api

A Ruby interface to the Ukrzaliznytsia API (http://booking.uz.gov.ua/)
Ruby
1
star
42

validates_nested_uniqueness

Library for validating nested uniqueness in Rails.
Ruby
1
star
43

time_by_example

Provides a Crystal implementation of Go-style time formatting by example.
Crystal
1
star