Coverage for src / wiktextract / extractor / vi / models.py: 100%

125 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2025-12-29 01:50 +0000

1from pydantic import BaseModel, ConfigDict, Field 

2 

3 

4class VietnameseBaseModel(BaseModel): 

5 model_config = ConfigDict( 

6 extra="forbid", 

7 strict=True, 

8 validate_assignment=True, 

9 validate_default=True, 

10 ) 

11 

12 

13class Example(VietnameseBaseModel): 

14 text: str 

15 bold_text_offsets: list[tuple[int, int]] = [] 

16 translation: str = "" 

17 bold_translation_offsets: list[tuple[int, int]] = [] 

18 literal_meaning: str = "" 

19 bold_literal_offsets: list[tuple[int, int]] = [] 

20 roman: str = Field( 

21 default="", description="Romanization of the example sentence" 

22 ) 

23 bold_roman_offsets: list[tuple[int, int]] = [] 

24 ref: str = Field( 

25 default="", 

26 description="Source of the sentence, like book title and page number", 

27 ) 

28 ruby: list[tuple[str, ...]] = Field( 

29 default=[], description="Japanese Kanji and furigana" 

30 ) 

31 tags: list[str] = [] 

32 raw_tags: list[str] = [] 

33 categories: list[str] = Field(default=[], exclude=True) 

34 

35 

36class AltForm(VietnameseBaseModel): 

37 word: str 

38 roman: str = "" 

39 

40 

41class Classifier(VietnameseBaseModel): 

42 classifier: str = "" 

43 tags: list[str] = [] 

44 raw_tags: list[str] = [] 

45 

46 

47class Sense(VietnameseBaseModel): 

48 glosses: list[str] = [] 

49 tags: list[str] = [] 

50 raw_tags: list[str] = [] 

51 categories: list[str] = [] 

52 topics: list[str] = [] 

53 examples: list[Example] = [] 

54 form_of: list[AltForm] = [] 

55 alt_of: list[AltForm] = [] 

56 classifiers: list[Classifier] = [] 

57 

58 

59class Linkage(VietnameseBaseModel): 

60 word: str 

61 tags: list[str] = [] 

62 raw_tags: list[str] = [] 

63 roman: str = "" 

64 sense: str = "" 

65 other: str = "" 

66 translation: str = "" 

67 senses: list[str] = [] 

68 ruby: list[tuple[str, ...]] = Field( 

69 default=[], description="Japanese Kanji and furigana" 

70 ) 

71 categories: list[str] = Field(default=[], exclude=True) 

72 

73 

74class Form(VietnameseBaseModel): 

75 form: str 

76 tags: list[str] = [] 

77 raw_tags: list[str] = [] 

78 roman: str = "" 

79 sense: str = "" 

80 ruby: list[tuple[str, ...]] = [] 

81 

82 

83class Translation(VietnameseBaseModel): 

84 lang_code: str = Field( 

85 description="Wiktionary language code of the translation term", 

86 ) 

87 lang: str = Field(description="Translation language name") 

88 word: str = Field(description="Translation term") 

89 sense: str = Field(default="", description="Translation gloss") 

90 tags: list[str] = [] 

91 raw_tags: list[str] = [] 

92 roman: str = "" 

93 lit: str = Field(default="", description="Literal translation") 

94 source: str = "" 

95 other: str = "" 

96 

97 

98class Sound(VietnameseBaseModel): 

99 ipa: str = Field(default="", description="International Phonetic Alphabet") 

100 tags: list[str] = [] 

101 raw_tags: list[str] = [] 

102 audio: str = Field(default="", description="Audio file name") 

103 wav_url: str = "" 

104 oga_url: str = "" 

105 ogg_url: str = "" 

106 mp3_url: str = "" 

107 opus_url: str = "" 

108 flac_url: str = "" 

109 rhymes: str = "" 

110 homophone: str = "" 

111 zh_pron: str = "" 

112 roman: str = "" 

113 other: str = "" 

114 hangeul: str = "" 

115 

116 

117class Hyphenation(VietnameseBaseModel): 

118 parts: list[str] = [] 

119 

120 

121class Descendant(VietnameseBaseModel): 

122 lang_code: str = Field(default="", description="Wiktionary language code") 

123 lang: str = Field(default="", description="Language name") 

124 word: str = "" 

125 roman: str = "" 

126 tags: list[str] = [] 

127 raw_tags: list[str] = [] 

128 descendants: list["Descendant"] = [] 

129 ruby: list[tuple[str, ...]] = Field( 

130 default=[], description="Japanese Kanji and furigana" 

131 ) 

132 sense: str = "" 

133 

134 

135class WordEntry(VietnameseBaseModel): 

136 model_config = ConfigDict(title="Vietnamese Wiktionary") 

137 word: str = Field(description="Word string") 

138 lang_code: str = Field(description="Wiktionary language code") 

139 lang: str = Field(description="Localized language name") 

140 pos: str = Field(description="Part of speech type") 

141 pos_title: str = "" 

142 senses: list[Sense] = [] 

143 categories: list[str] = [] 

144 tags: list[str] = [] 

145 raw_tags: list[str] = [] 

146 antonyms: list[Linkage] = [] 

147 synonyms: list[Linkage] = [] 

148 coordinate_terms: list[Linkage] = [] 

149 derived: list[Linkage] = [] 

150 related: list[Linkage] = [] 

151 holonyms: list[Linkage] = [] 

152 hypernyms: list[Linkage] = [] 

153 hyponyms: list[Linkage] = [] 

154 meronyms: list[Linkage] = [] 

155 forms: list[Form] = [] 

156 translations: list[Translation] = [] 

157 sounds: list[Sound] = [] 

158 etymology_texts: list[str] = [] 

159 hyphenations: list[Hyphenation] = [] 

160 notes: list[str] = [] 

161 anagrams: list[Linkage] = [] 

162 coordinate_terms: list[Linkage] = [] 

163 reduplicatives: list[Linkage] = [] 

164 literal_meaning: str = "" 

165 redirects: list[str] = [] 

166 descendants: list[Descendant] = [] 

167 classifiers: list[Classifier] = []