Skip to content

valmat/dhunspell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dlang hunspell wrapper

Wrapper for hunspell speller

Dependences

sudo apt install hunspell hunspell-dev

Optionality:

sudo apt hunspell-ru hunspell-de hunspell-fr

Usage

Check word

void main()
{
    auto spell = Spell.makeDefault();

    writeln("колбаса : ", spell.check("колбаса"));
    writeln("калбаса : ", spell.check("калбаса"));
    writeln("жир     : ", spell.check("жир"));
    writeln("жыр     : ", spell.check("жыр"));
}

output:

колбаса : true
калбаса : false
жир     : true
жыр     : false

Get dictionary encoding

writeln(spell.dicEncoding());

output:

UTF-8

Get suggestions

auto suggestions = spell.suggest("калбаса");
for(size_t i = 0; i < suggestions.size; ++i) {
    suggestions[i].writeln();
}

output:

колбаса
карбаса
кал баса
колбаска

Or the same:

foreach(ref w; suggestions.range) {
    w.writeln();
}

or

foreach(ref w; suggestions.toStrings) {
    w.writeln();
}

Method Slice.toStrings() returns strings array string[]

Analyze

auto analyze = spell.analyze("колбаса");
foreach(w; analyze.range) {
    w.writeln();
}

output:

st:колбаса

Stemming

foreach(w; spell.stem("колбаса").toStrings) {
    w.writeln();
}

output:

колбаса

Because Hunspell released under GNU LGPL v3 dhunspell has the same lecense.

The GNU LGPL v3 License

Releases

No releases published

Packages

No packages published

Languages