情感分析无法连接LM(Loughran and McDonald)词典,即ps.LM()

2024-10-01 09:21:04 发布

您现在位置:Python中文网/ 问答频道 /正文

https://github.com/hanzhichao2000/pysentiment是我试图为我工作的代码,因为我想评估一段文本是正的还是负的。在

我真的不明白为什么它不起作用,如果有人能给我任何建议,我会很高兴的。(这可能与我在学校电脑上运行这一点有关,我需要它在那里工作,也就是说,到python(2.7)的路径不像通常那样简单,因此我下载文件夹,而不是做pip安装或类似操作,并将它们添加到Lib文件夹中)

我把整个错误代码放在下面,因为我不知道什么是最相关的。谢谢您!在

import pysentiment as ps

lm = ps.LM()
Traceback (most recent call last):

  File "<ipython-input-16-cd6a13354c8a>", line 1, in <module>
    lm = ps.LM()

  File "pysentiment\base.py", line 57, in __init__
    self.init_dict()

  File "pysentiment\lm.py", line 20, in init_dict
    terms = data['Word'][data[category] > 0]

  File "C:\ProgramData\App-V\6F9A7389-FA64-4C13-A3B9-539B0D5EBBE5\8405BD12-8798-436E-AEE5-B79704BB086F\Root\VFS\AppVPackageDrive\Python27\lib\site-packages\pandas\core\frame.py", line 1797, in __getitem__
    return self._getitem_column(key)

  File "C:\ProgramData\App-V\6F9A7389-FA64-4C13-A3B9-539B0D5EBBE5\8405BD12-8798-436E-AEE5-B79704BB086F\Root\VFS\AppVPackageDrive\Python27\lib\site-packages\pandas\core\frame.py", line 1804, in _getitem_column
    return self._get_item_cache(key)

  File "C:\ProgramData\App-V\6F9A7389-FA64-4C13-A3B9-539B0D5EBBE5\8405BD12-8798-436E-AEE5-B79704BB086F\Root\VFS\AppVPackageDrive\Python27\lib\site-packages\pandas\core\generic.py", line 1084, in _get_item_cache
    values = self._data.get(item)

  File "C:\ProgramData\App-V\6F9A7389-FA64-4C13-A3B9-539B0D5EBBE5\8405BD12-8798-436E-AEE5-B79704BB086F\Root\VFS\AppVPackageDrive\Python27\lib\site-packages\pandas\core\internals.py", line 2851, in get
    loc = self.items.get_loc(item)

  File "C:\ProgramData\App-V\6F9A7389-FA64-4C13-A3B9-539B0D5EBBE5\8405BD12-8798-436E-AEE5-B79704BB086F\Root\VFS\AppVPackageDrive\Python27\lib\site-packages\pandas\core\index.py", line 1572, in get_loc
    return self._engine.get_loc(_values_from_object(key))

  File "pandas\index.pyx", line 134, in pandas.index.IndexEngine.get_loc (pandas\index.c:3824)

  File "pandas\index.pyx", line 154, in pandas.index.IndexEngine.get_loc (pandas\index.c:3704)

  File "pandas\hashtable.pyx", line 686, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12280)

  File "pandas\hashtable.pyx", line 694, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12231)

KeyError: 'Word'

Tags: inpyselfapppandasgetindexline