diff --git a/problems.py b/problems.py new file mode 100644 index 0000000..69f18f8 --- /dev/null +++ b/problems.py @@ -0,0 +1,135 @@ +from dataclasses import dataclass +from typing import Optional + +@dataclass +class KanjiKanaBlank: + "A type of question involving kana or kanji that need to be re-written into the other form." + kanji: str + kana: str + prompt: str # The prompt will be in the form of a Python format string, e.g. "それは{}であった", with the word to be shown in the blank + +class QuestionOnePart(KanjiKanaBlank): + pass + +class QuestionTwoPart(KanjiKanaBlank): + pass + +... + +class QuestionOne: + pass + +class QuestionTwo: + pass + +class QuestionThree: + pass + +class QuestionFour: + pass + +class QuestionFourPartOne: + pass + +class QuestionFourPartTwo: + pass + +class QuestionFive: + pass + +class QuestionSix: + pass + +class QuestionSeven: + pass + +class QuestionEight: + pass + +class QuestionNine: + pass + +def get_aozora_sentence(word: str, max_length: int = 16) -> Optional[str]: + "Receiving a `word`, retrieves a sentence from the Aozora Bunko corpus of a suitable `max_length`." + +def get_random_kun_word() -> str: + pass + +def get_random_on_word() -> str: + pass + +def get_random_kokuji_word() -> str: + pass + +# Section 1 (reading): generate using Aozora Bunko +def generate_section_1() -> QuestionOne: + """Generate 30 sentences, sampled from Aozora Bunko, no longer than 16 characters each, + with the first 20 expecting you to write the reading of an on'yomi derived word, + and the last 10 of a kun'yomi one. + """ + +# Section 2 (writing): likewise, generate uing aozora bunko +def generate_section_2(fourteen_general_readings: list[KanjiKanaBlank], on_homophone_pair: tuple[KanjiKanaBlank, KanjiKanaBlank], kun_homophone_pair: tuple[KanjiKanaBlank, KanjiKanaBlank], kokuji_pair: tuple[KanjiKanaBlank, KanjiKanaBlank]) -> QuestionTwo: + """Generate 14 sentences with readings of any kind, on or kun, as `KanjiKanaBlank`s. + Then, generate two pairs sentences. One of the pairs should be a kun reading of two different words, + and the other pair should be an on reading of two different words. + Finally, the last two should be based on any two kokuji's readings. + """ + +# Section 3 (word selection): using definitions and picking out readings into the reading box +def generate_section_3() -> QuestionThree: + """Generate 5 words of any kind, placing their corresponding readings in the "reading box". + Then, add a handful (e.g. 3) of misleading readings, which do not correspond to the readings of the words selected. + The question's objective is to have the taker match the selected words to their given readings, + ignoring the fake readings. + """ + +# Section 4 (yojijukugo): for part 1, generate yojijukugo with their first two or bottom two kanji missing. +# For part 2, generate 5 definitions and 8 yojijukugo in the box, whose parts should be highlighted accordingly +def generate_section_4() -> QuestionFour: + """Yojijuko question. + Part I + For the first 10 questions, yojijukugo are given. For the first 5, the top 2 characters of the compound are missing, + so they must be written out. The the last 5, the bottom 2 are missing. The taker is aided by the readings of the missing + 10 blanks, which are all placed in a reading box. There are no misleading readings like Q3. + Part II + 5 yojijukugo definitions are given, along with 8 yojijukugo in a box, each with eithe the top 2 or bottom 2 characters underlined. + There are two objectives: matching the definitions to the yojijukugo, as well as providing the reading for each underlined portion along with it. + """ + +# Section 5 (jukujikun): pick 10 words with a jukujikun reading +def generate_section_5() -> QuestionFive: + """10 words that use jukujikun or ateji are listed. They simply need their readings to be written down. + This function merely needs to get 10 arbitrary jukujikun/ateji words.""" + +# Section 6 (kun and on): pick 10 kanji, each with one word in which it is read as kun and one where it is read as on +def generate_section_6() -> QuestionSix: + """ + Pick five different characters that have both a kun reading with okurigana, and an on compound. + Each question consists of a pair of these two readings of the character. + """ + +# Section 7 (synonyms and antonyms): pick two sets of 5 kanji compounds. For words 1-5, generate their antonyms in the box, +# displayed as hiragana. For words 6-10, generate their synonyms in the same way. +def generate_section_7() -> QuestionSeven: + """Generate 5 pairs of antonyms and 5 pairs of synonyms. + For each pair, one of the items should be put in the "question" section, lemmatised, + whereas the other item should be put in the "reading" box as hiragana. + The objective for the first 5 questions is to match the given question term to its antonym + in the reading box, writing out that antonym using kanji; + and the objective for the second 5 is to do the same, but giving the synonyms of the given terms. + """ + +# Section 8 (proverbs, idioms and set expressions): generate 10 sample proverbs with the kanji to be written +def generate_section_8() -> QuestionEight: + """Simply generate 10 idioms (koji, kotowaza, seiku) with one term given as a blank (`KanjiKanaBlank`).""" + +# Section 9 (text comprehension): generate a text or two, with 10 words with straight line markings shown, +# whose katakana should be re-written as kanji; +# and 10 words with wavy markings, in kanji, to be written as hiragana. +def generate_section_9() -> QuestionNine: + """Derive an entire long-form passage from Aozora Bunko with a high diversity of kanji usage. + May generate more than one text, in which case each is letted (A, B, C, ...), but usually not that + many texts. + Some kanji words should be spelled out in hiragana, and some kana words should be spelled out in kanji. + """