Exemple #1
0
def promote_to_clause(e):
    """ Convert element into a clause. If it is a clause, return it as is. """
    if is_clause_t(e): return e
    if is_phrase_t(e):
        if e._type == NOUNPHRASE: return Clause(e)
        if e._type == VERBPHRASE: return Clause(Element(), e)
    return Clause(e)
Exemple #2
0
def promote_to_phrase(e):
    """ Convert element into a clause. If it is a clause, return it as is. """
    if is_clause_t(e): return e
    if is_phrase_t(e): return e
    if e._type == STRING: return NounPhrase(e, features=e._features)
    if e._type == PLACEHOLDER: return NounPhrase(e, features=e._features)
    if e._type == WORD:
        if e.pos == POS_VERB: return VerbPhrase(e, features=e._features)
        if e.pos == POS_ADVERB: return VerbPhrase(e, features=e._features)
        return NounPhrase(e, features=e._features)
    if e._type == COORDINATION:
        return Coordination(*[promote_to_phrase(x) for x in e.coords],
                            conj=e.conj, features=e._features)
    return NounPhrase(e, features=e._features)