コード例 #1
0
ファイル: __init__.py プロジェクト: EthanBlackburn/pattern
def lemma(word, pos="NN"):
    if pos == "NNS":
        return singularize(word)
    if pos.startswith(("VB","MD")):
        return conjugate(word, "infinitive") or word
    if pos.startswith(("JJ",)):
        return predicative(word)
    if pos.startswith(("DT",)):
        return singularize(word, pos="DT")
    return word
コード例 #2
0
ファイル: __init__.py プロジェクト: waytai/pattern
def lemma(word, pos="NN"):
    if pos == "NNS":
        return singularize(word)
    if pos.startswith(("VB", "MD")):
        return conjugate(word, "infinitive") or word
    if pos.startswith(("JJ", )):
        return predicative(word)
    if pos.startswith(("DT", )):
        return singularize(word, pos="DT")
    return word
コード例 #3
0
def lemma(word, pos="NN"):
    if pos == "NNS":
        return singularize(word)
    if pos.startswith(("VB","MD")):
        return conjugate(word, "infinitive") or word
    if pos.startswith(("JJ",)):
        return predicative(word)
    if pos.startswith(("DT","PR","WP")):
        return singularize(word, pos=pos)
    if pos.startswith(("RB", "IN")) and (word.endswith(("'", u"’")) or word == "du"):
        return singularize(word, pos=pos)
    return word
コード例 #4
0
ファイル: __init__.py プロジェクト: fivejjs/pattern
def lemma(word, pos="NN"):
    """ Returns the lemma of the given word, e.g. horses/NNS => horse, am/VBP => be.
        Words must be lowercase.
    """
    if pos == "NNS":
        return singularize(word)
    if pos is not None and pos.startswith(("VB", "MD")):
        return conjugate(word, "infinitive") or word
    return word
コード例 #5
0
ファイル: __init__.py プロジェクト: rajeshnair/pattern
def lemma(word, pos="NN"):
    """ Returns the lemma of the given word, e.g. horses/NNS => horse, am/VBP => be.
        Words must be lowercase.
    """
    if pos == "NNS":
        return singularize(word)
    if pos.startswith(("VB", "MD")):
        return conjugate(word, "infinitive") or word
    return word