From 08746ca1ed4ea0c472d6f5dd783876f5bdb90aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Ba=C3=B1ados=20Schwerter?= Date: Mon, 11 Nov 2024 17:38:54 +0000 Subject: [PATCH] Small refactor --- src/morphodict/search/espt.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/morphodict/search/espt.py b/src/morphodict/search/espt.py index 65f545d3d..e1cf77043 100644 --- a/src/morphodict/search/espt.py +++ b/src/morphodict/search/espt.py @@ -3,7 +3,6 @@ """ import logging -import re from dataclasses import dataclass from morphodict.phrase_translate.tag_maps import ( @@ -126,13 +125,7 @@ def inflect_search_results(self): ) ) - def _generate_inflected_results(self) -> list[_EipResult]: - """ - From the results, sort out the inflectable wordforms, then inflect them - using the new set of tags. - Return the inflected wordforms. - """ - + def _collect_non_inflected_results(self) -> list[Result]: words = [] for r in self.search_run.unsorted_results(): if not r.is_lemma: @@ -147,6 +140,17 @@ def _generate_inflected_results(self) -> list[_EipResult]: if "+N" in self.new_tags and r.is_lemma and "+N" in analysis_tags: words.append(r) + return words + + def _generate_inflected_results(self) -> list[_EipResult]: + """ + From the results, sort out the inflectable wordforms, then inflect them + using the new set of tags. + Return the inflected wordforms. + """ + + words = self._collect_non_inflected_results() + orig_tags_starting_with_plus: list[str] = [] tags_ending_with_plus: list[str] = [] for t in self.new_tags: