Skip to content

wordnet issues #64

Closed
Closed

Description

@christiaanw

I've made a fresh install of pattern-master yesterday and I'm running into issues with wordnet:

from pattern.en import wordnet
wordnet.synsets("train")

Traceback (most recent call last):
File "<pyshell#2>", line 1, in
wordnet.synsets("train")
File "/usr/local/lib/python2.7/dist-packages/pattern/en/wordnet/init.py", line 95, in synsets
return [Synset(s.synset) for i, s in enumerate(w)]
File "/usr/local/lib/python2.7/dist-packages/pattern/en/wordnet/pywordnet/wordnet.py", line 316, in getitem
return self.getSenses()[index]
File "/usr/local/lib/python2.7/dist-packages/pattern/en/wordnet/pywordnet/wordnet.py", line 242, in getSenses
self._senses = tuple(map(getSense, self._synsetOffsets))
File "/usr/local/lib/python2.7/dist-packages/pattern/en/wordnet/pywordnet/wordnet.py", line 241, in getSense
return getSynset(pos, offset)[form]
File "/usr/local/lib/python2.7/dist-packages/pattern/en/wordnet/pywordnet/wordnet.py", line 1090, in getSynset
return _dictionaryFor(pos).getSynset(offset)
File "/usr/local/lib/python2.7/dist-packages/pattern/en/wordnet/pywordnet/wordnet.py", line 827, in getSynset
return _entityCache.get((pos, offset), loader)
File "/usr/local/lib/python2.7/dist-packages/pattern/en/wordnet/pywordnet/wordnet.py", line 1308, in get
value = loadfn and loadfn()
File "/usr/local/lib/python2.7/dist-packages/pattern/en/wordnet/pywordnet/wordnet.py", line 826, in loader
return Synset(pos, offset, _lineAt(dataFile, offset))
File "/usr/local/lib/python2.7/dist-packages/pattern/en/wordnet/pywordnet/wordnet.py", line 366, in init
(self._senseTuples, remainder) = _partition(tokens[4:], 2, string.atoi(tokens[3], 16))
File "/usr/lib/python2.7/string.py", line 403, in atoi
return _int(s, base)
ValueError: invalid literal for int() with base 16: '@'

this is happening in interactive use in IDLE.

When running 06-example.py from the location of the unzipped download I get an error at a later moment:

Traceback (most recent call last):
File "/home/christiaan/Downloads/pattern-master/examples/03-en/06-wordnet.py", line 46, in
s.append((a.similarity(b), word))
File "../../pattern/text/en/wordnet/init.py", line 272, in similarity
lin = 2.0 * log(lcs(self, synset).ic) / (log(self.ic * synset.ic) or 1)
ValueError: math domain error

by the class function Synset.similarity, probably when it has to calculate the log of a negative number when working with the synsets for the words 'cat' and 'spaghetti'. Unfortunately for me this is exactly the function I'm interested in. I can see a temporary workaround for me by placing the pattern modules on the path of my project and adding in a try... except block to circumvent the ValueError, but it looks like something's broken in the wordnet implementation, although the first issue might just be a problem for my system setup/messy clips-pattern version updates.

Activity

  1. city-in-the-sky commented on Feb 10, 2014

    @city-in-the-sky
    Member

    I fixed the second issue, which was indeed a bug with a log(0). If you use the latest revision the problem should go away.

    The first issue was also mentioned a couple of years ago, and should have been fixed then. I tested on Mac, Windows and Ubuntu and I could not reproduce the error. What version of Pattern are you using?

    Try printing the output of this line in the source code:
    https://github.com/clips/pattern/blob/master/pattern/text/en/wordnet/pywordnet/wordnet.py#L1137

    It should be a sorted list with data.noun1 first and data.noun2 second.

    Let me know,
    Tom

  2. christiaanw commented on Feb 11, 2014

    @christiaanw
    Author

    I'm using 2.6. I've installed the latest revision now and when executing /examples/06-wordnet.py from the unzipped download it finishes correctly. I am however still getting the first issue when running the file from outside the package. The above line suggested yields a list with data.adj first and data.adv second. I have to manually define WNSEARCHDIR (WNHOME is set corrrectly in the environment variables) for this to work, and filenameroot = ""

  3. hayd commented on Nov 1, 2014

    @hayd

    pywordnet is now part of NLTK http://osteele.com/projects/pywordnet/

    we should check what patches have been made (were they ported upstream) and see if we can add nltk should be a dependancy (?).

  4. markus-beuckelmann commented on Aug 14, 2017

    @markus-beuckelmann
    Collaborator

    For future reference: Done as of ad3d72c, 190cb3d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions