Coverage for src / wiktextract / extractor / en / type_utils.py: 100%
173 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-03 06:43 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-03 06:43 +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 = list[Sequence[str]]
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
88class FormData(TypedDict, total=False):
89 form: str
90 head_nr: int
91 ipa: str
92 roman: str
93 ruby: Union[list[tuple[str, str]], list[Sequence[str]]]
94 source: str
95 tags: list[str]
96 raw_tags: list[str]
97 topics: list[str]
100class Hyphenation(TypedDict, total=False):
101 parts: list[str]
102 tags: list[str]
105SoundData = TypedDict(
106 "SoundData",
107 {
108 "audio": str,
109 "audio-ipa": str,
110 "enpr": str,
111 "form": str,
112 "hangeul": str,
113 "homophone": str,
114 "ipa": str,
115 "mp3_url": str,
116 "note": str,
117 "ogg_url": str,
118 "other": str,
119 "rhymes": str,
120 "tags": list[str],
121 "text": str,
122 "topics": list[str],
123 "zh-pron": str,
124 },
125 total=False,
126)
129class TranslationData(TypedDict, total=False):
130 alt: str
131 lang_code: str
132 code: str # DEPRECATED in favor of lang_code
133 english: str # DEPRECATED in favor of "translation"
134 translation: str
135 lang: str
136 note: str
137 roman: str
138 sense: str
139 tags: list[str]
140 taxonomic: str
141 topics: list[str]
142 word: str
145# Xxyzz's East Asian etymology example data
146class EtymologyExample(TypedDict, total=False):
147 english: str # DEPRECATED in favor of "translation"
148 translation: str
149 raw_tags: list[str]
150 ref: str
151 roman: str
152 tags: list[str]
153 text: str
154 type: str
157class ReferenceData(TypedDict, total=False):
158 text: str
159 refn: str
162class AttestationData(TypedDict, total=False):
163 date: str
164 references: list[ReferenceData]
167class SenseData(TypedDict, total=False):
168 alt_of: list[AltOf]
169 antonyms: list[LinkageData]
170 categories: list[str]
171 compound_of: list[AltOf]
172 coordinate_terms: list[LinkageData]
173 examples: list[ExampleData]
174 form_of: list[FormOf]
175 glosses: list[str]
176 head_nr: int
177 holonyms: list[LinkageData]
178 hypernyms: list[LinkageData]
179 hyponyms: list[LinkageData]
180 instances: list[LinkageData]
181 links: list[LinkData]
182 meronyms: list[LinkageData]
183 qualifier: str
184 raw_glosses: list[str]
185 related: list[LinkageData] # also used for "alternative forms"
186 senseid: list[str]
187 synonyms: list[LinkageData]
188 tags: list[str]
189 taxonomic: str
190 topics: list[str]
191 wikidata: list[str]
192 wikipedia: list[str]
193 attestations: list[AttestationData]
196class WordData(TypedDict, total=False):
197 abbreviations: list[LinkageData]
198 alt_of: list[AltOf]
199 antonyms: list[LinkageData]
200 categories: list[str]
201 coordinate_terms: list[LinkageData]
202 derived: list[LinkageData]
203 descendants: list[DescendantData]
204 etymology_examples: list[EtymologyExample]
205 etymology_number: int
206 etymology_templates: list[TemplateData]
207 etymology_text: str
208 form_of: list[FormOf]
209 forms: list[FormData]
210 head_templates: list[TemplateData]
211 holonyms: list[LinkageData]
212 hyphenation: list[str] # Being deprecated
213 hyphenations: list[Hyphenation]
214 hypernyms: list[LinkageData]
215 hyponyms: list[LinkageData]
216 inflection_templates: list[TemplateData]
217 info_templates: list[TemplateData]
218 instances: list[LinkageData]
219 lang: str
220 lang_code: str
221 literal_meaning: str
222 meronyms: list[LinkageData]
223 original_title: str
224 pos: str
225 proverbs: list[LinkageData]
226 redirects: list[str]
227 related: list[LinkageData]
228 senses: list[SenseData]
229 sounds: list[SoundData]
230 synonyms: list[LinkageData]
231 translations: list[TranslationData]
232 troponyms: list[LinkageData]
233 wikidata: list[str]
234 wikipedia: list[str]
235 word: str
236 anagrams: list[LinkageData]