[libvoikko] VoikkoGrammarError and	voikkoGetGrammarErrorShortDescription
    Harri Pitkänen 
    hatapitk at iki.fi
       
    Mon Nov  4 18:14:06 EET 2013
    
    
  
On Monday 04 November 2013 15:20:36 Francis Tyers wrote:
> At the moment VoikkoGrammarError is typedeffed as voikko_grammar_error.
> 
> I would like to add 'char *title' to voikko_grammar_error, would this be
> ok ?
The exact layout of voikko_grammar_error is visible to client code through 
deprecated API and thus it cannot be changed. But you can change 
VoikkoGrammarError:
 typedef struct {
	voikko_grammar_error legacyError;
	char * title;
	GrammarChecker * checker;
 } VoikkoGrammarError;
(Actually VoikkoGrammarError could just as well be turned into a class.)
You need the reference to the grammar checker that created the error so that 
in voikkoGetGrammarErrorShortDescription you can do something like
  error->checker->translateErrorTitle(error->title, language);
> Also, what would the best way be to load the error descriptions from the
> XML file ? Keep a map<pair<string, string>, pair<string, string>> in the
> CgGrammarChecker.hpp with pair<code, lang>, pair<title, description>,
> e.g.
> 
> map< pair<"orth-prop", "en">, pair<"Capitalisation of proper nouns",
> "The proper noun "$1" should begin with a capital letter."> >
> 
> Then pass this to the CgRuleEngine class via the constructor ?
Sounds reasonable.
> I would probably have to edit the DictionaryLoader too, to pass through
> the path to the errors.xml file.
I think the path could be derived directly from 
dictionary.getGrammarBackend().getPath() which is something CgGrammarChecker 
already has access to?
Harri
    
    
More information about the Libvoikko
mailing list