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

107 statements  

« prev     ^ index     » next       coverage.py v7.9.0, created at 2025-06-13 07:43 +0000

1from pydantic import BaseModel, ConfigDict, Field 

2 

3 

4class JapaneseBaseModel(BaseModel): 

5 model_config = ConfigDict( 

6 extra="forbid", 

7 strict=True, 

8 validate_assignment=True, 

9 validate_default=True, 

10 ) 

11 

12 

13class Example(JapaneseBaseModel): 

14 text: str = "" 

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

16 translation: str = "" 

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

18 ref: str = "" 

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

20 roman: str = "" 

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

22 

23 

24class AltForm(JapaneseBaseModel): 

25 word: str 

26 

27 

28class Sense(JapaneseBaseModel): 

29 glosses: list[str] = [] 

30 tags: list[str] = [] 

31 raw_tags: list[str] = [] 

32 topics: list[str] = [] 

33 categories: list[str] = [] 

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

35 examples: list[Example] = [] 

36 form_of: list[AltForm] = [] 

37 notes: list[str] = [] 

38 

39 

40class Form(JapaneseBaseModel): 

41 form: str = "" 

42 tags: list[str] = [] 

43 raw_tags: list[str] = [] 

44 roman: str = "" 

45 literal_meaning: str = "" 

46 

47 

48class Sound(JapaneseBaseModel): 

49 zh_pron: str = Field(default="", description="Chinese word pronunciation") 

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

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

52 wav_url: str = "" 

53 oga_url: str = "" 

54 ogg_url: str = "" 

55 mp3_url: str = "" 

56 opus_url: str = "" 

57 flac_url: str = "" 

58 tags: list[str] = [] 

59 raw_tags: list[str] = [] 

60 homophones: list[str] = [] 

61 form: str = "" 

62 roman: str = "" 

63 sense: str = "" 

64 

65 

66class Translation(JapaneseBaseModel): 

67 lang_code: str = Field( 

68 default="", 

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

70 ) 

71 lang: str = Field(default="", description="Translation language name") 

72 word: str = Field(default="", description="Translation term") 

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

74 tags: list[str] = [] 

75 raw_tags: list[str] = [] 

76 roman: str = "" 

77 

78 

79class Linkage(JapaneseBaseModel): 

80 word: str 

81 tags: list[str] = [] 

82 raw_tags: list[str] = [] 

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

84 sense: str = "" 

85 roman: str = "" 

86 literal_meaning: str = "" 

87 

88 

89class Descendant(JapaneseBaseModel): 

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

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

92 word: str = "" 

93 roman: str = "" 

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

95 sense: str = "" 

96 tags: list[str] = [] 

97 raw_tags: list[str] = [] 

98 

99 

100class WordEntry(JapaneseBaseModel): 

101 model_config = ConfigDict(title="Japanese Wiktionary") 

102 

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

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

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

106 pos: str = Field(default="", description="Part of speech type") 

107 pos_title: str = "" 

108 senses: list[Sense] = [] 

109 title: str = Field(default="", description="Redirect page source title") 

110 redirect: str = Field(default="", description="Redirect page target title") 

111 categories: list[str] = [] 

112 tags: list[str] = [] 

113 raw_tags: list[str] = [] 

114 forms: list[Form] = [] 

115 etymology_texts: list[str] = [] 

116 sounds: list[Sound] = [] 

117 translations: list[Translation] = [] 

118 antonyms: list[Linkage] = [] 

119 synonyms: list[Linkage] = [] 

120 hyponyms: list[Linkage] = [] 

121 hypernyms: list[Linkage] = [] 

122 holonyms: list[Linkage] = [] 

123 meronyms: list[Linkage] = [] 

124 derived: list[Linkage] = [] 

125 contraction: list[Linkage] = [] 

126 abbreviations: list[Linkage] = [] 

127 related: list[Linkage] = [] 

128 collocations: list[Linkage] = [] 

129 proverbs: list[Linkage] = [] 

130 phrases: list[Linkage] = [] 

131 coordinate_terms: list[Linkage] = [] 

132 cognates: list[Descendant] = [] 

133 descendants: list[Descendant] = [] 

134 anagrams: list[Linkage] = [] 

135 notes: list[str] = [] 

136 proverbs: list[Descendant] = []