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

172 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-12 08:27 +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 roman: str 

22 ruby: Union[list[Sequence[str]], list[tuple[str, str]]] 

23 sense: str 

24 source: str 

25 tags: list[str] 

26 taxonomic: str 

27 topics: list[str] 

28 urls: list[str] 

29 word: str 

30 

31 

32class ExampleData(TypedDict, total=False): 

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

34 translation: str 

35 bold_translation_offsets: list[tuple[int, int]] 

36 note: str 

37 ref: str 

38 roman: str 

39 bold_roman_offsets: list[tuple[int, int]] 

40 ruby: Union[list[tuple[str, str]], list[Sequence[str]]] 

41 text: str 

42 bold_text_offsets: list[tuple[int, int]] 

43 type: str 

44 literal_meaning: str 

45 bold_literal_offsets: list[tuple[int, int]] 

46 tags: list[str] 

47 raw_tags: list[str] 

48 

49 

50class FormOf(TypedDict, total=False): 

51 word: str 

52 extra: str 

53 roman: str 

54 

55 

56LinkData = list[Sequence[str]] 

57 

58 

59class PlusObjTemplateData(TypedDict, total=False): 

60 tags: list[str] 

61 words: list[str] 

62 meaning: str 

63 

64 

65ExtraTemplateData = Union[PlusObjTemplateData] 

66 

67 

68class TemplateData(TypedDict, total=False): 

69 args: TemplateArgs 

70 expansion: str 

71 name: str 

72 extra_data: ExtraTemplateData 

73 

74 

75class DescendantData(TypedDict, total=False): 

76 lang_code: str 

77 lang: str 

78 word: str 

79 roman: str 

80 tags: list[str] 

81 raw_tags: list[str] 

82 descendants: list["DescendantData"] 

83 ruby: list[tuple[str, ...]] 

84 sense: str 

85 

86 

87class FormData(TypedDict, total=False): 

88 form: str 

89 head_nr: int 

90 ipa: str 

91 roman: str 

92 ruby: Union[list[tuple[str, str]], list[Sequence[str]]] 

93 source: str 

94 tags: list[str] 

95 raw_tags: list[str] 

96 topics: list[str] 

97 

98 

99class Hyphenation(TypedDict, total=False): 

100 parts: list[str] 

101 tags: list[str] 

102 

103 

104SoundData = TypedDict( 

105 "SoundData", 

106 { 

107 "audio": str, 

108 "audio-ipa": str, 

109 "enpr": str, 

110 "form": str, 

111 "hangeul": str, 

112 "homophone": str, 

113 "ipa": str, 

114 "mp3_url": str, 

115 "note": str, 

116 "ogg_url": str, 

117 "other": str, 

118 "rhymes": str, 

119 "tags": list[str], 

120 "text": str, 

121 "topics": list[str], 

122 "zh-pron": str, 

123 }, 

124 total=False, 

125) 

126 

127 

128class TranslationData(TypedDict, total=False): 

129 alt: str 

130 lang_code: str 

131 code: str # DEPRECATED in favor of lang_code 

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

133 translation: str 

134 lang: str 

135 note: str 

136 roman: str 

137 sense: str 

138 tags: list[str] 

139 taxonomic: str 

140 topics: list[str] 

141 word: str 

142 

143 

144# Xxyzz's East Asian etymology example data 

145class EtymologyExample(TypedDict, total=False): 

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

147 translation: str 

148 raw_tags: list[str] 

149 ref: str 

150 roman: str 

151 tags: list[str] 

152 text: str 

153 type: str 

154 

155 

156class ReferenceData(TypedDict, total=False): 

157 text: str 

158 refn: str 

159 

160 

161class AttestationData(TypedDict, total=False): 

162 date: str 

163 references: list[ReferenceData] 

164 

165 

166class SenseData(TypedDict, total=False): 

167 alt_of: list[AltOf] 

168 antonyms: list[LinkageData] 

169 categories: list[str] 

170 compound_of: list[AltOf] 

171 coordinate_terms: list[LinkageData] 

172 examples: list[ExampleData] 

173 form_of: list[FormOf] 

174 glosses: list[str] 

175 head_nr: int 

176 holonyms: list[LinkageData] 

177 hypernyms: list[LinkageData] 

178 hyponyms: list[LinkageData] 

179 instances: list[LinkageData] 

180 links: list[LinkData] 

181 meronyms: list[LinkageData] 

182 qualifier: str 

183 raw_glosses: list[str] 

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

185 senseid: list[str] 

186 synonyms: list[LinkageData] 

187 tags: list[str] 

188 taxonomic: str 

189 topics: list[str] 

190 wikidata: list[str] 

191 wikipedia: list[str] 

192 attestations: list[AttestationData] 

193 

194 

195class WordData(TypedDict, total=False): 

196 abbreviations: list[LinkageData] 

197 alt_of: list[AltOf] 

198 antonyms: list[LinkageData] 

199 categories: list[str] 

200 coordinate_terms: list[LinkageData] 

201 derived: list[LinkageData] 

202 descendants: list[DescendantData] 

203 etymology_examples: list[EtymologyExample] 

204 etymology_number: int 

205 etymology_templates: list[TemplateData] 

206 etymology_text: str 

207 form_of: list[FormOf] 

208 forms: list[FormData] 

209 head_templates: list[TemplateData] 

210 holonyms: list[LinkageData] 

211 hyphenation: list[str] # Being deprecated 

212 hyphenations: list[Hyphenation] 

213 hypernyms: list[LinkageData] 

214 hyponyms: list[LinkageData] 

215 inflection_templates: list[TemplateData] 

216 info_templates: list[TemplateData] 

217 instances: list[LinkageData] 

218 lang: str 

219 lang_code: str 

220 literal_meaning: str 

221 meronyms: list[LinkageData] 

222 original_title: str 

223 pos: str 

224 proverbs: list[LinkageData] 

225 redirects: list[str] 

226 related: list[LinkageData] 

227 senses: list[SenseData] 

228 sounds: list[SoundData] 

229 synonyms: list[LinkageData] 

230 translations: list[TranslationData] 

231 troponyms: list[LinkageData] 

232 wikidata: list[str] 

233 wikipedia: list[str] 

234 word: str 

235 anagrams: list[LinkageData]