aboSamoor / polyglot

Multilingual text (NLP) processing toolkit
http://polyglot-nlp.com
Other
2.29k stars 337 forks source link

I get list index out of range when calling sentiment for different language #217

Open NaveenSrikanthD opened 4 years ago

NaveenSrikanthD commented 4 years ago

from polyglot.text import Text blob=b'contact avec notre facteur ainsi que la livraison des colis good excellent' text=Text(blob)

res=text.entities[0]

print("{:<16}{}".format("Word", "Polarity")+"\n"+"-"*30) for w in text.words[:]: print("{:<16}{:>2}".format(w, w.polarity)) first_sentences=text.sentences[0] first_entity=first_sentences.entities[0]

Below is my output Word Polarity

contact 0 avec 0 notre 0 facteur 0 ainsi 0 que 0 la 0 livraison 0 des 0 colis 0 good 1 excellent 1

IndexError Traceback (most recent call last)

in 7 print("{:<16}{:>2}".format(w, w.polarity)) 8 first_sentences=text.sentences[0] ----> 9 first_entity=first_sentences.entities[0] IndexError: list index out of range I see it is running only for english text