Skip to content

Commit

Permalink
Change ru model field Sound.homophones type to list[str]
Browse files Browse the repository at this point in the history
fix check JSON type error
  • Loading branch information
xxyzz committed Mar 19, 2024
1 parent ff18619 commit 790b19f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/wiktextract/extractor/ru/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
4 changes: 2 additions & 2 deletions src/wiktextract/extractor/ru/pronunciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_ru_pronunciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_process_transcription_template(self):
"expected": {
"ipa": "vot",
"audio": "Ru-вот.ogg",
"homophones": [{"word": "вод"}],
"homophones": ["вод"],
},
},
]
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_process_transcriptions_template(self):
"expected": [
{
"ipa": "bɐˈlʲit",
"homophones": [{"word": "болит"}],
"homophones": ["болит"],
"tags": ["singular"],
},
{
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_process_transcription_ru_template_2(self):
{
"ipa": "vot",
"audio": "Ru-вот.ogg",
"homophones": [{"word": "вод"}],
"homophones": ["вод"],
}
],
)
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_process_transcriptions_ru_template_2(self):
[
{
"ipa": "bɐˈlʲit",
"homophones": [{"word": "болит"}],
"homophones": ["болит"],
"tags": ["singular"],
},
{
Expand Down

0 comments on commit 790b19f

Please sign in to comment.