with open('~taradoudesuka.md', 'w', encoding="utf-8") as f:

    f.write(printTitle('Usage Form'))
    cardText = 'V past form + らどうですか'

    f.write(generateCard(cardText, []))

    f.write(printTitle('Explanation'))
    f.write(
        "This form conveys advice or recommendation but it may also have a criticizing tone for not performing the activity that should have done already."
    )
    f.write(printTitle('Examples'))

    f.write('<b>Example A</b>')
    f.write('<br>')
    furigana = getHtmlString("勉強する")
    furigana1 = getHtmlString("勉強した")
    furigana3 = getHtmlString("勉強したらどうですか")
    f.write(
        f'{furigana} --> [convert to past tense] --> {furigana1} --> [combine with らどうですか] --> {furigana3} '
    )
    l1 = TextPair('もっと勉強したらどうですか。',
                  "Why don't you study harder?", [
                      HighlightText('勉強した', Color.LIGHT_GREEN),
                      HighlightText('らどうですか', Color.LIGHT_PINK)
                  ],
                  addBullet=True)
    f.write(generate([l1]))
    writeNewLine(f)

    f.write('<b>Example B</b>')
Beispiel #2
0
from python_utils.generator import printTitle, generateCard, writeNewLine, generate
from python_utils.html_generator import getHtmlString
from python_utils.model import TextPair, HighlightText, Color
from python_utils.vocab_list import generateVocabLines

