Convert words into their noun / adjective / verb form in Java

前端 未结 1 403
生来不讨喜
生来不讨喜 2021-01-14 06:13

Is it possible to hava a Java alternative to NLTK in order to \'verbify\' words as can be seen in this question?

Convert words between verb/noun/adjective forms

相关标签:
1条回答
  • 2021-01-14 06:26

    A quick and dirty solution using wordnet can be like following.

    >>>from ntlk.corpus import wordnet as wn
    >>> wn.synsets('born')
    [Synset('born.n.01'), Synset('bear.v.01'), Synset('give_birth.v.01'), Synset('digest.v.03'), Synset('bear.v.04'), Synset('bear.v.05'), Synset('bear.v.06'), Synset('hold.v.11'), Synset('yield.v.10'), Synset('wear.v.02'), Synset('behave.v.02'), Synset('bear.v.11'), Synset('hold.v.14'), Synset('have_a_bun_in_the_oven.v.01'), Synset('born.a.01'), Synset('natural.s.09')]
    
    >>> wn.synsets('birth')
    [Synset('birth.n.01'), Synset('birth.n.02'), Synset('parturition.n.01'), Synset('parentage.n.02'), Synset('birth.n.05'), Synset('give_birth.v.01')]
    >>>
    

    Here you can see that " Synset('give_birth.v.01')] " is a common result set which is "verb". So in this way you can find work around and see if there is any matching result, and convert born to birth or vice versa!

    0 讨论(0)
提交回复
热议问题