给定POS标签,例如VBD,如何将动词与NLTK匹配?
例如
VERB: go
POS: VBD
RESULT: went
Run Code Online (Sandbox Code Playgroud)
art*_*omp 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'
>>>
Run Code Online (Sandbox Code Playgroud)
注意
conjugate当时态不需要辅助动词时,似乎只输出.例如,在西班牙语中,ir的(单数第一人称)未来是iré.在英语中,go的未来是由辅助意志和不定式去形成的,导致将去.在下面的代码,IRE输出,但不是会去.
>>> 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")
>>>
Run Code Online (Sandbox Code Playgroud)