with open('volitional_form_+_toomotteimasu.md', 'w', encoding="utf-8") as f:
    toomotteimasu = getHtmlString("と 思っています")

    f.write(printTitle('Usage Form'))
    f.write(
        generateCard('V volitional form +' + toomotteimasu,
                     [('light_green', 'V volitional form'),
                      ('light_pink', toomotteimasu)]))
    writeNewLine(f)

    f.write(printTitle('Prerequisite'))
    f.write(
        f'Please see [these rules](volitional_form.md) if you want to know how to do verb conjugation for volitional form.'
    )
    writeNewLine(f)
    f.write(printTitle('Explanation'))
    f.write(
        f"You can use the volitional form with {toomotteimasu} to express what the speaker is thinking of doing. Note that when you use this expression, the decision of doing something was made some time ago. You can also use to express a third person's will or intention."
    )

    f.write(printTitle('Examples'))

    f.write('<b>Example A</b>')
    f.write('<br>')
    l1 = TextPair('週末は 海に 行こうと思っています。',
                  "I am thinking of going to the beach at the weekend.", [
    f.write(getInfoBlock("You <b>cannot</b> use `と` 「to」to express the speaker's wishes, judgement, permission, hopes, requests"))
    f.write('\n')

    f.write(printTitle('Conjugation Rule for と「to」'))
    cardText = 'Sentence: <em>[Condition]</em> `と` <em>[Result]</em> \n \n use <em>present tense short form</em> + `と`'

    f.write(generateCard(cardText, [], useLeft=True))

    f.write('<br>')
    f.write('<b>Example A</b>')
    f.write('<br>')
    l1 = TextPair('ここを押すと、ドアが 開きます。', "Press here to open the door.", [HighlightText('押す', Color.LIGHT_GREEN), HighlightText('と', Color.LIGHT_PINK)], addBullet=True, )
    f.write(generate([l1]))
    writeNewLine(f)

    f.write(getCssFlowChartWithTwoBlock(getHtmlString('押す'), 'attach と', getHtmlString('押すと'), ))
    writeNewLine(f)
    f.write('<b>Example B</b>')
    f.write('<br>')
    l1 = TextPair('メアリーさんが 国に帰ると 寂しくなります。', "When Mary returns home, we will be lonely.", [HighlightText('帰る', Color.LIGHT_GREEN), HighlightText('と', Color.LIGHT_PINK)], addBullet=True, )
    f.write(generate([l1]))

    f.write(getCssFlowChartWithTwoBlock(getHtmlString('帰る'), 'attach と', getHtmlString('帰ると'), ))
    f.write('\n')
    f.write(getInfoBlock("In this example, we are expressing the cause-effect relationship within the event"))
    f.write('\n')

    f.write('<br>')
    f.write('<b>Example C</b>')
    f.write('<br>')
    l1 = TextPair('私は子供の時、冬になると風邪をひきました。', "When I was a child, I caught a cold whenever winter arrived.", [HighlightText('だった', Color.LIGHT_GREEN), HighlightText('ら', Color.LIGHT_PINK, replaceAt=1)],
Beispiel #4
0
    f.write('<b>Example A : Verb</b>')
    f.write('<br>')
    l1 = TextPair(
        '東京へ 来たら、 ぜひ連絡して ください。',
        "Please contact me when you come to Tokyo.",
        [
            HighlightText('来た', Color.LIGHT_GREEN),
            HighlightText('ら', Color.LIGHT_PINK, replaceAt=1)
        ],
        addBullet=True,
    )
    f.write(generate([l1]))
    writeNewLine(f)

    f.write(
        getCssFlowChartWithThreeBlock(getHtmlString('来る'),
                                      'change to past tense form',
                                      getHtmlString('来た'), 'attach ら',
                                      getHtmlString('来たら')))
    writeNewLine(f)
    f.write('<b>Example B : Verb</b>')
    f.write('<br>')
    l1 = TextPair(
        '練習したら うまくなるよ。',
        "If you practice, you'll get better.",
        [
            HighlightText('練習した', Color.LIGHT_GREEN),
            HighlightText('ら', Color.LIGHT_PINK, replaceAt=1)
        ],
        addBullet=True,
    )
    f.write(getMermaidScript())

    f.write(printTitle('Usage Form'))
    cardText = ' Stem Verb  + ながら'

    f.write(generateCard(cardText, []))

    f.write(printTitle('Explanation'))
    f.write(
        "You can use with ながら with two verbs to express the two actions are performed at the same time. However, it cannot describe an action performed by another person."
    )
    f.write(printTitle('Examples'))

    f.write('<b>Example A</b>')
    f.write('<br>')
    furigana = getHtmlString("聞く")
    furigana1 = getHtmlString("聞き")
    furigana3 = getHtmlString("聞きながら")
    flowChart = getFlowChart(
        ["聞く", "聞き", "聞きながら"],
        ['convert dictionary to stem verb', 'combine with ながら'])
    f.write(flowChart)
    l1 = TextPair('私はいつも音楽を聞きながら日本語を勉強します。',
                  "I always study Japanese while listening to music.", [
                      HighlightText('聞き', Color.LIGHT_GREEN),
                      HighlightText('ながら', Color.LIGHT_PINK)
                  ],
                  addBullet=True)
    f.write(generate([l1]))
    writeNewLine(f)
Beispiel #6
0
    cardText = '<b>Rule 1:</b> For u-verbs: Replace the u-vowel sound with the お equivalent and attach う' + '\n' + '\n' + \
               '<b>Rule 2:</b> For ru-verbs: Replace る with よう' + '\n' + '\n' + \
               '<b>Rule 3:</b> For exceptions: する becomes しよう and くる becomes こよう'

    f.write(generateCard(cardText, [], useLeft=True))

    f.write((printTitle('Rule 1')))
    writeNewLine(f)
    f.write(
        'For u-verbs: Replace the u-vowel sound with the お equivalent and attach う'
    )

    table = generateTable(
        ['Dictionary Form', 'Replacing Method', 'Volitional Form'], [
            [
                getHtmlString("使う"),
                'Replace う with お sound equivalent and attach う',
                getHtmlString("使おう")
            ],
            [
                getHtmlString("引く"),
                'Replace く with お sound equivalent and attach う',
                getHtmlString("引こう")
            ],
            [
                getHtmlString("泳ぐ"),
                'Replace ぐ with お sound equivalent and attach う',
                getHtmlString("泳ごう")
            ],
            [
                getHtmlString("起こす"),
Beispiel #7
0
    f.write(generate([l1]))
    writeNewLine(f)
    writeNewLine(f)
    f.write('You could also add `まだ` to show that the state is on going.')
    l1 = TextPair('まだ 雨が 降っています。',
                  'It is still raining.', [
                      HighlightText('まだ', Color.LIGHT_INDIGO),
                      HighlightText('降って', Color.LIGHT_GREEN),
                      HighlightText('います', Color.LIGHT_PINK)
                  ],
                  addBullet=True)
    f.write(generate([l1]))

    f.write((printTitle('To describe habitual actions')))
    f.write('\n')
    morning = getHtmlString('毎朝')
    f.write(
        'You can also use `ている` to describe habitual actions.' +
        f'There is a time indicator such as {morning} to show when actions are occurring regularly.'
    )
    l1 = TextPair('毎朝 ジョギングを しています。',
                  'I jog every morning.', [
                      HighlightText('毎朝', Color.LIGHT_INDIGO),
                      HighlightText('して', Color.LIGHT_GREEN),
                      HighlightText('います', Color.LIGHT_PINK)
                  ],
                  addBullet=True)
    f.write(generate([l1]))
    writeNewLine(f)
    f.write('\n')
Beispiel #8
0
               '<b>Rule 5:</b> For い-Adj:  Change the last い of the い-adjective into ければ' + '\n' + '\n' + \
               '<b>Rule 6:</b> For な-Adj: Change the last な of the な-adjective and attach なら' + '\n' + '\n' + \
               '<b>Rule 7:</b> For Noun: Attach なら to the noun'

    f.write(generateCard(cardText, [], useLeft=True))

    f.write((printTitle('Rule 1')))
    writeNewLine(f)
    f.write(
        'For u-verbs: Replace the u-vowel sound with the え equivalent and attach ば'
    )

    table = generateTable(
        ['Dictionary Form', 'Replacing Method', 'Conditional Form'], [
            [
                getHtmlString("使う"),
                'Replace う with the え equivalent and attach ば',
                getHtmlString("使えば")
            ],
            [
                getHtmlString("引く"),
                'Replace く with the え equivalent and attach ば',
                getHtmlString("引けば")
            ],
            [
                getHtmlString("泳ぐ"),
                'Replace ぐ with the え equivalent and attach ば',
                getHtmlString("泳げば")
            ],
            [
                getHtmlString("起こす"),
from python_utils.html_generator import getHtmlString
from python_utils.table_generator import generateTable

with open('te_form.md', 'w', encoding="utf-8") as f:
    f.write(printTitle('Verb て-Form (Te-Form)'))
    f.write(
        'Te-forms are a very important part of Japanese grammar. You can use in the following forms.\n \n'
    )
    f.write('- [V て-form + いただけませんか](v_te-form_+_itadakemasenka.md)\n')
    f.write('- [V て-form + います](v_te-form_iru.md)\n')
    f.write('- [V て-form + おきます](v_te-form_okimasu.md)\n')

    f.write((printTitle('Rule 1')))
    f.write('For ru-verbs: Replace る with て')
    table = generateTable(['Dictionary Form', 'Replacing Method', 'て-Form'], [
        [getHtmlString("食べる"), 'Replace る with て',
         getHtmlString("食べて")],
    ])

    f.write(table)

    f.write((printTitle('Rule 2')))
    f.write('For u-verbs: we have 5 subs categories.')
    f.write(printSecondaryTitle('u-verbs with final う, つ and る'))
    f.write('For u-verbs ending with う, つ and る, we should replace with って.')
    table = generateTable(
        ['Dictionary Form', 'Replacing Method', 'て-Form'],
        [[getHtmlString("会う"), 'Replace う with って',
          getHtmlString("会って")],
         [getHtmlString("待つ"), 'Replace つ with って',
          getHtmlString("待って")],
Beispiel #10
0
    cardText = '<b>Rule 1:</b> For ru-verbs: Replace る with た' + '<br>' + \
               '<b>Rule 2:</b> <br> &emsp; For u-verbs ending with う, つ and る: Replace those ending with った' + '<br>' + \
               '&emsp; For u-verbs ending with む, ぶ and ぬ: Replace those ending with んだ' + '<br>' + \
               '&emsp; For u-verbs ending with く: Replace those ending with いて' + '<br>' + \
               '&emsp; For u-verbs ending with ぐ: Replace those ending with いだ' + '<br>' + \
               '&emsp; For u-verbs ending with す: Replace those ending with した' + '<br>' + \
               '&emsp; u-verbs exception: past tense form of 行く is 行った' + '<br>' + \
               '<b>Rule 3:</b> For exceptions: する becomes した and くる becomes きた'

    f.write(generateCard(cardText, [], useLeft=True))

    f.write((printTitle('Rule 1')))
    f.write('For ru-verbs: Replace `る` with `た`')
    table = generateTable(
        ['Dictionary Form', 'Replacing Method', 'Past Tense Form'], [
            [getHtmlString("食べる"), 'Replace る with た',
             getHtmlString("食べた")],
        ])

    f.write(table)

    f.write((printTitle('Rule 2')))
    f.write('For u-verbs: we have 5 subs categories.')
    f.write(printSecondaryTitle('u-verbs with final う, つ and る'))
    f.write('For u-verbs ending with う, つ and る, we should replace with った.')
    table = generateTable(
        ['Dictionary Form', 'Replacing Method', 'Past Tense Form'],
        [[getHtmlString("会う"), 'Replace う with った',
          getHtmlString("会った")],
         [getHtmlString("待つ"), 'Replace つ with った',
          getHtmlString("待った")],
    cardText = '<b>Rule 1:</b> For u-verbs: Replace the u-vowel sound with the あ equivalent and attach れる' + '\n' + '\n' + \
               '<b>Rule 2:</b> For ru-verbs: Replace る with られる' + '\n' + '\n' + \
               '<b>Rule 3:</b> For verb exceptions: する becomes される and される becomes こられる' + '\n' + '\n'

    f.write(generateCard(cardText, [], useLeft=True))

    f.write((printTitle('Rule 1')))
    writeNewLine(f)
    f.write(
        'For u-verbs: Replace the u-vowel sound with the あ equivalent and attach れる'
    )

    table = generateTable(
        ['Dictionary Form', 'Replacing Method', 'Passive Form'], [
            [
                getHtmlString("使う"),
                'Replace う with the あ equivalent and attach れる',
                getHtmlString("使われる")
            ],
            [
                getHtmlString("行く"),
                'Replace く with the あ equivalent and attach れる',
                getHtmlString("行かれる")
            ],
            [
                getHtmlString("泳ぐ"),
                'Replace ぐ with the あ equivalent and attach れる',
                getHtmlString("泳がれる")
            ],
            [
                getHtmlString("話す"),