From 790b19f8d90f249378dcb885accd61cd9094b763 Mon Sep 17 00:00:00 2001 From: xxyzz Date: Tue, 19 Mar 2024 09:53:15 +0800 Subject: [PATCH] Change ru model field `Sound.homophones` type to `list[str]` fix check JSON type error --- src/wiktextract/extractor/ru/models.py | 2 +- src/wiktextract/extractor/ru/pronunciation.py | 4 ++-- tests/test_ru_pronunciation.py | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wiktextract/extractor/ru/models.py b/src/wiktextract/extractor/ru/models.py index 0ebe78b8..01f10cdc 100644 --- a/src/wiktextract/extractor/ru/models.py +++ b/src/wiktextract/extractor/ru/models.py @@ -46,7 +46,7 @@ class Sound(BaseModelWrap): default=[], description="Specifying the variant of the pronunciation" ) raw_tags: list[str] = [] - homophones: list[Linkage] = Field( + homophones: list[str] = Field( default=[], description="Words with same pronunciation" ) diff --git a/src/wiktextract/extractor/ru/pronunciation.py b/src/wiktextract/extractor/ru/pronunciation.py index c381d9aa..3126f508 100644 --- a/src/wiktextract/extractor/ru/pronunciation.py +++ b/src/wiktextract/extractor/ru/pronunciation.py @@ -7,7 +7,7 @@ from wiktextract.wxr_context import WiktextractContext from ..share import create_audio_url_dict -from .models import Linkage, Sound, WordEntry +from .models import Sound, WordEntry def process_transcription_template( @@ -209,7 +209,7 @@ def extract_homophones( ): homophones_raw = clean_node(wxr, {}, template_params.get("омофоны", "")) homophones = [ - Linkage(word=h.strip()) for h in homophones_raw.split(",") if h.strip() + h.strip() for h in homophones_raw.split(",") if h.strip() != "" ] if homophones: if isinstance(sounds, list): diff --git a/tests/test_ru_pronunciation.py b/tests/test_ru_pronunciation.py index dde7a4fc..efe78812 100644 --- a/tests/test_ru_pronunciation.py +++ b/tests/test_ru_pronunciation.py @@ -68,7 +68,7 @@ def test_process_transcription_template(self): "expected": { "ipa": "vot", "audio": "Ru-вот.ogg", - "homophones": [{"word": "вод"}], + "homophones": ["вод"], }, }, ] @@ -104,7 +104,7 @@ def test_process_transcriptions_template(self): "expected": [ { "ipa": "bɐˈlʲit", - "homophones": [{"word": "болит"}], + "homophones": ["болит"], "tags": ["singular"], }, { @@ -159,7 +159,7 @@ def test_process_transcription_ru_template_2(self): { "ipa": "vot", "audio": "Ru-вот.ogg", - "homophones": [{"word": "вод"}], + "homophones": ["вод"], } ], ) @@ -201,7 +201,7 @@ def test_process_transcriptions_ru_template_2(self): [ { "ipa": "bɐˈlʲit", - "homophones": [{"word": "болит"}], + "homophones": ["болит"], "tags": ["singular"], }, {