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.