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

69 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 KoreanBaseModel(BaseModel): 

5 model_config = ConfigDict( 

6 extra="forbid", 

7 strict=True, 

8 validate_assignment=True, 

9 validate_default=True, 

10 ) 

11 

12 

13class Example(KoreanBaseModel): 

14 text: str = "" 

15 translation: str = "" 

16 ref: str = "" 

17 roman: str = "" 

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

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

20 ) 

21 tags: list[str] = [] 

22 literal_meaning: str = "" 

23 note: str = "" 

24 

25 

26class AltForm(KoreanBaseModel): 

27 word: str 

28 

29 

30class Sense(KoreanBaseModel): 

31 glosses: list[str] = [] 

32 tags: list[str] = [] 

33 raw_tags: list[str] = [] 

34 topics: list[str] = [] 

35 categories: list[str] = [] 

36 examples: list[Example] = [] 

37 note: str = "" 

38 form_of: list[AltForm] = [] 

39 

40 

41class Sound(KoreanBaseModel): 

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

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

44 wav_url: str = "" 

45 oga_url: str = "" 

46 ogg_url: str = "" 

47 mp3_url: str = "" 

48 opus_url: str = "" 

49 flac_url: str = "" 

50 tags: list[str] = [] 

51 raw_tags: list[str] = [] 

52 hangul: str = "" 

53 roman: str = "" 

54 other: str = "" 

55 

56 

57class Linkage(KoreanBaseModel): 

58 word: str 

59 sense: str = "" 

60 roman: str = "" 

61 raw_tags: list[str] = [] 

62 tags: list[str] = [] 

63 

64 

65class Translation(KoreanBaseModel): 

66 lang_code: str = Field( 

67 description="Wiktionary language code of the translation term" 

68 ) 

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

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

71 roman: str = "" 

72 raw_tags: list[str] = [] 

73 sense: str = "" 

74 

75 

76class WordEntry(KoreanBaseModel): 

77 model_config = ConfigDict(title="Korean Wiktionary") 

78 word: str = Field(description="Word string", min_length=1) 

79 lang_code: str = Field(description="Wiktionary language code", min_length=1) 

80 lang: str = Field(description="Localized language name", min_length=1) 

81 pos: str = Field(description="Part of speech type", min_length=1) 

82 pos_title: str = "" 

83 senses: list[Sense] = [] 

84 categories: list[str] = [] 

85 tags: list[str] = [] 

86 raw_tags: list[str] = [] 

87 sounds: list[Sound] = [] 

88 proverbs: list[Linkage] = [] 

89 derived: list[Linkage] = [] 

90 related: list[Linkage] = [] 

91 synonyms: list[Linkage] = [] 

92 antonyms: list[Linkage] = [] 

93 translations: list[Translation] = [] 

94 etymology_texts: list[str] = []