Coverage for src/wiktextract/extractor/fr/models.py: 100%
125 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 11:10 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 11:10 +0000
1from pydantic import BaseModel, ConfigDict, Field
4class FrenchBaseModel(BaseModel):
5 model_config = ConfigDict(
6 extra="forbid",
7 strict=True,
8 validate_assignment=True,
9 validate_default=True,
10 )
13class AttestationData(FrenchBaseModel):
14 date: str
17class Example(FrenchBaseModel):
18 text: str = Field(default="", description="Example usage sentence")
19 bold_text_offsets: list[tuple[int, int]] = []
20 translation: str = Field(
21 default="", description="French translation of the example sentence"
22 )
23 bold_translation_offsets: list[tuple[int, int]] = []
24 roman: str = Field(
25 default="", description="Romanization of the example sentence"
26 )
27 bold_roman_offsets: list[tuple[int, int]] = []
28 ref: str = Field(
29 default="",
30 description="Source of the sentence, like book title and page number",
31 )
32 attestations: list[AttestationData] = Field(
33 default=[],
34 description="For examples in 'Attestations historiques' section",
35 )
36 note: str = ""
37 raw_tags: list[str] = []
38 tags: list[str] = []
41class Form(FrenchBaseModel):
42 form: str = ""
43 tags: list[str] = []
44 raw_tags: list[str] = []
45 ipas: list[str] = []
46 source: str = Field(
47 default="",
48 description="Form line template name or Conjugaison page title",
49 )
50 hiragana: str = ""
51 roman: str = ""
52 sense: str = Field(default="", description="Definition of the word")
53 sense_index: int = Field(default=0, ge=0)
54 article: str = ""
57class Sound(FrenchBaseModel):
58 zh_pron: str = Field(default="", description="Chinese word pronunciation")
59 ipa: str = Field(default="", description="International Phonetic Alphabet")
60 audio: str = Field(default="", description="Audio file name")
61 wav_url: str = ""
62 oga_url: str = ""
63 ogg_url: str = ""
64 mp3_url: str = ""
65 opus_url: str = ""
66 flac_url: str = ""
67 tags: list[str] = []
68 raw_tags: list[str] = []
69 rhymes: str = ""
70 categories: list[str] = Field(default=[], exclude=True)
71 homophone: str = ""
72 roman: str = ""
75class Translation(FrenchBaseModel):
76 lang_code: str = Field(
77 default="",
78 description="Wiktionary language code of the translation term",
79 )
80 lang: str = Field(default="", description="Translation language name")
81 word: str = Field(default="", description="Translation term")
82 sense: str = Field(default="", description="Translation gloss")
83 sense_index: int = Field(
84 default=0, ge=0, description="Number of the definition, start from 1"
85 )
86 tags: list[str] = []
87 raw_tags: list[str] = []
88 roman: str = ""
89 traditional_writing: str = Field(
90 default="",
91 description="Alternative writting for Chinese, Korean and Mongolian",
92 )
93 ruby: list[tuple[str, ...]] = Field(
94 default=[], description="Japanese Kanji and furigana"
95 )
98class Linkage(FrenchBaseModel):
99 word: str
100 tags: list[str] = []
101 raw_tags: list[str] = []
102 topics: list[str] = []
103 roman: str = ""
104 alt: str = Field(default="", description="Alternative form")
105 translation: str = Field(default="", description="French translation")
106 sense: str = Field(default="", description="Definition of the word")
107 sense_index: int = Field(
108 default=0, ge=0, description="Number of the definition, start from 1"
109 )
110 ruby: list[tuple[str, ...]] = Field(
111 default=[], description="Japanese Kanji and furigana"
112 )
115class AltForm(FrenchBaseModel):
116 word: str
119class Sense(FrenchBaseModel):
120 glosses: list[str] = []
121 tags: list[str] = []
122 raw_tags: list[str] = []
123 topics: list[str] = []
124 categories: list[str] = []
125 examples: list[Example] = []
126 note: str = ""
127 alt_of: list[AltForm] = []
128 form_of: list[AltForm] = []
129 attestations: list[AttestationData] = []
132class Descendant(FrenchBaseModel):
133 lang_code: str = Field(default="", description="Wiktionary language code")
134 lang: str = Field(default="", description="Language name")
135 word: str = ""
136 roman: str = ""
137 tags: list[str] = []
138 raw_tags: list[str] = []
139 ruby: list[tuple[str, ...]] = Field(
140 default=[], description="Japanese Kanji and furigana"
141 )
142 sense: str = ""
143 descendants: list["Descendant"] = []
146class WordEntry(FrenchBaseModel):
147 model_config = ConfigDict(title="French Wiktionary")
149 word: str = Field(description="Word string")
150 lang_code: str = Field(description="Wiktionary language code")
151 lang: str = Field(description="Localized language name")
152 pos: str = Field(default="", description="Part of speech type")
153 pos_title: str = Field(
154 default="",
155 description="Original POS title for matching etymology texts",
156 )
157 pos_id: str = Field(
158 default="",
159 description="POS id for matching etymology texts",
160 exclude=True,
161 )
162 etymology_texts: list[str] = Field(default=[], description="Etymology list")
163 etymology_examples: list[Example] = Field(
164 default=[], description="Data in 'Attestations historiques' section"
165 )
166 senses: list[Sense] = Field(default=[], description="Sense list")
167 forms: list[Form] = Field(default=[], description="Inflection forms list")
168 sounds: list[Sound] = []
169 translations: list[Translation] = []
170 antonyms: list[Linkage] = []
171 synonyms: list[Linkage] = []
172 hyponyms: list[Linkage] = []
173 hypernyms: list[Linkage] = []
174 holonyms: list[Linkage] = []
175 meronyms: list[Linkage] = []
176 derived: list[Linkage] = []
177 troponyms: list[Linkage] = []
178 paronyms: list[Linkage] = []
179 related: list[Linkage] = []
180 abbreviation: list[Linkage] = []
181 proverbs: list[Linkage] = []
182 anagrams: list[Linkage] = []
183 title: str = Field(default="", description="Redirect page source title")
184 redirect: str = Field(default="", description="Redirect page target title")
185 categories: list[str] = []
186 notes: list[str] = []
187 tags: list[str] = []
188 raw_tags: list[str] = []
189 attestations: list[AttestationData] = []
190 original_title: str = ""
191 descendants: list[Descendant] = []