Giter Club home page Giter Club logo

Comments (6)

goodmami avatar goodmami commented on July 24, 2024 1

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.

goodmami avatar goodmami commented on July 24, 2024

@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.

LifeIsStrange avatar LifeIsStrange commented on July 24, 2024

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.

mintaka5 avatar mintaka5 commented on July 24, 2024

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.

goodmami avatar goodmami commented on July 24, 2024

@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.

goodmami avatar goodmami commented on July 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.