diff --git a/src/CreeDictionary/API/search/presentation.py b/src/CreeDictionary/API/search/presentation.py index 88dfbb712..50e0e1744 100644 --- a/src/CreeDictionary/API/search/presentation.py +++ b/src/CreeDictionary/API/search/presentation.py @@ -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: diff --git a/src/CreeDictionary/CreeDictionary/orthography.py b/src/CreeDictionary/CreeDictionary/orthography.py index c8fdf8b97..e4befd11b 100644 --- a/src/CreeDictionary/CreeDictionary/orthography.py +++ b/src/CreeDictionary/CreeDictionary/orthography.py @@ -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 diff --git a/src/CreeDictionary/tests/API_tests/model_test.py b/src/CreeDictionary/tests/API_tests/model_test.py index 887768b0a..553d3e1ae 100644 --- a/src/CreeDictionary/tests/API_tests/model_test.py +++ b/src/CreeDictionary/tests/API_tests/model_test.py @@ -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 diff --git a/src/CreeDictionary/tests/conftest.py b/src/CreeDictionary/tests/conftest.py index d629e5bf6..6030e4388 100644 --- a/src/CreeDictionary/tests/conftest.py +++ b/src/CreeDictionary/tests/conftest.py @@ -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) diff --git a/src/crkeng/site/settings.py b/src/crkeng/site/settings.py index 3f0db5ae4..ccf052718 100644 --- a/src/crkeng/site/settings.py +++ b/src/crkeng/site/settings.py @@ -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", diff --git a/src/morphodict/lexicon/management/commands/importjsondict.py b/src/morphodict/lexicon/management/commands/importjsondict.py index 12745e7e1..432d96e5c 100644 --- a/src/morphodict/lexicon/management/commands/importjsondict.py +++ b/src/morphodict/lexicon/management/commands/importjsondict.py @@ -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 @@ -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(