Comments (6)
Ok, I think I understand. I've updated the original issue text to clarify (please update if it's inaccurate).
However, my initial reaction is that this is not a good fit for Wn. Unlike the NLTK, Wn is not trying to accommodate a wide range of NLP tasks, but is specifically about modeling and working with wordnet data as defined by WN-LMF. I would therefore suggest using another tag mapper with Wn, such as the NLTK's nltk.tag.mapping (but I'm not sure if it supports the wordnet tagset). If it does, you could write a wrapper function:
def ptb_synsets(lemma: str = None, pos: str = None, *args, **kwargs) -> wn.Synset:
if pos:
pos = map_tag('en-ptb', 'wordnet', pos)
return wn.synsets(lemma, pos, *args, **kwargs)
from wn.
@LifeIsStrange can you please explain what you want with this issue? I see that the linked NLTK pull request is something to do with PTB style POS tags, but I don't know what you want here.
from wn.
Hmm one of the use case I see would be:
wn.words(pos='v')
The wn APIs that accept a pos argument could allow the universal pos tag and pen tree bank pos tags as equivalent values. (since the pos can be obtained from an external program that may use those popular tagging schemes)
I don't know wether the nltk PR cover more use cases
The original NLTK issue explain it better than I do:
nltk/nltk#2963
from wn.
i found a case with 'p'???. keeps throwing an error. seems any POS tag with p
in it will not have an index assignment.:
>> idk it's some kind of lame ai program or app
[('idk', 'NN'), ('it', 'PRP'), ("'s", 'VBZ'), ('some', 'DT'), ('kind', 'NN'), ('of', 'IN'), ('lame', 'JJ'), ('ai', 'JJ'), ('program'
, 'NN'), ('or', 'CC'), ('app', 'NN')]
idk/NN
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\site-packages\nltk\corpus\reader\sentiwordnet.py", line 94, in se
nti_synsets
synset_list = wn.synsets(string, pos)
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\site-packages\nltk\corpus\reader\wordnet.py", line 1700, in synse
ts
return [
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\site-packages\nltk\corpus\reader\wordnet.py", line 1703, in <list
comp>
for form in self._morphy(lemma, p, check_exceptions)
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\site-packages\nltk\corpus\reader\wordnet.py", line 2008, in _morp
hy
exceptions = self._exception_map[pos]
KeyError: 'p'
def process_user_input(user_input: str, db: TinyDB):
if len(user_input) > 0:
# train(user_input, db)
# response
tokens = nltk.word_tokenize(user_input)
tags = nltk.pos_tag(tokens)
# find entities
# entities = nltk.chunk.ne_chunk(tags)
[print(list(sentiwordnet.senti_synsets(tag[0], tag[1].lower()))) for tag in tags]
from wn.
@white5moke it appears you are using the NLTK in your example. This repository is a standalone project called Wn and is not part of the NLTK.
While the NLTK appears to raise an error for an unknown part of speech, in Wn, p
is in fact a valid part of speech, but no wordnet (that I'm aware of) makes use of it. Using pos='p'
should just return an empty list:
>>> import wn
>>> import wn.constants
>>> wn.constants.ADPOSITION
'p'
>>> wn.synsets(pos='p')
[]
Wn will also return an empty list (instead of an error) for an invalid part of speech:
>>> wn.constants.PARTS_OF_SPEECH
frozenset({'t', 'r', 's', 'p', 'v', 'a', 'n', 'u', 'x', 'c'})
>>> wn.synsets(pos='b') # b is not a defined part of speech
[]
from wn.
Since support for non-wordnet POS schemes is not currently part of the roadmap, so I will close this as wontfix.
from wn.
Related Issues (20)
- Generalize glob-search for lexicon/project specifiers
- Syntactic behaviours not being properly added
- If you try to loop through senses first, hypernym_paths() hangs HOT 5
- Document "default mode" queries
- Missing Spanish definitions HOT 3
- antonyms in languages other than German and English HOT 5
- If you create an entry with an ILIDefinition, but ill.id='' you lose the definition HOT 2
- Tracing back 'inferred' synsets to their reference lexicons HOT 3
- Stumped by multilingual relation traversal HOT 7
- Synset.relations() for some lexicons uses synset id as relation name
- Update Python versions HOT 2
- Is there any mapping between different English wordnet? HOT 4
- synset.relations fails with a KeyError HOT 3
- Merged synsets are lost in translation HOT 8
- SQLite objects created in a thread can only be used in that same thread HOT 3
- Add OEWN 2022 to index HOT 2
- Addition to NLTK migration guide w.r.t. offsets HOT 4
- Add a `conda` install option for `wn` on conda-forge channel HOT 5
- Allow contributors to self-assign issues with GitHub workflow HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wn.