我在另一台计算机上运行我的nltk python程序并且工作正常,但在我的计算机上我遇到了这些错误:
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
在两台计算机上,我使用的是Python 2.7.13和Pycharm Community Edition。
可能是什么原因?谢谢!
答案 0 :(得分:0)
您正在处理的数据在两台计算机上是不同的。数据集中可能有一个单词,您的机器上只有一个字母。