nltk.download('wordnet') is giving "ParseError: mismatched tag: line 33, column 2" on Python 3.10

huangapple go评论54阅读模式
英文:

nltk.download('wordnet') is giving "ParseError: mismatched tag: line 33, column 2" on Python 3.10

问题

使用nltk.stem.WordNetLemmatizer()时,我遇到了以下错误。

LookupError: 
**********************************************************************
  找不到资源 wordnet。
  请使用 NLTK 下载器获取该资源:

  >>> import nltk
  >>> nltk.download('wordnet')
  
  更多信息请参阅:https://www.nltk.org/data.html

当我运行以下代码时

import nltk
nltk.download('wordnet')

我遇到了以下解析错误

Traceback (most recent call last):

  File ~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py:3460 in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  Cell In[32], line 2
    nltk.download('wordnet')

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:777 in download
    for msg in self.incr_download(info_or_id, download_dir, force):

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:629 in incr_download
    info = self._info_or_id(info_or_id)

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:603 in _info_or_id
    return this.info(info_or_id)

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:1009 in info
    self._update_index()

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:952 in _update_index
    ElementTree.parse(urlopen(self._url)).getroot()

  File ~\Anaconda3\lib\xml\etree\ElementTree.py:1222 in parse
    tree.parse(source, parser)

  File ~\Anaconda3\lib\xml\etree\ElementTree.py:580 in parse
    self._root = parser._parse_whole(source)

  File <string>
ParseError: mismatched tag: line 33, column 2

我最初在Jupyter Notebook中运行了此代码,重启了内核并尝试了再次运行。我还尝试在Python解释器中运行它。每次都给我同样的错误。

nltk 版本是 3.7

英文:

In attempting to use nltk.stem.WordNetLemmatizer() I get the error below.

LookupError: 
**********************************************************************
  Resource wordnet not found.
  Please use the NLTK Downloader to obtain the resource:

  &gt;&gt;&gt; import nltk
  &gt;&gt;&gt; nltk.download(&#39;wordnet&#39;)
  
  For more information see: https://www.nltk.org/data.html

When I go to run this

import nltk
nltk.download(&#39;wordnet&#39;)

I get this Parse Error

Traceback (most recent call last):

  File ~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py:3460 in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  Cell In[32], line 2
    nltk.download(&#39;wordnet&#39;)

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:777 in download
    for msg in self.incr_download(info_or_id, download_dir, force):

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:629 in incr_download
    info = self._info_or_id(info_or_id)

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:603 in _info_or_id
    return self.info(info_or_id)

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:1009 in info
    self._update_index()

  File ~\Anaconda3\lib\site-packages\nltk\downloader.py:952 in _update_index
    ElementTree.parse(urlopen(self._url)).getroot()

  File ~\Anaconda3\lib\xml\etree\ElementTree.py:1222 in parse
    tree.parse(source, parser)

  File ~\Anaconda3\lib\xml\etree\ElementTree.py:580 in parse
    self._root = parser._parse_whole(source)

  File &lt;string&gt;
ParseError: mismatched tag: line 33, column 2

I ran the code in Jupyter Notebook originally, restarted the kernel and tried again. I also tried running it in the Python interpreter. Every time has given me the same error.

nltk version is 3.7

答案1

得分: 0

可能有其他解决方案来解决我的问题,我最终采取的方法是手动从https://www.nltk.org/nltk_data/下载WordNet,并将文件保存在文档所指示的位置(C:\nltk_data\corpora\wordnet)。

英文:

There may be other solutions to my issue, what I ended up doing to solve this problem was manually downloading wordnet from https://www.nltk.org/nltk_data/ and saving the file where the documentation tells you to (C:\nltk_data\corpora\wordnet)

huangapple
  • 本文由 发表于 2023年8月4日 20:40:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76836010.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定