Coverage for src/wiktextract/extractor/fr/models.py: 100%
112 statements
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-15 05:18 +0000
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-15 05:18 +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 = ""
39class Form(FrenchBaseModel):
40 form: str = ""
41 tags: list[str] = []
42 raw_tags: list[str] = []
43 ipas: list[str] = []
44 source: str = Field(
45 default="",
46 description="Form line template name or Conjugaison page title",
47 )
48 hiragana: str = ""
49 roman: str = ""
50 sense: str = Field(default="", description="Definition of the word")
51 sense_index: int = Field(default=0, ge=0)
54class Sound(FrenchBaseModel):
55 zh_pron: str = Field(default="", description="Chinese word pronunciation")
56 ipa: str = Field(default="", description="International Phonetic Alphabet")
57 audio: str = Field(default="", description="Audio file name")
58 wav_url: str = ""
59 oga_url: str = ""
60 ogg_url: str = ""
61 mp3_url: str = ""
62 opus_url: str = ""
63 flac_url: str = ""
64 tags: list[str] = []
65 raw_tags: list[str] = []
66 rhymes: str = ""
67 categories: list[str] = Field(default=[], exclude=True)
68 homophone: str = ""
69 roman: str = ""
72class Translation(FrenchBaseModel):
73 lang_code: str = Field(
74 default="",
75 description="Wiktionary language code of the translation term",
76 )
77 lang: str = Field(default="", description="Translation language name")
78 word: str = Field(default="", description="Translation term")
79 sense: str = Field(default="", description="Translation gloss")
80 sense_index: int = Field(
81 default=0, ge=0, description="Number of the definition, start from 1"
82 )
83 tags: list[str] = []
84 raw_tags: list[str] = []
85 roman: str = ""
86 traditional_writing: str = Field(
87 default="",
88 description="Alternative writting for Chinese, Korean and Mongolian",
89 )
90 ruby: list[tuple[str, ...]] = Field(
91 default=[], description="Japanese Kanji and furigana"
92 )
95class Linkage(FrenchBaseModel):
96 word: str
97 tags: list[str] = []
98 raw_tags: list[str] = []
99 topics: list[str] = []
100 roman: str = ""
101 alt: str = Field(default="", description="Alternative form")
102 translation: str = Field(default="", description="French translation")
103 sense: str = Field(default="", description="Definition of the word")
104 sense_index: int = Field(
105 default=0, ge=0, description="Number of the definition, start from 1"
106 )
107 lang: str = Field(default="", description="Localized language name")
108 lang_code: str = Field(default="", description="Wiktionary language code")
111class AltForm(FrenchBaseModel):
112 word: str
115class Sense(FrenchBaseModel):
116 glosses: list[str] = []
117 tags: list[str] = []
118 raw_tags: list[str] = []
119 topics: list[str] = []
120 categories: list[str] = []
121 examples: list[Example] = []
122 note: str = ""
123 alt_of: list[AltForm] = []
124 form_of: list[AltForm] = []
125 attestations: list[AttestationData] = []
128class WordEntry(FrenchBaseModel):
129 model_config = ConfigDict(title="French Wiktionary")
131 word: str = Field(description="Word string")
132 lang_code: str = Field(description="Wiktionary language code")
133 lang: str = Field(description="Localized language name")
134 pos: str = Field(default="", description="Part of speech type")
135 pos_title: str = Field(
136 default="",
137 description="Original POS title for matching etymology texts",
138 )
139 pos_id: str = Field(
140 default="",
141 description="POS id for matching etymology texts",
142 exclude=True,
143 )
144 etymology_texts: list[str] = Field(default=[], description="Etymology list")
145 etymology_examples: list[Example] = Field(
146 default=[], description="Data in 'Attestations historiques' section"
147 )
148 senses: list[Sense] = Field(default=[], description="Sense list")
149 forms: list[Form] = Field(default=[], description="Inflection forms list")
150 sounds: list[Sound] = []
151 translations: list[Translation] = []
152 antonyms: list[Linkage] = []
153 synonyms: list[Linkage] = []
154 hyponyms: list[Linkage] = []
155 hypernyms: list[Linkage] = []
156 holonyms: list[Linkage] = []
157 meronyms: list[Linkage] = []
158 derived: list[Linkage] = []
159 troponyms: list[Linkage] = []
160 paronyms: list[Linkage] = []
161 related: list[Linkage] = []
162 abbreviation: list[Linkage] = []
163 proverbs: list[Linkage] = []
164 anagrams: list[Linkage] = []
165 title: str = Field(default="", description="Redirect page source title")
166 redirect: str = Field(default="", description="Redirect page target title")
167 categories: list[str] = []
168 notes: list[str] = []
169 tags: list[str] = []
170 raw_tags: list[str] = []
171 attestations: list[AttestationData] = []
172 original_title: str = ""