鉴于POS标签,例如VBD,如何将动词与NLTK匹配?
e.g。
VERB: go
POS: VBD
RESULT: went
答案 0 :(得分:14)
NLTK目前不提供变形。 Pattern-en和nodebox进行了变换。
有时,pattern-en网站中的示例无法正常显示。这对我有用:
>>> from pattern.en import conjugate
>>> verb = "go"
>>> conjugate(verb,
... tense = "past", # INFINITIVE, PRESENT, PAST, FUTURE
... person = 3, # 1, 2, 3 or None
... number = "singular", # SG, PL
... mood = "indicative", # INDICATIVE, IMPERATIVE, CONDITIONAL, SUBJUNCTIVE
... aspect = "imperfective", # IMPERFECTIVE, PERFECTIVE, PROGRESSIVE
... negated = False) # True or False
u'went'
>>>
注意强>
似乎conjugate
仅在时态不需要辅助动词时输出。例如,在西班牙语中, ir 的(单数第一人称)未来是iré。在英语中, go 的未来由辅助将和不定式 go 组成,导致将 。在下面的代码中,输出iré,但将不会。
>>> from pattern.es import conjugate as conjugate_es
>>> verb = "ir"
>>> conjugate_es(verb, tense = "future")
u'ir\xe1'
>>> from pattern.en import conjugate as conjugate_en
>>> verb = "go"
>>> conjugate_en(verb, tense = "future")
>>>
答案 1 :(得分:1)
我使用MontyLingua进行单词拐点和结合。 https://pypi.python.org/pypi/MontyLingua/2.1
mlg = MontyLingua.MontyNLGenerator.MontyNLGenerator()
mlg.conjugate_verb(verb,mode)