ich meine nltk Python-Programm auf einem anderen Computer laufen und es funktioniert gut, aber auf meinem Computer ich diese Fehler bekommen:Indexerror: Stringindex
Connected to pydev debugger (build 163.10154.50)
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pydev\pydevd.py", line 1596, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pydev\pydevd.py", line 974, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:/Text Mining/Text mining-20161123T063352Z/Text mining/SentAnal/SentimentAnalysis.py", line 151, in <module>
analyze()
File "D:/Text Mining/Text mining-20161123T063352Z/Text mining/SentAnal/SentimentAnalysis.py", line 135, in analyze
negativeFeatures, positiveFeatures = process_categories()
File "D:/Text Mining/Text mining-20161123T063352Z/Text mining/SentAnal/SentimentAnalysis.py", line 119, in process_categories
words = stem_words(words)
File "D:/Text Mining/Text mining-20161123T063352Z/Text mining/SentAnal/SentimentAnalysis.py", line 37, in stem_words
words2.append(porter.stem(word))
File "C:\Python27\lib\site-packages\nltk\stem\porter.py", line 665, in stem
stem = self._step1b(stem)
File "C:\Python27\lib\site-packages\nltk\stem\porter.py", line 376, in _step1b
lambda stem: (self._measure(stem) == 1 and
File "C:\Python27\lib\site-packages\nltk\stem\porter.py", line 258, in _apply_rule_list
if suffix == '*d' and self._ends_double_consonant(word):
File "C:\Python27\lib\site-packages\nltk\stem\porter.py", line 214, in _ends_double_consonant
word[-1] == word[-2] and
IndexError: string index out of range
Process finished with exit code 1
auf beiden Computern Ich bin mit Python 2.7.13 und Pycharm Community Edition.
Was könnte die Ursache sein? Vielen Dank!
Ziemlich klar von dem Fehler. 'word [-1] == word [-2]' Die Variable 'world' hat weniger als 2 Elemente. –
Ich weiß nicht, was genau Wort ist, aber es klingt, dass das Wort nur ein Zeichen hat –