How to find out if suffix rule was applied

Submitted by fcbr on Fri, 04/20/2018 - 14:52
Forums

I'm using Freeling 4.0 and I need to check if a particular word was found via the suffixes rules.

Using Python, I'm using the following code excerpt:

w = freeling.word(form)
dic.annotate_word(w)
w.get_lemma()
w.found_in_dict()

It looks like the only way to find out if a word was "found" via suffix rules is when get_lemma() returns something and fund_in_dict() returns None.

Is that correct?

In 4.0 yes, there is no way to find out that.

However, in 4.1, class word has methods word::is_analyzed_by()  and word::get_analyzed_by() that will allow you to query whether the word was analyzed by a specific module, or to get all the modules that analyzed the word.

e.g.

if (w.is_analyzed_by(word::AFFIXES)) { ... }

or

if (w.get_analyzed_by() & word::AFFIXES != 0) {...}