def __init__(self, stemming_file, lexicon_file): self.ruleset = load_stemming(stemming_file) self.lexicon, self.form_override, self.accent_override = load_lexicon( lexicon_file, pre_processor=debreath) self.inflexion = Inflexion() self.inflexion.add_lexicon(self.lexicon) self.inflexion.add_stemming_rule_set(self.ruleset)
def __init__(self, stemming_file, lexicon_file=None, strip_length=False): self.ruleset = load_stemming(stemming_file, strip_length) if lexicon_file: self.lexicon, self.form_override, self.accent_override = \ load_lexicon(lexicon_file, pre_processor=debreath) else: self.lexicon = Lexicon() self.form_override = {} self.accent_override = defaultdict(list) self.inflexion = Inflexion() self.inflexion.add_lexicon(self.lexicon) self.inflexion.add_stemming_rule_set(self.ruleset)
def test_stemming(self): s = load_stemming("test_files/stemming_test.yaml") self.assertEqual(s.key_to_rules["bar"][0].surface, "ace") self.assertEqual(s.key_to_rules["foo"][1].tags, {"baz"})
def test_bad_ref(self): with self.assertRaises(RefDoesNotExistException): load_stemming("test_files/bad_ref.yaml")