Replies: 1 comment 4 replies
-
A sense is an edge between a word and a synset showing that a word has the conceptual meaning captured by the synset (there is some documentation here). There may be many senses for a word, and many words for a synset. While it is technically possible for the same word and synset to have multiple sense links between them, such a situation would be redundant and erroneous, and that wordnet should be corrected.
By "it" I think you mean getting the sense, if any, between a given for sense in wn.senses(word):
word = sense.word()
synset = sense.synset() You could use these to populate a dictionary for later lookup, if you like: lookup_dict[(word, synset)] = sense
I'm not sure what you mean by "position". If you mean a unique key for use in a dictionary, the d = {}
for sense in wn.senses(word):
d[sense] = (sense.word(), sense.synset()) But if you know you're only working within a single lexicon, you can use the identifiers, which is a bit faster if you're doing this frequently: d = {}
for sense in wn.senses(word):
d[sense.id] = (sense.word(), sense.synset()) While it's unlikely, a synset, sense, or word identifier can be reused in different lexicons, but not within a single lexicon. When you use wn.senses(word, lexicon='pwn:3.0') # or whatever lexicon you want Or, even better, create a pwn = wn.Wordnet(lexicon='pwn:3.0')
pwn.senses(word) |
Beta Was this translation helpful? Give feedback.
-
i'm looping trought word synsets ...afaik there is only one sense per pair word ==sense==> synset ! right ?
how can i get it ?
As a side question is this the fastest way to check for the position of the sense ... i dont want to use dict if possible (wondering if hash() is necessary)
sense_map = { hash(e):i for i,e in enumerate(wn.senses()) }
Beta Was this translation helpful? Give feedback.
All reactions