【问题标题】:ValueError with nltk on python 3.6 Windows在 python 3.6 Windows 上使用 nltk 的 ValueError
【发布时间】:2018-02-08 05:51:23
【问题描述】:

试图运行

wordnet.synsets('table')

从 Windows 上的 Python 3.6 得到

     File "<stdin>", line 1, in <module>
  File "C:\Users\Leti\Anaconda3\envs\DeepVis\lib\site-packages\nltk\corpus\reader\wordnet.py", line 1424, in synsets
    for p in pos
  File "C:\Users\Leti\Anaconda3\envs\DeepVis\lib\site-packages\nltk\corpus\reader\wordnet.py", line 1426, in <listcomp>
    for offset in index[form].get(p, [])]
  File "C:\Users\Leti\Anaconda3\envs\DeepVis\lib\site-packages\nltk\corpus\reader\wordnet.py", line 1280, in _synset_from_pos_and_offset
    synset = self._synset_from_pos_and_line(pos, data_file_line)
  File "C:\Users\Leti\Anaconda3\envs\DeepVis\lib\site-packages\nltk\corpus\reader\wordnet.py", line 1381, in _synset_from_pos_and_line
    raise WordNetError('line %r: %s' % (data_file_line, e))
nltk.corpus.reader.wordnet.WordNetError: line 'tted dalmatian  \r\n': not enough values to unpack (expected 2, got 1)

在 Linux 上它工作得很好!

有人知道发生了什么吗?

【问题讨论】:

    标签: windows python-3.x nltk wordnet valueerror


    【解决方案1】:

    尝试通过UltraEdit或notepad++等工具将文件nltk_data\corpora\wordnet\data.noun格式转换为Unix(编辑-->EOL转换-->Unix(LF))

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多