python string manipulation for 法语规则动词变位1

我们在学法语动词变位的时候,经常会“去掉词尾” 加上xxx。这是不是很像我们最早学python玩string时候的呢?玩一玩。

直陈式现在时

有 -er, -ir结尾

第一组动词, 以er结尾的

def verb_group1_indicatif_present(mot):
    assert mot[-2:] == 'er'
    res = {}
    root = mot[:-2]
    res['je'] = root + 'e'
    res['tu'] = root + 'es'
    res['il'] = root + 'e'
    res['elle'] = root + 'e'
    res['nous'] = root + 'ons'
    res['vous'] = root + 'ez'
    res['ils'] = root + 'ent'
    return res

第二组动词 以ir结尾

def verb_group2_indicatif_present(mot):
    assert mot[-2:] == 'ir'
    res = {}
    root = mot[:-2]
    res['je'] = root + 'is'
    res['tu'] = root + 'is'
    res['il'] = root + 'it'
    res['elle'] = root + 'it'
    res['nous'] = root + 'issons'
    res['vous'] = root + 'issez'
    res['ils'] = root + 'ent'
    return res
def verb_indicatif_present(mot):
    if mot[-2:] == 'er':
        return verb_group1_indicatif_present(mot)
    elif mot[-2:] == 'ir':
        return verb_group2_indicatif_present(mot)

def verb_group1_passe_compose(mot):
    #     group 1
    assert mot[-2:] == 'er'
    root = mot[:-2]
    res = {}
    res['je'] = root + 'é'
    res['tu'] = root + 'é'
    res['il'] = root + 'é'
    res['elle'] = root + 'ée'
    res['nous'] = root + 'é'
    res['vous'] = root + 'é'
    res['ils'] = root + 'é'
    res['elles'] = root + 'ées'
    return res
    assert mot[-2:] == 'ir'
    root = mot[:-2]
    res = {}
    res['je'] = root + 'i'
    res['tu'] = root + 'i'
    res['il'] = root + 'i'
    res['elle'] = root + 'i'
    res['nous'] = root + 'i'
    res['vous'] = root + 'i'
    res['ils'] = root + 'i'
    res['elles'] = root + 'i'
    return res
def verb_group_passe_compose(mot):
    if mot[-2:] == 'er':
        return verb_group1_passe_compose(mot)
    elif mot[-2:] == 'ir':
        return verb_group2_passe_compose(mot)
def verb_imparfait(mot):
    """group 1 and group 2
    未完成过去式"""
    root = verb_indicatif_present(mot)['nous']
    res = {}
    res['je'] = root + 'ais'
    res['tu'] = root + 'ais'
    res['il'] = root + 'ait'
    res['elle'] = root + 'ait'
    res['nous'] = root + 'ions'
    res['vous'] = root + 'iez'
    res['ils'] = root + 'aient'
    # res['elles'] = root + 'i'
    return res
def verb_futur_simpler(mot):
    """group 1 and group 2
    简单将来时"""
    res = {}
    res['je'] = mot + 'ai'
    res['tu'] = mot + 'as'
    res['il'] = mot + 'a'
    res['elle'] = mot + 'a'
    res['nous'] = mot + 'ons'
    res['vous'] = mot + 'ez'
    res['ils'] = mot + 'ont'
    return res

你可能感兴趣的:(python string manipulation for 法语规则动词变位1)