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

94 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-25 10:11 +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 translation: str = "" 

16 ref: str = "" 

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

18 

19 

20class AltForm(JapaneseBaseModel): 

21 word: str 

22 

23 

24class Sense(JapaneseBaseModel): 

25 glosses: list[str] = [] 

26 tags: list[str] = [] 

27 raw_tags: list[str] = [] 

28 topics: list[str] = [] 

29 categories: list[str] = [] 

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

31 examples: list[Example] = [] 

32 form_of: list[AltForm] = [] 

33 

34 

35class Form(JapaneseBaseModel): 

36 form: str = "" 

37 tags: list[str] = [] 

38 raw_tags: list[str] = [] 

39 

40 

41class Sound(JapaneseBaseModel): 

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

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

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

45 wav_url: str = "" 

46 oga_url: str = "" 

47 ogg_url: str = "" 

48 mp3_url: str = "" 

49 opus_url: str = "" 

50 flac_url: str = "" 

51 tags: list[str] = [] 

52 raw_tags: list[str] = [] 

53 homophones: list[str] = [] 

54 form: str = "" 

55 roman: str = "" 

56 

57 

58class Translation(JapaneseBaseModel): 

59 lang_code: str = Field( 

60 default="", 

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

62 ) 

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

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

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

66 tags: list[str] = [] 

67 raw_tags: list[str] = [] 

68 roman: str = "" 

69 

70 

71class Linkage(JapaneseBaseModel): 

72 word: str 

73 tags: list[str] = [] 

74 raw_tags: list[str] = [] 

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

76 sense: str = "" 

77 

78 

79class Descendant(JapaneseBaseModel): 

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

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

82 word: str = "" 

83 roman: str = "" 

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

85 sense: str = "" 

86 tags: list[str] = [] 

87 raw_tags: list[str] = [] 

88 

89 

90class WordEntry(JapaneseBaseModel): 

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

92 

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

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

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

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

97 pos_title: str = "" 

98 senses: list[Sense] = [] 

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

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

101 categories: list[str] = [] 

102 tags: list[str] = [] 

103 raw_tags: list[str] = [] 

104 forms: list[Form] = [] 

105 etymology_texts: list[str] = [] 

106 sounds: list[Sound] = [] 

107 translations: list[Translation] = [] 

108 antonyms: list[Linkage] = [] 

109 synonyms: list[Linkage] = [] 

110 hyponyms: list[Linkage] = [] 

111 hypernyms: list[Linkage] = [] 

112 holonyms: list[Linkage] = [] 

113 meronyms: list[Linkage] = [] 

114 derived: list[Linkage] = [] 

115 contraction: list[Linkage] = [] 

116 abbreviations: list[Linkage] = [] 

117 related: list[Linkage] = [] 

118 collocations: list[Linkage] = [] 

119 proverbs: list[Linkage] = [] 

120 phrases: list[Linkage] = [] 

121 coordinate_terms: list[Linkage] = [] 

122 cognates: list[Descendant] = [] 

123 descendants: list[Descendant] = []