Coverage for src/wiktextract/extractor/en/type_utils.py: 100%
176 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-07 00:55 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-07 00:55 +0000
1from typing import (
2 Sequence,
3 TypedDict,
4 Union,
5)
7from wikitextprocessor.core import TemplateArgs
10class AltOf(TypedDict, total=False):
11 word: str
12 extra: str
15class LinkageData(TypedDict, total=False):
16 alt: str
17 english: str # DEPRECATED in favor of "translation"
18 translation: str
19 extra: str
20 qualifier: str
21 raw_tags: list[str]
22 roman: str
23 ruby: Union[list[Sequence[str]], list[tuple[str, str]]]
24 sense: str
25 source: str
26 tags: list[str]
27 taxonomic: str
28 topics: list[str]
29 urls: list[str]
30 word: str
33class ExampleData(TypedDict, total=False):
34 english: str # DEPRECATED in favor of "translation"
35 translation: str
36 bold_translation_offsets: list[tuple[int, int]]
37 note: str
38 ref: str
39 roman: str
40 bold_roman_offsets: list[tuple[int, int]]
41 ruby: Union[list[tuple[str, str]], list[Sequence[str]]]
42 text: str
43 bold_text_offsets: list[tuple[int, int]]
44 type: str
45 literal_meaning: str
46 bold_literal_offsets: list[tuple[int, int]]
47 tags: list[str]
48 raw_tags: list[str]
51class FormOf(TypedDict, total=False):
52 word: str
53 extra: str
54 roman: str
57LinkData = tuple[str, str] # text, link target
60class PlusObjTemplateData(TypedDict, total=False):
61 tags: list[str]
62 words: list[str]
63 meaning: str
66ExtraTemplateData = Union[PlusObjTemplateData]
69class TemplateData(TypedDict, total=False):
70 args: TemplateArgs
71 expansion: str
72 name: str
73 extra_data: ExtraTemplateData
76class DescendantData(TypedDict, total=False):
77 lang_code: str
78 lang: str
79 word: str
80 roman: str
81 tags: list[str]
82 raw_tags: list[str]
83 descendants: list["DescendantData"]
84 ruby: list[tuple[str, ...]]
85 sense: str
86 etymology_templates: list[TemplateData]
89class FormData(TypedDict, total=False):
90 form: str
91 head_nr: int
92 ipa: str
93 roman: str
94 ruby: Union[list[tuple[str, str]], list[Sequence[str]]]
95 source: str
96 tags: list[str]
97 raw_tags: list[str]
98 topics: list[str]
99 links: list[LinkData]
102class Hyphenation(TypedDict, total=False):
103 parts: list[str]
104 tags: list[str]
107SoundData = TypedDict(
108 "SoundData",
109 {
110 "audio": str,
111 "audio-ipa": str,
112 "enpr": str,
113 "form": str,
114 "hangeul": str,
115 "homophone": str,
116 "ipa": str,
117 "mp3_url": str,
118 "note": str,
119 "ogg_url": str,
120 "other": str,
121 "rhymes": str,
122 "tags": list[str],
123 "text": str,
124 "topics": list[str],
125 "zh-pron": str,
126 },
127 total=False,
128)
131class TranslationData(TypedDict, total=False):
132 alt: str
133 lang_code: str
134 code: str # DEPRECATED in favor of lang_code
135 english: str # DEPRECATED in favor of "translation"
136 translation: str
137 lang: str
138 note: str
139 roman: str
140 sense: str
141 tags: list[str]
142 taxonomic: str
143 topics: list[str]
144 word: str
147# Xxyzz's East Asian etymology example data
148class EtymologyExample(TypedDict, total=False):
149 english: str # DEPRECATED in favor of "translation"
150 translation: str
151 raw_tags: list[str]
152 ref: str
153 roman: str
154 tags: list[str]
155 text: str
156 type: str
159class ReferenceData(TypedDict, total=False):
160 text: str
161 refn: str
164class AttestationData(TypedDict, total=False):
165 date: str
166 references: list[ReferenceData]
169class SenseData(TypedDict, total=False):
170 alt_of: list[AltOf]
171 antonyms: list[LinkageData]
172 categories: list[str]
173 compound_of: list[AltOf]
174 coordinate_terms: list[LinkageData]
175 examples: list[ExampleData]
176 form_of: list[FormOf]
177 glosses: list[str]
178 head_nr: int
179 holonyms: list[LinkageData]
180 hypernyms: list[LinkageData]
181 hyponyms: list[LinkageData]
182 instances: list[LinkageData]
183 links: list[LinkData]
184 meronyms: list[LinkageData]
185 qualifier: str
186 raw_glosses: list[str]
187 related: list[LinkageData] # also used for "alternative forms"
188 senseid: list[str]
189 synonyms: list[LinkageData]
190 tags: list[str]
191 taxonomic: str
192 topics: list[str]
193 wikidata: list[str]
194 wikipedia: list[str]
195 attestations: list[AttestationData]
198class WordData(TypedDict, total=False):
199 abbreviations: list[LinkageData]
200 alt_of: list[AltOf]
201 antonyms: list[LinkageData]
202 categories: list[str]
203 coordinate_terms: list[LinkageData]
204 derived: list[LinkageData]
205 descendants: list[DescendantData]
206 etymology_examples: list[EtymologyExample]
207 etymology_links: list[LinkData]
208 etymology_number: str
209 etymology_templates: list[TemplateData]
210 etymology_text: str
211 form_of: list[FormOf]
212 forms: list[FormData]
213 head_templates: list[TemplateData]
214 holonyms: list[LinkageData]
215 hyphenation: list[str] # Being deprecated
216 hyphenations: list[Hyphenation]
217 hypernyms: list[LinkageData]
218 hyponyms: list[LinkageData]
219 inflection_templates: list[TemplateData]
220 info_templates: list[TemplateData]
221 instances: list[LinkageData]
222 lang: str
223 lang_code: str
224 literal_meaning: str
225 meronyms: list[LinkageData]
226 original_title: str
227 pos: str
228 proverbs: list[LinkageData]
229 redirects: list[str]
230 related: list[LinkageData]
231 senses: list[SenseData]
232 sounds: list[SoundData]
233 synonyms: list[LinkageData]
234 translations: list[TranslationData]
235 troponyms: list[LinkageData]
236 wikidata: list[str]
237 wikipedia: list[str]
238 word: str
239 anagrams: list[LinkageData]