-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populated first function of to_target
- Loading branch information
Showing
4 changed files
with
39 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import logging | ||
|
||
from morphodict.analysis import RichAnalysis | ||
from morphodict.phrase_translate.source_tag_map import ( | ||
noun_wordform_to_phrase, | ||
verb_wordform_to_phrase, | ||
) | ||
from morphodict.phrase_translate.fst import ( | ||
inflect_target_noun_phrase, | ||
inflect_target_verb_phrase | ||
) | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def inflect_target_language_phrase(analysis, lemma_definition): | ||
if isinstance(analysis, tuple): | ||
analysis = RichAnalysis(analysis) | ||
cree_wordform_tag_list = analysis.prefix_tags + analysis.suffix_tags | ||
|
||
if "+N" in cree_wordform_tag_list: | ||
tags_for_phrase = noun_wordform_to_phrase.map_tags(cree_wordform_tag_list) | ||
tagged_phrase = f"{''.join(tags_for_phrase)} {lemma_definition}" | ||
logger.debug("tagged_phrase = %s\n", tagged_phrase) | ||
phrase = inflect_target_noun_phrase(tagged_phrase) | ||
logger.debug("phrase = %s\n", phrase) | ||
return phrase.strip() | ||
|
||
elif "+V" in cree_wordform_tag_list: | ||
tags_for_phrase = verb_wordform_to_phrase.map_tags(cree_wordform_tag_list) | ||
tagged_phrase = f"{''.join(tags_for_phrase)} {lemma_definition}" | ||
logger.debug("tagged_phrase = %s\n", tagged_phrase) | ||
phrase = inflect_target_verb_phrase(tagged_phrase) | ||
logger.debug("phrase = %s\n", phrase) | ||
return phrase.strip() |