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

123 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2025-12-05 07:46 +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 

115 

116class Hyphenation(VietnameseBaseModel): 

117 parts: list[str] = [] 

118 

119 

120class Descendant(VietnameseBaseModel): 

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

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

123 word: str = "" 

124 roman: str = "" 

125 tags: list[str] = [] 

126 raw_tags: list[str] = [] 

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

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

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

130 ) 

131 sense: str = "" 

132 

133 

134class WordEntry(VietnameseBaseModel): 

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

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

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

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

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

140 pos_title: str = "" 

141 senses: list[Sense] = [] 

142 categories: list[str] = [] 

143 tags: list[str] = [] 

144 raw_tags: list[str] = [] 

145 antonyms: list[Linkage] = [] 

146 synonyms: list[Linkage] = [] 

147 coordinate_terms: list[Linkage] = [] 

148 derived: list[Linkage] = [] 

149 related: list[Linkage] = [] 

150 holonyms: list[Linkage] = [] 

151 hypernyms: list[Linkage] = [] 

152 hyponyms: list[Linkage] = [] 

153 meronyms: list[Linkage] = [] 

154 forms: list[Form] = [] 

155 translations: list[Translation] = [] 

156 sounds: list[Sound] = [] 

157 etymology_texts: list[str] = [] 

158 hyphenations: list[Hyphenation] = [] 

159 notes: list[str] = [] 

160 anagrams: list[Linkage] = [] 

161 coordinate_terms: list[Linkage] = [] 

162 reduplicatives: list[Linkage] = [] 

163 literal_meaning: str = "" 

164 redirects: list[str] = [] 

165 descendants: list[Descendant] = []