当前位置:   article > 正文

NLP:pattern库应用_pattern库 nlp

pattern库 nlp
  1. from pattern.en import conjugate, PRESENT, INFINITIVE, PAST, FUTURE, SG, PLURAL, PROGRESSIVE
  2. vb_word = "be"
  3. print(conjugate(vb_word, tense=PRESENT, person=1, number=SG))
  4. print(conjugate(vb_word, tense=PRESENT, person=2, number=SG))
  5. print(conjugate(vb_word, tense=PRESENT, person=3, number=SG))
  6. print(conjugate(vb_word, tense=PRESENT, number=PLURAL))
  7. print(conjugate(vb_word, tense=PRESENT, aspect=PROGRESSIVE))
  8. print(conjugate(vb_word, tense=INFINITIVE))
  9. print(conjugate(vb_word, tense=PAST, aspect=PROGRESSIVE))

tense:时态

person:n—第n人称

number:主语的单复数(个数)

aspect:语态(+ed、+ing)

 

以下为源码解释:

https://github.com/clips/pattern/blob/53245196139c6ef26dc9c34873dda8a16f236d23/examples/03-en/01-inflect.py

  1. # The conjugate() function inflects a verb to another tense.
  2. # You can supply:
  3. # - tense : INFINITIVE, PRESENT, PAST,
  4. # - person: 1, 2, 3 or None,
  5. # - number: SINGULAR, PLURAL,
  6. # - mood : INDICATIVE, IMPERATIVE,
  7. # - aspect: IMPERFECTIVE, PROGRESSIVE.
  8. # The tense can also be given as an abbreviated alias, e.g.,
  9. # inf, 1sg, 2sg, 3sg, pl, part, 1sgp, 2sgp, 3sgp, ppl, ppart.
  10. from pattern.en import PRESENT, SINGULAR
  11. print(conjugate("being", tense=PRESENT, person=1, number=SINGULAR, negated=False))
  12. print(conjugate("being", tense="1sg", negated=False))
  13. print("")

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/343453
推荐阅读
相关标签
  

闽ICP备14008679号