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

96 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-12 08:27 +0000

1from pydantic import BaseModel, ConfigDict, Field 

2 

3 

4class MalayBaseModel(BaseModel): 

5 model_config = ConfigDict( 

6 extra="forbid", 

7 strict=True, 

8 validate_assignment=True, 

9 validate_default=True, 

10 ) 

11 

12 

13class Example(MalayBaseModel): 

14 text: str 

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

16 translation: str = "" 

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

18 roman: str = "" 

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

20 ref: str = "" 

21 tags: list[str] = [] 

22 raw_tags: list[str] = [] 

23 literal_meaning: str = "" 

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

25 

26 

27class AltForm(MalayBaseModel): 

28 word: str 

29 

30 

31class Attestation(MalayBaseModel): 

32 date: str 

33 

34 

35class Sense(MalayBaseModel): 

36 glosses: list[str] = [] 

37 tags: list[str] = [] 

38 raw_tags: list[str] = [] 

39 topics: list[str] = [] 

40 categories: list[str] = [] 

41 examples: list[Example] = [] 

42 form_of: list[AltForm] = [] 

43 alt_of: list[AltForm] = [] 

44 attestations: list[Attestation] = [] 

45 

46 

47class Form(MalayBaseModel): 

48 form: str 

49 tags: list[str] = [] 

50 raw_tags: list[str] = [] 

51 

52 

53class Linkage(MalayBaseModel): 

54 word: str 

55 tags: list[str] = [] 

56 raw_tags: list[str] = [] 

57 sense: str = "" 

58 

59 

60class Translation(MalayBaseModel): 

61 lang_code: str = Field( 

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

63 ) 

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

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

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

67 tags: list[str] = [] 

68 raw_tags: list[str] = [] 

69 roman: str = "" 

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

71 source: str = "" 

72 

73 

74class Hyphenation(MalayBaseModel): 

75 parts: list[str] = [] 

76 tags: list[str] = [] 

77 raw_tags: list[str] = [] 

78 

79 

80class Sound(MalayBaseModel): 

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

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

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

84 wav_url: str = "" 

85 oga_url: str = "" 

86 ogg_url: str = "" 

87 mp3_url: str = "" 

88 opus_url: str = "" 

89 flac_url: str = "" 

90 tags: list[str] = [] 

91 raw_tags: list[str] = [] 

92 homophone: str = "" 

93 other: str = "" 

94 roman: str = "" 

95 rhymes: str = "" 

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

97 hyphenations: list[Hyphenation] = Field(default=[], exclude=True) 

98 

99 

100class WordEntry(MalayBaseModel): 

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

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

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

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

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

106 pos_title: str = "" 

107 senses: list[Sense] = [] 

108 categories: list[str] = [] 

109 tags: list[str] = [] 

110 raw_tags: list[str] = [] 

111 forms: list[Form] = [] 

112 etymology_text: str = "" 

113 antonyms: list[Linkage] = [] 

114 synonyms: list[Linkage] = [] 

115 translations: list[Translation] = [] 

116 hypernyms: list[Linkage] = [] 

117 coordinate_terms: list[Linkage] = [] 

118 hyponyms: list[Linkage] = [] 

119 hyphenations: list[Hyphenation] = [] 

120 sounds: list[Sound] = [] 

121 derived: list[Linkage] = [] 

122 anagrams: list[Linkage] = [] 

123 proverbs: list[Linkage] = [] 

124 related: list[Linkage] = [] 

125 notes: list[str] = []