Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjective Nominalization in Python NLTK

Is there a way to obtain Wordnet adjective nominalizations using NLTK? For example, for happy the desired output would be happiness.

I tried to dig around, but couldn't find anything.

like image 787
abhgh Avatar asked Oct 14 '22 05:10

abhgh


1 Answers

The quick and dirty answer is that wordnet does this already:

  • <adj.all>S: (adj) happy (enjoying or showing or marked by joy or pleasure) "a happy smile"; "spent many happy days on the beach"; "a happy marriage"

    • attribute
      • <noun.state>S: (n) happiness, felicity (state of well-being characterized by emotions ranging from contentment to intense joy)
      • <noun.feeling>S: (n) happiness (emotions experienced when in a state of well-being)
    • derivationally related form
      • <noun.state> W: (n) happiness [Related to: happy] (state of well-being characterized by emotions ranging from contentment to intense joy)
      • <noun.feeling> W: (n) happiness [Related to: happy] (emotions experienced when in a state of well-being)

The remaining question is how to do this programmatically (without web-scraping).

Added:

The wordnet library wrapper tool is pretty powerful and demonstrates what appears to be the breadth of the C library interface:

$ wn happy
No information available for noun happy
No information available for verb happy
Information available for adj happy
    -antsa      Antonyms
    -synsa      Synonyms (ordered by estimated frequency)
    -attra      Attributes
    -deria      Derived Forms
    -famla      Familiarity & Polysemy Count
    -grepa      List of Compound Words
    -over       Overview of Senses
$ wn happy -deria -n1
Derived Forms of adj happy
Sense 1
happy (vs. unhappy)
       RELATED TO->(noun) happiness#1
           => happiness, felicity
       RELATED TO->(noun) happiness#2
           => happiness

So, Pythonically, you could either subprocess to the wn command which is kinda sloppy, or use the wordnet facilities already built into NLTK.

On ubuntu (and presumably debian) the wordnet libraries and tools are conveniently available with:

sudo apt-get install wordnet wordnet-dev

Alas:

$ wn pythonic
No information available for pythonic
like image 89
msw Avatar answered Oct 21 '22 08:10

msw