clips / clips/pattern

recursion + keyerror issue with some wordnet synsets

Open
#208 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.9k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Ran into an odd recursion and keyerror errors with a wordnet synset of "deny". Note that I abbreviated the 990 iterations of a part of the output.

[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from pattern.en import wordnet as wn
>>> from pattern import __version__ as pattver
>>> pattver
'2.6'
>>> s = wn.synsets("deny", pos="VB")
>>> print(s[4].hypernyms(recursive=True))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  **** CHUNK REPEATED 990 TIMES ****
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/__init__.py", line 244, in hypernyms
    [p.extend(s.hypernyms(True, depth)) for s in list(p)]
  **** CHUNK REPEATED 990 TIMES ****
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/__init__.py", line 236, in hypernyms
    p = [Synset(p.getTarget()) for p in self._synset.getPointers(wn.HYPERNYM)]
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 722, in getTarget
    synset = getSynset(self.pos, self.targetOffset)
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 1090, in getSynset
    return _dictionaryFor(pos).getSynset(offset)
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 827, in getSynset
    return _entityCache.get((pos, offset), loader)
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 1310, in get
    if value == None:
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 472, in __cmp__
    return _compareInstances(self, other, ('pos', 'offset'))
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 1108, in _compareInstances
    elif a.__class__ != b.__class__:
RuntimeError: maximum recursion depth exceeded in cmp
>>> print(s[4].hypernyms(recursive=True))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/__init__.py", line 244, in hypernyms
    [p.extend(s.hypernyms(True, depth)) for s in list(p)]
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/__init__.py", line 236, in hypernyms
    p = [Synset(p.getTarget()) for p in self._synset.getPointers(wn.HYPERNYM)]
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 722, in getTarget
    synset = getSynset(self.pos, self.targetOffset)
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 1090, in getSynset
    return _dictionaryFor(pos).getSynset(offset)
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 827, in getSynset
    return _entityCache.get((pos, offset), loader)
  File "[HOME_DIR]/anaconda/envs/snorkel/lib/python2.7/site-packages/pattern/text/en/wordnet/pywordnet/wordnet.py", line 1309, in get
    del this.history[timestamp]
KeyError: 1003 

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported calls with pattern.en.wordnet, especially s[4].hypernyms(recursive=True) for "deny" with pos="VB". Read pattern/text/en/wordnet/init.py around Synset.hypernyms and pywordnet/wordnet.py around getTarget, getSynset, and _entityCache.get. Done means the recursion and KeyError are resolved for this reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.