Coverage for src/wiktextract/extractor/ms/models.py: 100%
88 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-04 10:58 +0000
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-04 10:58 +0000
1from pydantic import BaseModel, ConfigDict, Field
4class MalayBaseModel(BaseModel):
5 model_config = ConfigDict(
6 extra="forbid",
7 strict=True,
8 validate_assignment=True,
9 validate_default=True,
10 )
13class Example(MalayBaseModel):
14 text: str
15 bold_text_offsets: list[tuple[int, int]] = []
16 translation: str = ""
17 bold_translation_offsets: list[tuple[int, int]] = []
18 roman: str = ""
19 bold_roman_offsets: list[tuple[int, int]] = []
20 ref: str = ""
21 tags: list[str] = []
22 raw_tags: list[str] = []
23 literal_meaning: str = ""
24 bold_literal_offsets: list[tuple[int, int]] = []
27class AltForm(MalayBaseModel):
28 word: str
31class Sense(MalayBaseModel):
32 glosses: list[str] = []
33 tags: list[str] = []
34 raw_tags: list[str] = []
35 topics: list[str] = []
36 categories: list[str] = []
37 examples: list[Example] = []
38 form_of: list[AltForm] = []
39 alt_of: list[AltForm] = []
42class Form(MalayBaseModel):
43 form: str
44 tags: list[str] = []
45 raw_tags: list[str] = []
48class Linkage(MalayBaseModel):
49 word: str
50 tags: list[str] = []
51 raw_tags: list[str] = []
52 sense: str = ""
55class Translation(MalayBaseModel):
56 lang_code: str = Field(
57 description="Wiktionary language code of the translation term",
58 )
59 lang: str = Field(description="Translation language name")
60 word: str = Field(description="Translation term")
61 sense: str = Field(default="", description="Translation gloss")
62 tags: list[str] = []
63 raw_tags: list[str] = []
64 roman: str = ""
65 categories: list[str] = Field(default=[], exclude=True)
68class Sound(MalayBaseModel):
69 zh_pron: str = Field(default="", description="Chinese word pronunciation")
70 ipa: str = Field(default="", description="International Phonetic Alphabet")
71 audio: str = Field(default="", description="Audio file name")
72 wav_url: str = ""
73 oga_url: str = ""
74 ogg_url: str = ""
75 mp3_url: str = ""
76 opus_url: str = ""
77 flac_url: str = ""
78 tags: list[str] = []
79 raw_tags: list[str] = []
80 homophone: str = ""
81 other: str = ""
82 roman: str = ""
83 rhymes: str = ""
84 categories: list[str] = Field(default=[], exclude=True)
85 hyphenation: str = Field(default="", exclude=True)
88class WordEntry(MalayBaseModel):
89 model_config = ConfigDict(title="Malay Wiktionary")
90 word: str = Field(description="Word string")
91 lang_code: str = Field(description="Wiktionary language code")
92 lang: str = Field(description="Localized language name")
93 pos: str = Field(description="Part of speech type")
94 pos_title: str = ""
95 senses: list[Sense] = []
96 categories: list[str] = []
97 tags: list[str] = []
98 raw_tags: list[str] = []
99 forms: list[Form] = []
100 etymology_text: str = ""
101 antonyms: list[Linkage] = []
102 synonyms: list[Linkage] = []
103 translations: list[Translation] = []
104 hypernyms: list[Linkage] = []
105 coordinate_terms: list[Linkage] = []
106 hyponyms: list[Linkage] = []
107 hyphenation: str = ""
108 sounds: list[Sound] = []
109 derived: list[Linkage] = []
110 anagrams: list[Linkage] = []
111 proverbs: list[Linkage] = []
112 related: list[Linkage] = []
113 notes: list[str] = []