[libvoikko] SuggestionGenerator interface

Harri Pitkänen hatapitk at iki.fi
Sat Feb 27 19:58:36 EET 2010


On Thursday 25 February 2010, Flammie Pirinen wrote:
> 2010-02-25, Harri Pitkänen sanoi:
> > Looks interesting. We should improve the suggestion generation code
> > so that your suggestion mechanism could actually be plugged into use.
> > Should not be too hard, most of the required abstractions are already
> > there.
> 
> That would be ideal, or even further, as I think there were provision
> for different suggestion algorithms in current voikko, same can be
> easily done providing different transducers. I suppose at some point
> the hard coded file names can be replaced by information read from
> the .pro file or something?

Yes, that is possible.

I refactored the spelling suggestion code in SVN a bit. If you change your 
HfstSuggestion class to extend 
libvoikko::spellchecker::suggestion::SuggestionGenerator and modify 
libvoikko::spellchecker::suggestion::SuggestionGeneratorFactory appropriately 
it should now be possible to actually use the suggestions generated by 
HfstSuggestion.

I have not yet implemented the configuration of suggestion generator backend 
in the .pro file. It should be configured just the same way as Speller and 
Analyzer are configured, but that does not work yet.

The SuggestionGenerator interface is not very well designed. Both inputs 
(incorrectly spelled word) and outputs (suggestions) are passed using single 
mediating SuggestionStatus object. For historical reasons that class contains 
some implementation specific stuff about computational cost. Methods

 const wchar_t * getWord();
 size_t getWordLength();
 void addSuggestion(const wchar_t * newSuggestion, int priority);

are the only ones you likely will need from it when implementing 
HfstSuggestion.

I'll probably change the interface at some point so that it will just take a 
word as input and return a list of suggestions as output.

> > Additionally indentation does not match the tab indentation used in
> > libvoikko. I admit that the choice of using tabs for indentation in
> > libvoikko was a mistake and I'll probably reindent all of the source
> > code using four spaces instead.
> 
> Well, I've always been supporter of tabs for line initial indentation,
> but overwhelming majority of projects aren't so I finally set up my vim
> to do GNU style indentation. If you prefer some style that is not GNU
> nor kernel style, but have e.g. vim cindent modeline for the preferred
> style, it would greatly help in delivering properly indented patches.

Unfortunately I do not have modelines available for any editor, I tend to 
regularly switch between different editors. Basically my coding style has 
followed Java coding conventions using tabs for indentation and tab width of 4 
characters.

Harri



More information about the Libvoikko mailing list