[libvoikko] Using the Hfst analyser outside of AnalyzerFactory

Harri Pitkänen hatapitk at iki.fi
Wed Sep 25 20:43:02 EEST 2013


On Wednesday 25 September 2013 14:51:03 Francis Tyers wrote:
> In grammar/GrammarChecker.hpp, I have defined:
> 
> 		RuleEngine * ruleEngine;
> 		GcCache gc_cache;
> 		morphology::Analyzer * analyser ;
> 
> The class grammar/CgGrammarChecker.hpp extends this and loads:
> 
>   * An instance of CgRuleEngine into ruleEngine
> 
> I would like to load an instance of HfstAnalyzer into analyser, but I
> don't see how I can create an instance without using the
> AnalyzerFactory, which only allows creation using a setup::Dictionary
> object.
> 
> Would it be better to edit AnalyzerFactory and add a method to create
> analysers only from a path, or is there some other way to get around
> this ?

I think you can just call

  new morphology::HfstAnalyzer(path);

The constructor is missing an implementation right now but the parameter there 
is supposed to contain the path to the directory. So no need to use 
AnalyzerFactory at all. In fact AnalyzerFactory is meant to be used only when 
you don't know (and don't care) about the concrete implementation that will be 
created. There is no need to use it when you know you want HfstAnalyzer.

Harri



More information about the Libvoikko mailing list