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

150 statements  

« prev     ^ index     » next       coverage.py v7.9.0, created at 2025-06-13 07:43 +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 

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 

29 

30 

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] 

46 

47 

48class FormOf(TypedDict, total=False): 

49 word: str 

50 extra: str 

51 roman: str 

52 

53 

54LinkData = list[Sequence[str]] 

55 

56 

57class PlusObjTemplateData(TypedDict, total=False): 

58 tags: list[str] 

59 words: list[str] 

60 meaning: str 

61 

62 

63ExtraTemplateData = Union[PlusObjTemplateData] 

64 

65 

66class TemplateData(TypedDict, total=False): 

67 args: TemplateArgs 

68 expansion: str 

69 name: str 

70 extra_data: ExtraTemplateData 

71 

72 

73class DescendantData(TypedDict, total=False): 

74 depth: int 

75 tags: list[str] 

76 templates: list[TemplateData] 

77 text: str 

78 

79 

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] 

90 

91 

92SoundData = TypedDict( 

93 "SoundData", 

94 { 

95 "audio": str, 

96 "audio-ipa": str, 

97 "enpr": str, 

98 "form": str, 

99 "hangeul": str, 

100 "homophone": str, 

101 "ipa": str, 

102 "mp3_url": str, 

103 "note": str, 

104 "ogg_url": str, 

105 "other": str, 

106 "rhymes": str, 

107 "tags": list[str], 

108 "text": str, 

109 "topics": list[str], 

110 "zh-pron": str, 

111 }, 

112 total=False, 

113) 

114 

115 

116class TranslationData(TypedDict, total=False): 

117 alt: str 

118 code: str 

119 english: str 

120 lang: str 

121 note: str 

122 roman: str 

123 sense: str 

124 tags: list[str] 

125 taxonomic: str 

126 topics: list[str] 

127 word: str 

128 

129 

130# Xxyzz's East Asian etymology example data 

131class EtymologyExample(TypedDict, total=False): 

132 english: str 

133 raw_tags: list[str] 

134 ref: str 

135 roman: str 

136 tags: list[str] 

137 text: str 

138 type: str 

139 

140 

141class SenseData(TypedDict, total=False): 

142 alt_of: list[AltOf] 

143 antonyms: list[LinkageData] 

144 categories: list[str] 

145 compound_of: list[AltOf] 

146 coordinate_terms: list[LinkageData] 

147 examples: list[ExampleData] 

148 form_of: list[FormOf] 

149 glosses: list[str] 

150 head_nr: int 

151 holonyms: list[LinkageData] 

152 hypernyms: list[LinkageData] 

153 hyponyms: list[LinkageData] 

154 instances: list[LinkageData] 

155 links: list[LinkData] 

156 meronyms: list[LinkageData] 

157 qualifier: str 

158 raw_glosses: list[str] 

159 related: list[LinkageData] 

160 senseid: list[str] 

161 synonyms: list[LinkageData] 

162 tags: list[str] 

163 taxonomic: str 

164 topics: list[str] 

165 wikidata: list[str] 

166 wikipedia: list[str] 

167 

168 

169class WordData(TypedDict, total=False): 

170 abbreviations: list[LinkageData] 

171 alt_of: list[AltOf] 

172 antonyms: list[LinkageData] 

173 categories: list[str] 

174 coordinate_terms: list[LinkageData] 

175 derived: list[LinkageData] 

176 descendants: list[DescendantData] 

177 etymology_examples: list[EtymologyExample] 

178 etymology_number: int 

179 etymology_templates: list[TemplateData] 

180 etymology_text: str 

181 form_of: list[FormOf] 

182 forms: list[FormData] 

183 head_templates: list[TemplateData] 

184 holonyms: list[LinkageData] 

185 hyphenation: list[str] 

186 hypernyms: list[LinkageData] 

187 hyponyms: list[LinkageData] 

188 inflection_templates: list[TemplateData] 

189 info_templates: list[TemplateData] 

190 instances: list[LinkageData] 

191 lang: str 

192 lang_code: str 

193 literal_meaning: str 

194 meronyms: list[LinkageData] 

195 original_title: str 

196 pos: str 

197 proverbs: list[LinkageData] 

198 redirects: list[str] 

199 related: list[LinkageData] 

200 senses: list[SenseData] 

201 sounds: list[SoundData] 

202 synonyms: list[LinkageData] 

203 translations: list[TranslationData] 

204 troponyms: list[LinkageData] 

205 wikidata: list[str] 

206 wikipedia: list[str] 

207 word: str