[Snowball-discuss] PyStemmer: " 'dict' object has no attribute 'iteritems'" on Python 3

Marc Abramowitz marca at surveymonkey.com
Thu Feb 21 20:13:25 GMT 2013


Thank you for PyStemmer!

I tried to use PyStemmer-1.2.0 on Python 3.3. It imported and basically worked for a few examples, but if I call it in a loop for a large number of words, I get the following error on the 10,000th iteration:

```
    word = stemmer.stemWord(word)
  File "Stemmer.pyx", line 195, in Stemmer.Stemmer.stemWord (src/Stemmer.c:1657)
  File "Stemmer.pyx", line 159, in Stemmer.Stemmer.__purgeCache (src/Stemmer.c:1216)
AttributeError: 'dict' object has no attribute 'iteritems'
```

This error is probably easy to fix. In Python 3, the dict no longer has the "iteritems" method; you simply use "items" (which is lazy in Python 3) instead.This could be fixed  by modifying the code or having the setup.py specify `use_2to3=True`, etc.

I then wondered if there was already a fix for this issue in the svn trunk for this as PyStemmer-1.2.0 was released on PyPI in 2011. I checked out the source code from svn://svn.tartarus.org/snowball/trunk/pystemmer/ but if I try to do `python setup.py build` or `python setup.py install`, I get this error:

```
Traceback (most recent call last):
  File "setup.py", line 21, in <module>
    for line in open(os.path.join(library_dir, 'mkinc_utf8.mak'))
IOError: [Errno 2] No such file or directory: 'libstemmer_c/mkinc_utf8.mak'
```

So I wonder if there might be another release of PyStemmer on PyPI with improved Python 3 support? I'm also curious how to install from svn and get around the missing file error. If I can get past the installation error and there is no fix for this issue yet, I might be able to send a patch with a fix.

Thanks,
Marc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tartarus.org/mailman/private/snowball-discuss/attachments/20130221/1f3e3ba5/attachment.htm>


More information about the Snowball-discuss mailing list