File size: 4,177 Bytes
db080f6
 
 
 
 
 
 
 
 
 
 
 
 
 
b719566
db080f6
b719566
 
 
db080f6
 
 
 
 
 
 
 
 
 
 
 
b719566
db080f6
 
 
 
 
 
 
 
 
 
 
 
b719566
db080f6
 
 
 
 
 
 
 
 
 
 
 
 
b719566
db080f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from typing_extensions import Self
from typing import Any, Literal, Optional
from pydantic import BaseModel, Field, model_validator, ValidationError
from .language import (
    LANGUAGE_CODES,
    T_LANGUAGE_CODES,
    LANGUAGES,
    T_LANGUAGES,
    CODE_TO_LANGUAGE,
    LANGUAGE_TO_CODE,
)

class _Record(BaseModel):
    "Base Data Model For Language Learner"
    lang: T_LANGUAGES | str = Field(..., description="The language name.")
    data: str = Field(..., description="The data for the record, like `apple` is vocabulary, `How are you.` is a phrase. `I like your product! How much is this` is a sentence.")
    level: None = Field(None, description="The field needs to be defined in the sub data model.")
    # _meta: dict = Field(..., description="The field to be implement or overwrite, please do not fill this yet.")
    IPA: Optional[str] = Field(..., description="International Phonetic Alphabet")

class Vocabulary(_Record):
    """
    This is for word level record.
    Please fill the `data` field with vocabulary level input respect to the language.
    e.g. 
        Chinese: "貓", "車", "醫生", "學校", "咖啡", "書"
        English: "Cat", "Car", "Doctor", "School", "Coffee", "Book"
        Japanese: "猫(ねこ)", "車(くるま)", "医者(いしゃ)", "学校(がっこう)", "コーヒー", "本(ほん)"
        Korean: "고양이", "차", "의사", "학교", "커피", "책"
        Italian: "Gatto", "Auto", "Dottore", "Scuola", "Caffè", "Libro"
    """
    level: Literal['WORD']

class Phrase(_Record):
    """
    This is for phrase level record.
    Please fill the `data` field with phrase level input respect to the language.
    e.g. 
        Chinese: "你好", "謝謝你", "我愛你", "怎麼了?", "好久不見", "多少錢?"
        English: "Hello", "Thank you", "I love you", "What's wrong?", "Long time no see", "How much is it?"
        Japanese: "こんにちは", "ありがとう", "愛してる", "どうしたの?", "久しぶり(ひさしぶり)", "いくらですか?"
        Korean: "안녕하세요", "감사합니다", "사랑해요", "왜 그래요?", "오랜만이에요", "얼마예요?"
        Italian: "Ciao", "Grazie", "Ti amo", "Che succede?", "È da tanto tempo!", "Quanto costa?"
    """
    level: Literal['PHRASE']


class Sentence(_Record):
    """
    This is for sentence level record.
    Please fill the `data` field with sentence level input respect to the language.
    e.g. 
        Chinese: "這是一隻可愛的貓。", "我想喝一杯咖啡。", "你住在哪裡?", "今天的天氣很好。", "你能幫助我嗎?", "我正在學習日語和韓語。"
        English: "This is a cute cat.", "I want to drink a cup of coffee.", "Where do you live?", "The weather is nice today.", "Can you help me?", "I am learning Japanese and Korean."
        Japanese: "これはかわいい猫です。", "コーヒーを一杯飲みたいです。", "どこに住んでいますか?", "今日は天気がいいです。", "手伝ってくれますか?", "日本語と韓国語を勉強しています。"
        Korean: "이건 귀여운 고양이예요.", "커피 한 잔 마시고 싶어요.", "어디에 살아요?", "오늘 날씨가 좋아요.", "저를 도와줄 수 있어요?", "일본어와 한국어를 공부하고 있어요."
        Italian: "Questo è un gatto carino.", "Voglio bere una tazza di caffè.", "Dove vivi?", "Oggi il tempo è bello.", "Puoi aiutarmi?", "Sto imparando il giapponese e il coreano."
    """
    level: Literal['SENTENCE']


class ReadableReference(BaseModel):
    """
    This is a reference for the foregin language.
    Try to let the user to understand the foregin language more easily.
    Please use the user native language to do this.
    """
    name: str
    short_explain: str
    description: str = Field(
        ...,
        description="Try to describe the foreign language more comprehensively."
    )

class __R(BaseModel):
    reference: ReadableReference

class R_Vocabulary(__R):
    foreign: Vocabulary
    
class R_Phrase(__R):
    foreign: Phrase

class R_Sentence(__R):
    foreign: Sentence