diff --git a/wani.py b/wani.py index 5717210..223b310 100644 --- a/wani.py +++ b/wani.py @@ -261,9 +261,7 @@ class WordFormMsdCR(WordFormAnyCR): def _render(self): msd = self.word_renderer.get_lemma_msd(self.lemma, self.msd) - WordLemma = namedtuple('WordLemmaOnly', 'msd most_frequent_text lemma text') - backup_word = WordLemma(msd=msd, most_frequent_text=lambda *x: None, lemma=None, text=None) - self.words.append(backup_word) + self.words.append(WordMsdOnly(msd)) return super()._render() @@ -832,12 +830,16 @@ def get_msd(comp): logging.error(d, file=sys.stderr) raise NotImplementedError("MSD?") -def lemma_only_word(msd): - if msd is None: + +class WordMsdOnly: + def __init__(self, msd): + self.msd = msd + self.lemma = None + self.text = None + + def most_frequent_text(self, _): return None - else: - WordLemma = namedtuple('WordLemmaOnly', 'msd most_frequent_text lemma text') - return WordLemma(msd=msd, most_frequent_text=lambda *x: None, lemma=None, text=None) + class Word: def __init__(self, xml, do_msd_translate):