YayaYaya YayaYaya - 6 months ago 11
Python Question

arabic stemmer doesnt work for sentences

I have python 2.7 and i installed this , I have this code :

from snowballstemmer import stemmer
ar_stemmer = stemmer("arabic")
stem = ar_stemmer.stemWord(u"مكتبة لمعالجةالكلمات العربية وتجذيعها ")
print stem


When i run it, i get the same sentence without stem مكتبة لمعالجة الكلمات العربية وتجذيعها , so what should i change ?

Answer

Split the sentence on words like this:

from snowballstemmer import stemmer
ar_stemmer = stemmer("arabic")
sentence = u"مكتبة لمعالجة الكلمات العربية وتجذيعها"
for word in sentence.split(" "):
    stem = ar_stemmer.stemWord(word)
    print stem
Comments