コード例 #1
0
ファイル: syntax.py プロジェクト: andlima/fraseador
def determiner(person=None, gender=None, number=None, function='S',
               kind=None, S=None):
    if percent(35):
        det = wf.getNominal('article', gender, number)
        next = (det.value.index, 'article')
    elif percent(50):
        det = wf.getAdjectivePronoun(gender, number, 'determiner')
        next = (det.value.index, 'adjective_pronoun')
    else:
        det = wf.getPossessivePronoun(
            gender, number, aleatory('person'), aleatory('number'))
        next = (det.value.index, 'possessive_pronoun')
    return Tree('determiner', [det], {'next': next})
コード例 #2
0
ファイル: syntax.py プロジェクト: andlima/fraseador
def adnominalAdjunct(person=None, gender=None, number=None, function='S',
                     kind=None, S=None, position='pos'):
    L = []

    if kind == 'noun':
        if percent(20):
            if percent(50):
                # menino feio
                # bola feia
                adjective = wf.getNominal('adjective', gender, number, S)
                L.append(adjective)
            else:
                if percent(40):
                    # menino que correu
                    # bola que caiu
                    L = [wf.getRelativePronoun(gender, number, None),
                         verbPhrase(person, gender, number, S=S)]
                elif percent(50):
                    # menino que a mãe ama
                    # bola que o menino chutou
                    L = [wf.getRelativePronoun(gender, number, None),
                         clause(tran='vtd', OD=S)]
                else:
                    # menino de quem a mãe gosta
                    # bola da qual o menino gosta
                    that_clause = clause(tran='vti', OI=S)
                    preposition = wf.getPreposition(
                        that_clause.info['preposition'], gender,
                        number, None)
                    L = [
                        preposition,
                        wf.getRelativePronoun(
                            gender, number, S
                        ),
                        that_clause
                    ]

    elif kind == 'personal_pronoun' and function == 'S':
        if percent(20):
            # eu que corri
            L = [wf.getRelativePronoun(gender, number, None),
                 verbPhrase(person, gender, number, S=S)]

    if L:
        return Tree('adnominal adjunct', L, {})
    else:
        return None
コード例 #3
0
ファイル: syntax.py プロジェクト: andlima/fraseador
def noun(person=None, gender=None, number=None, function='S',
         kind=None, S=None):

    if kind == 'noun':
        if person != '3':
            raise NounNotThirdPersonError(
                'Phrase for noun not on the 3rd person: %s' % str(
                    (person, gender, number, function, kind, S)
                )
            )
        head = wf.getNominal('noun', gender, number, S)
        next = (head.value.index, 'noun')
    elif kind == 'personal_pronoun':
        tonic = 'a' if function == 'OD' else 't'
        head = wf.getPersonalPronoun(
            person, number, gender, function, tonic)
        next = (head.value.index, 'personal_pronoun')
    else:
        raise NounPhraseKindError(
            "Invalid argument `kind`=%s for noun(). Should be one of: "
            "['noun', 'personal_pronoun']. " % repr(kind)
        )
    return Tree('noun', [head], {'head': head, 'next': next})