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

78 statements  

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

1from pydantic import BaseModel, ConfigDict, Field 

2 

3 

4class CzechBaseModel(BaseModel): 

5 model_config = ConfigDict( 

6 extra="forbid", 

7 strict=True, 

8 validate_assignment=True, 

9 validate_default=True, 

10 ) 

11 

12 

13class Example(CzechBaseModel): 

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 = Field( 

19 default="", 

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

21 ) 

22 

23 

24class AltForm(CzechBaseModel): 

25 word: str 

26 

27 

28class Sense(CzechBaseModel): 

29 glosses: list[str] = [] 

30 tags: list[str] = [] 

31 raw_tags: list[str] = [] 

32 categories: list[str] = [] 

33 topics: list[str] = [] 

34 examples: list[Example] = [] 

35 form_of: list[AltForm] = [] 

36 

37 

38class Sound(CzechBaseModel): 

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

40 tags: list[str] = [] 

41 raw_tags: list[str] = [] 

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

43 wav_url: str = "" 

44 oga_url: str = "" 

45 ogg_url: str = "" 

46 mp3_url: str = "" 

47 opus_url: str = "" 

48 flac_url: str = "" 

49 homophone: str = "" 

50 zh_pron: str = "" 

51 other: str = "" 

52 roman: str = "" 

53 

54 

55class Hyphenation(CzechBaseModel): 

56 parts: list[str] = [] 

57 

58 

59class Form(CzechBaseModel): 

60 form: str 

61 tags: list[str] = [] 

62 raw_tags: list[str] = [] 

63 roman: str = "" 

64 

65 

66class Translation(CzechBaseModel): 

67 lang_code: str = Field( 

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

69 ) 

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

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

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

73 sense_index: int = Field( 

74 default=0, ge=0, description="Number of the definition, start from 1" 

75 ) 

76 tags: list[str] = [] 

77 raw_tags: list[str] = [] 

78 

79 

80class Linkage(CzechBaseModel): 

81 word: str 

82 tags: list[str] = [] 

83 raw_tags: list[str] = [] 

84 sense_index: int = Field( 

85 default=0, ge=0, description="Number of the definition, start from 1" 

86 ) 

87 

88 

89class WordEntry(CzechBaseModel): 

90 model_config = ConfigDict(title="Czech Wiktionary") 

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

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

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

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

95 pos_title: str = "" 

96 senses: list[Sense] = [] 

97 categories: list[str] = [] 

98 tags: list[str] = [] 

99 raw_tags: list[str] = [] 

100 sounds: list[Sound] = [] 

101 hyphenations: list[Hyphenation] = [] 

102 etymology_texts: list[str] = [] 

103 forms: list[Form] = [] 

104 translations: list[Translation] = [] 

105 synonyms: list[Linkage] = [] 

106 antonyms: list[Linkage] = [] 

107 related: list[Linkage] = [] 

108 phrases: list[Linkage] = [] 

109 proverbs: list[Linkage] = [] 

110 derived: list[Linkage] = [] 

111 note: str = "" 

112 abbreviations: list[Linkage] = []