1

I installed this stemmer for arabic language Here. I was running it with this code :

from snowballstemmer import stemmer
ar_stemmer = stemmer("arabic")
ar_stemmer.stemWord(u"فسميتموها")

And when I run it, I get this :

Traceback (most recent call last):
File "C:\Users\CLIENT\Desktop\snowballstemmer-1.1.0.tar\snowballstemmer-   1.1.0\stemmer.py", line 9, in <module>
ar_stemmer = stemmer("arabic")
File "C:\Anaconda2\lib\site-packages\snowballstemmer\__init__.py", line 57,   in stemmer
raise KeyError("Stemming algorithm '%s' not found" % lang)
KeyError: "Stemming algorithm 'arabic' not found"
Assem
  • 11,574
  • 5
  • 59
  • 97
YayaYaya
  • 125
  • 2
  • 3
  • 10

2 Answers2

2

Don't install the version of snowballstemmer from PyPi cause it doesn't support Arabic yet. Install the version provided in the link. It has this Arabic stemmer inside. You can do this by downloading the tarball and execute the setup.py:

sudo python setup.py install

Here is an example:

>>> from snowballstemmer import stemmer
>>> ar_stemmer = stemmer("arabic")
>>> stem = ar_stemmer.stemWord(u"فسميتموها")
>>> print stem
سمي
>>> stem
u'\u0633\u0645\u064a'
Assem
  • 11,574
  • 5
  • 59
  • 97
1

I once worked with SnowballStemmer, this was the way it worked for me:

>>> from nltk.stem import SnowballStemmer
>>> print(" ".join(SnowballStemmer.languages)) # See which languages are supported
danish dutch english finnish french german hungarian
italian norwegian porter portuguese romanian russian
spanish swedish
>>> stemmer = SnowballStemmer("german") # Choose a language
>>> stemmer.stem("Autobahnen") # Stem a word
'autobahn'

I'm not sure if arabic works here

Matthias Burger
  • 5,549
  • 7
  • 49
  • 94