[libvoikko] grammar checking in libvoikko

Harri Pitkänen hatapitk at iki.fi
Mon Sep 16 18:26:00 EEST 2013


On Monday 16 September 2013 11:45:31 Francis Tyers wrote:
> * Is the full analysis of HFST morphologies available through libvoikko,
> or do we just have access to the surface string ?

It used to be but the feature was removed when support for ZHFST spellers was 
added. This was because we dropped the dependency on hfst-optimized-lookup and 
started to use hfstospell instead.

HfstAnalyzer is still there (but the implementation is essentially empty) so 
you should be able to resurrect the feature from Git history quite easily:


> * I see there is some existing work in libvoikko/src/grammar/ -- could /
> should this infrastructure be reused ?

You need to plug in your grammar checker by replacing lines 84 - 134 with your 
checker in this source file:


"const wchar_t * text" contains the text to be checked. For each error you 
find you create a CacheEntry object and call gc_cache_append_error to push the 
error into the cache.

To do all this without breaking the existing code we need to build an abstract 
GrammarChecker superclass and extend it with two subclasses, one for the 
existing implementation and another for your new implementation. The exactly 
same has been done with Analyzer, SpellChecker and others. I can help you with 
that and some other small things that will be needed such as changes to the 
LibreOffice plugin.

> * Implementing this will involve adding a dependency on vislcg3 -- what
> is the best way that this could be done ?

I'm not very familiar with vislcg3. If it is a well behaving library you 
should be able to to just dynamically link with it, just as we do with 


The license appears to be GPLv3+. That is OK for an optional dependency. So 
you need to add a compile time conditional (disabled by default) to enable 
this new feature.

Good luck with your grammar checker and feel free to ask for help whenever you 
have any questions about libvoikko.


More information about the Libvoikko mailing list