Coverage for src/wiktextract/extractor/en/type_utils.py: 100%
162 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 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
18 extra: str
19 qualifier: str
20 roman: str
21 ruby: Union[list[Sequence[str]], list[tuple[str, str]]]
22 sense: str
23 source: str
24 tags: list[str]
25 taxonomic: str
26 topics: list[str]
27 urls: list[str]
28 word: str
31class ExampleData(TypedDict, total=False):
32 english: str
33 bold_english_offsets: list[tuple[int, int]]
34 note: str
35 ref: str
36 roman: str
37 bold_roman_offsets: list[tuple[int, int]]
38 ruby: Union[list[tuple[str, str]], list[Sequence[str]]]
39 text: str
40 bold_text_offsets: list[tuple[int, int]]
41 type: str
42 literal_meaning: str
43 bold_literal_offsets: list[tuple[int, int]]
44 tags: list[str]
45 raw_tags: list[str]
48class FormOf(TypedDict, total=False):
49 word: str
50 extra: str
51 roman: str
54LinkData = list[Sequence[str]]
57class PlusObjTemplateData(TypedDict, total=False):
58 tags: list[str]
59 words: list[str]
60 meaning: str
63ExtraTemplateData = Union[PlusObjTemplateData]
66class TemplateData(TypedDict, total=False):
67 args: TemplateArgs
68 expansion: str
69 name: str
70 extra_data: ExtraTemplateData
73class DescendantData(TypedDict, total=False):
74 depth: int
75 tags: list[str]
76 templates: list[TemplateData]
77 text: str
80class FormData(TypedDict, total=False):
81 form: str
82 head_nr: int
83 ipa: str
84 roman: str
85 ruby: Union[list[tuple[str, str]], list[Sequence[str]]]
86 source: str
87 tags: list[str]
88 raw_tags: list[str]
89 topics: list[str]
92class Hyphenation(TypedDict, total=False):
93 parts: list[str]
94 tags: list[str]
97SoundData = TypedDict(
98 "SoundData",
99 {
100 "audio": str,
101 "audio-ipa": str,
102 "enpr": str,
103 "form": str,
104 "hangeul": str,
105 "homophone": str,
106 "ipa": str,
107 "mp3_url": str,
108 "note": str,
109 "ogg_url": str,
110 "other": str,
111 "rhymes": str,
112 "tags": list[str],
113 "text": str,
114 "topics": list[str],
115 "zh-pron": str,
116 },
117 total=False,
118)
121class TranslationData(TypedDict, total=False):
122 alt: str
123 code: str
124 english: str
125 lang: str
126 note: str
127 roman: str
128 sense: str
129 tags: list[str]
130 taxonomic: str
131 topics: list[str]
132 word: str
135# Xxyzz's East Asian etymology example data
136class EtymologyExample(TypedDict, total=False):
137 english: str
138 raw_tags: list[str]
139 ref: str
140 roman: str
141 tags: list[str]
142 text: str
143 type: str
146class ReferenceData(TypedDict, total=False):
147 text: str
148 refn: str
151class AttestationData(TypedDict, total=False):
152 date: str
153 references: list[ReferenceData]
156class SenseData(TypedDict, total=False):
157 alt_of: list[AltOf]
158 antonyms: list[LinkageData]
159 categories: list[str]
160 compound_of: list[AltOf]
161 coordinate_terms: list[LinkageData]
162 examples: list[ExampleData]
163 form_of: list[FormOf]
164 glosses: list[str]
165 head_nr: int
166 holonyms: list[LinkageData]
167 hypernyms: list[LinkageData]
168 hyponyms: list[LinkageData]
169 instances: list[LinkageData]
170 links: list[LinkData]
171 meronyms: list[LinkageData]
172 qualifier: str
173 raw_glosses: list[str]
174 related: list[LinkageData] # also used for "alternative forms"
175 senseid: list[str]
176 synonyms: list[LinkageData]
177 tags: list[str]
178 taxonomic: str
179 topics: list[str]
180 wikidata: list[str]
181 wikipedia: list[str]
182 attestations: list[AttestationData]
185class WordData(TypedDict, total=False):
186 abbreviations: list[LinkageData]
187 alt_of: list[AltOf]
188 antonyms: list[LinkageData]
189 categories: list[str]
190 coordinate_terms: list[LinkageData]
191 derived: list[LinkageData]
192 descendants: list[DescendantData]
193 etymology_examples: list[EtymologyExample]
194 etymology_number: int
195 etymology_templates: list[TemplateData]
196 etymology_text: str
197 form_of: list[FormOf]
198 forms: list[FormData]
199 head_templates: list[TemplateData]
200 holonyms: list[LinkageData]
201 hyphenation: list[str] # Being deprecated
202 hyphenations: list[Hyphenation]
203 hypernyms: list[LinkageData]
204 hyponyms: list[LinkageData]
205 inflection_templates: list[TemplateData]
206 info_templates: list[TemplateData]
207 instances: list[LinkageData]
208 lang: str
209 lang_code: str
210 literal_meaning: str
211 meronyms: list[LinkageData]
212 original_title: str
213 pos: str
214 proverbs: list[LinkageData]
215 redirects: list[str]
216 related: list[LinkageData]
217 senses: list[SenseData]
218 sounds: list[SoundData]
219 synonyms: list[LinkageData]
220 translations: list[TranslationData]
221 troponyms: list[LinkageData]
222 wikidata: list[str]
223 wikipedia: list[str]
224 word: str
225 anagrams: list[LinkageData] = []