Skip to content

Commit

Permalink
Merge branch 'main' of github.com:UAlbertaALTLab/morphodict
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Aug 15, 2024
2 parents 073ac52 + d9a58f1 commit cf298e4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/CreeDictionary/API/search/presentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def to_fst_output_style(value):
ret = original
if original:
ret = use_preferred_animate_emoji(original, animate_emoji)
return ret or ''
return ret or ""


def use_preferred_animate_emoji(original: str, animate_emoji: str) -> str:
Expand Down
3 changes: 3 additions & 0 deletions src/CreeDictionary/CreeDictionary/orthography.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@
CIRCUMFLEX_TO_MACRON = str.maketrans("êîôâ", "ēīōā")
ACCENTED_Y_TO_Y = str.maketrans("ý", "y")


def to_y(latn_accented_y: str) -> str:
"""
Translate SRO with accented y to normal y
"""
return latn_accented_y.translate(ACCENTED_Y_TO_Y)


def to_macrons(sro_circumflex: str) -> str:
"""
Transliterate SRO to macrons.
"""
return sro_circumflex.translate(CIRCUMFLEX_TO_MACRON)


def to_macrons_with_y(sro_circumflex: str) -> str:
"""
Transliterate SRO to macrons with normal y
Expand Down
4 changes: 3 additions & 1 deletion src/CreeDictionary/tests/API_tests/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ def test_search_for_exact_lemma(lemma: Wordform):
# https://github.com/UAlbertaALTLab/morphodict/issues/230
# or there would be flaky local tests and ci tests
assert len(exact_match.wordform.definitions.all()) >= 1
assert all(len(dfn.source_ids) >= 1 for dfn in exact_match.wordform.definitions.all())
assert all(
len(dfn.source_ids) >= 1 for dfn in exact_match.wordform.definitions.all()
)


@pytest.mark.django_db
Expand Down
2 changes: 1 addition & 1 deletion src/CreeDictionary/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ def lemmas():
"""
Strategy to return lemmas from the database.
"""
return WordformStrategy(is_lemma=True,raw_analysis__isnull=False)
return WordformStrategy(is_lemma=True, raw_analysis__isnull=False)
4 changes: 2 additions & 2 deletions src/crkeng/site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
# 'Latn' is Okimāsis/Wolvegrey's SRO
"Latn-y": {
"name": "SRO (êîôâ) with y",
"converter": "CreeDictionary.CreeDictionary.orthography.to_y"
},
"converter": "CreeDictionary.CreeDictionary.orthography.to_y",
},
"Latn": {"name": "SRO (êîôâ) with ý"},
"Latn-x-macron-y": {
"name": "SRO (ēīōā) with y",
Expand Down
13 changes: 10 additions & 3 deletions src/morphodict/lexicon/management/commands/importjsondict.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def _add_definition(self, wordform, text, sources: list[str], **kwargs):
)
return d

def create_definitions(self, wordform, senses, check_uniqueness = False):
def create_definitions(self, wordform, senses, check_uniqueness=False):
"""Create definition objects for the given wordform and senses."""

# Normally definition.citations.all() would tell you the sources, but to
Expand All @@ -542,8 +542,15 @@ def create_definitions(self, wordform, senses, check_uniqueness = False):
keywords.update(stem_keywords(new_definition.semantic_definition))

if check_uniqueness:
keywords -= { kw.text for kw in TargetLanguageKeyword.objects.filter(wordform=wordform)}
keywords -= { kw.text for kw in self.target_language_keyword_buffer._buffer if kw.wordform == wordform}
keywords -= {
kw.text
for kw in TargetLanguageKeyword.objects.filter(wordform=wordform)
}
keywords -= {
kw.text
for kw in self.target_language_keyword_buffer._buffer
if kw.wordform == wordform
}

for kw in keywords:
self.target_language_keyword_buffer.add(
Expand Down

0 comments on commit cf298e4

Please sign in to comment.