Coverage for src / wiktextract / extractor / en / type_utils.py: 100%

174 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-11 04:48 +0000

1from typing import ( 

2 Sequence, 

3 TypedDict, 

4 Union, 

5) 

6 

7from wikitextprocessor.core import TemplateArgs 

8 

9 

10class AltOf(TypedDict, total=False): 

11 word: str 

12 extra: str 

13 

14 

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 

31 

32 

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] 

49 

50 

51class FormOf(TypedDict, total=False): 

52 word: str 

53 extra: str 

54 roman: str 

55 

56 

57LinkData = list[Sequence[str]] 

58 

59 

60class PlusObjTemplateData(TypedDict, total=False): 

61 tags: list[str] 

62 words: list[str] 

63 meaning: str 

64 

65 

66ExtraTemplateData = Union[PlusObjTemplateData] 

67 

68 

69class TemplateData(TypedDict, total=False): 

70 args: TemplateArgs 

71 expansion: str 

72 name: str 

73 extra_data: ExtraTemplateData 

74 

75 

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 

87 

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] 

98 links: list[tuple[str, str]] 

99 

100 

101class Hyphenation(TypedDict, total=False): 

102 parts: list[str] 

103 tags: list[str] 

104 

105 

106SoundData = TypedDict( 

107 "SoundData", 

108 { 

109 "audio": str, 

110 "audio-ipa": str, 

111 "enpr": str, 

112 "form": str, 

113 "hangeul": str, 

114 "homophone": str, 

115 "ipa": str, 

116 "mp3_url": str, 

117 "note": str, 

118 "ogg_url": str, 

119 "other": str, 

120 "rhymes": str, 

121 "tags": list[str], 

122 "text": str, 

123 "topics": list[str], 

124 "zh-pron": str, 

125 }, 

126 total=False, 

127) 

128 

129 

130class TranslationData(TypedDict, total=False): 

131 alt: str 

132 lang_code: str 

133 code: str # DEPRECATED in favor of lang_code 

134 english: str # DEPRECATED in favor of "translation" 

135 translation: str 

136 lang: str 

137 note: str 

138 roman: str 

139 sense: str 

140 tags: list[str] 

141 taxonomic: str 

142 topics: list[str] 

143 word: str 

144 

145 

146# Xxyzz's East Asian etymology example data 

147class EtymologyExample(TypedDict, total=False): 

148 english: str # DEPRECATED in favor of "translation" 

149 translation: str 

150 raw_tags: list[str] 

151 ref: str 

152 roman: str 

153 tags: list[str] 

154 text: str 

155 type: str 

156 

157 

158class ReferenceData(TypedDict, total=False): 

159 text: str 

160 refn: str 

161 

162 

163class AttestationData(TypedDict, total=False): 

164 date: str 

165 references: list[ReferenceData] 

166 

167 

168class SenseData(TypedDict, total=False): 

169 alt_of: list[AltOf] 

170 antonyms: list[LinkageData] 

171 categories: list[str] 

172 compound_of: list[AltOf] 

173 coordinate_terms: list[LinkageData] 

174 examples: list[ExampleData] 

175 form_of: list[FormOf] 

176 glosses: list[str] 

177 head_nr: int 

178 holonyms: list[LinkageData] 

179 hypernyms: list[LinkageData] 

180 hyponyms: list[LinkageData] 

181 instances: list[LinkageData] 

182 links: list[LinkData] 

183 meronyms: list[LinkageData] 

184 qualifier: str 

185 raw_glosses: list[str] 

186 related: list[LinkageData] # also used for "alternative forms" 

187 senseid: list[str] 

188 synonyms: list[LinkageData] 

189 tags: list[str] 

190 taxonomic: str 

191 topics: list[str] 

192 wikidata: list[str] 

193 wikipedia: list[str] 

194 attestations: list[AttestationData] 

195 

196 

197class WordData(TypedDict, total=False): 

198 abbreviations: list[LinkageData] 

199 alt_of: list[AltOf] 

200 antonyms: list[LinkageData] 

201 categories: list[str] 

202 coordinate_terms: list[LinkageData] 

203 derived: list[LinkageData] 

204 descendants: list[DescendantData] 

205 etymology_examples: list[EtymologyExample] 

206 etymology_number: int 

207 etymology_templates: list[TemplateData] 

208 etymology_text: str 

209 form_of: list[FormOf] 

210 forms: list[FormData] 

211 head_templates: list[TemplateData] 

212 holonyms: list[LinkageData] 

213 hyphenation: list[str] # Being deprecated 

214 hyphenations: list[Hyphenation] 

215 hypernyms: list[LinkageData] 

216 hyponyms: list[LinkageData] 

217 inflection_templates: list[TemplateData] 

218 info_templates: list[TemplateData] 

219 instances: list[LinkageData] 

220 lang: str 

221 lang_code: str 

222 literal_meaning: str 

223 meronyms: list[LinkageData] 

224 original_title: str 

225 pos: str 

226 proverbs: list[LinkageData] 

227 redirects: list[str] 

228 related: list[LinkageData] 

229 senses: list[SenseData] 

230 sounds: list[SoundData] 

231 synonyms: list[LinkageData] 

232 translations: list[TranslationData] 

233 troponyms: list[LinkageData] 

234 wikidata: list[str] 

235 wikipedia: list[str] 

236 word: str 

237 anagrams: list[LinkageData]