2

The wordnet demo as shown here displays the lexical information of a file in its search result. for example the word motion has many lexical categories( as it has many "senses" ) one of them being "verb.motion".I have seen the other questions but they do not explain as to how you could do this in NLTK. How can I obtain that information using NLTK.

Community
  • 1
  • 1
Kiran Yallabandi
  • 2,544
  • 2
  • 22
  • 25
  • Imho you are searching possible lemmas. Have you been visiting this site: http://www.nltk.org/howto/wordnet.html ? – 404pio Mar 05 '15 at 13:15
  • @frankov That is the first place I looked up actually. Any way as per my understanding of lemmas they are nothing but the base form of a word, independent of the senses . For example we have the word content which has the senses "proportion of a material" and "the state of being contended" and the lemma of those senses would simply be the word "content". What I want is the lexical information associated with it that is , for the above two examples it would be "noun.relation" and "noun.state". Please correct me if I'm wrong. – Kiran Yallabandi Mar 05 '15 at 20:15
  • Maybe you are searching for mophological dictionaries? – 404pio Mar 05 '15 at 22:22
  • Ok, look here: http://www.nltk.org/book/ch05.html at section "7 How to Determine the Category of a Word" and subsection "7.2 Syntactic Clues" - it's little laconic, but you can start from there - if it's what you are searching. – 404pio Mar 05 '15 at 22:33
  • @frankov First of all thank you for your efforts but POS tagging is not what I am looking for. Here look at this sample definition of the word "transfer" from wordnet website : S: (v) transfer, reassign (transfer somebody to a different position or location of work) S: (v) transfer (move from one place to another) "transfer the data". As you can see here you have categories like "".I want to extract these using the NLTK. – Kiran Yallabandi Mar 06 '15 at 07:09

2 Answers2

6

@Kiran Yallabandi

I didn't know what you want. But now, I have example:

In [1]: from nltk.corpus import wordnet as wn

In [35]: for synset in wn.synsets('move'):
    print "<%s> (%s) %s" % (synset.lexname, synset.definition, 

synset.examples)
   ....:     
<noun.act> (the act of deciding to do something) ["he didn't make a move to help", 'his first move was to hire a lawyer']
<noun.act> (the act of changing your residence or place of business) ['they say that three moves equal one fire']
<noun.act> (a change of position that does not entail a change of location) ['the reflex motion of his eyebrows revealed his surprise', 'movement is a sign of life', 'an impatient move of his hand', 'gastrointestinal motility']
<noun.act> (the act of changing location from one place to another) ['police controlled the motion of the crowd', 'the movement of people from the farms to the cities', 'his move put him directly in my path']
<noun.act> ((game) a player's turn to take some action permitted by the rules of the game) []
<verb.motion> (change location; move, travel, or proceed, also metaphorically) ['How fast does your new car go?', 'We travelled from Rome to Naples by bus', 'The policemen went from door to door looking for the suspect', 'The soldiers moved towards the city in an attempt to take it before night fell', 'news travelled fast']
<verb.motion> (cause to move or shift into a new position or place, both in a concrete and in an abstract sense) ['Move those boxes into the corner, please', "I'm moving my money to another bank", 'The director moved more responsibilities onto his new assistant']
<verb.motion> (move so as to change position, perform a nontranslational motion) ['He moved his hand slightly to the right']
<verb.motion> (change residence, affiliation, or place of employment) ['We moved from Idaho to Nebraska', 'The basketball player moved from one team to another']
<verb.social> (follow a procedure or take a course) ['We should go farther in this matter', 'She went through a lot of trouble', 'go about the world in a certain manner', 'Messages must go through diplomatic channels']
<verb.body> (be in a state of action) ['she is always moving']
<verb.change> (go or proceed from one point to another) ['the debate moved from family values to the economy']
<verb.social> (perform an action, or work out or perform (an action)) ['think before you act', 'We must move quickly', 'The governor should act on the new energy bill', 'The nanny acted quickly by grabbing the toddler and covering him with a wet towel']
<verb.emotion> (have an emotional or cognitive impact upon) ['This child impressed me as unusually mature', 'This behavior struck me as odd']
<verb.creation> (give an incentive for action) ['This moved me to sacrifice my career']
<verb.emotion> (arouse sympathy or compassion in) ['Her fate moved us all']
<verb.possession> (dispose of by selling) ['The chairman of the company told the salesmen to move the computers']
<verb.change> (progress by being changed) ['The speech has to go through several more drafts', 'run through your presentation before the meeting']
<verb.social> (live one's life in a specified environment) ['she moves in certain circles only']
<verb.competition> (have a turn; make one's move in a game) ['Can I go now?']
<verb.communication> (propose formally; in a debate or parliamentary meeting) []

Is this that, what you need? You have to have wordnet corpus downloaded via nltk downloader.

404pio
  • 1,080
  • 1
  • 12
  • 32
4

Too bad it wont let me add comment, I have to submit as answer.

To add to 404pio's answer,

instead of this:

synset.lexname

you want this:

synset.lexname()

Reason: they have simply updated and made changes to nltk.

Source: https://stackoverflow.com/a/27796656

Vineeth Sai
  • 3,389
  • 7
  • 23
  • 34
agileOne
  • 97
  • 9