【问题标题】:Is there any way to add a new location to the list of places where nltk looks for the wordnet corpus?有什么方法可以将新位置添加到 nltk 查找 wordnet 语料库的位置列表中?
【发布时间】:2012-10-21 16:16:06
【问题描述】:

由于访问权限问题,我无法在我的大学计算机上下载 wordnet 语料库,因此我无法使用 nltk wordnet lemmatizer。

我尝试这样做时收到以下错误:

**********************************************************************   Resource 'corpora/wordnet' not found.  Please use the NLTK   Downloader to obtain the resource:  >>> nltk.download()   Searched in:
    - '/home/XX/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
**********************************************************************

当我在家里遇到同样的问题时,我可以通过两种方式解决它:

  1. 使用 nltk.download(),标准方式和
  2. 在 /home/XX/nltk_data 位置创建一个新文件夹,然后将语料库目录粘贴到其中。

现在在大学里,我只能访问 /home/XX/bin 而不能直接访问 /home/XX。那么我是否可以将 wordnet 语料库粘贴到 /home/XX/bin 中,然后以某种方式让 nltk 在该文件夹中查找语料库?

【问题讨论】:

    标签: python ubuntu nltk


    【解决方案1】:

    设置NLTK_DATA environment variable:

    export NLTK_DATA=/path/to/nltk_data
    

    【讨论】:

      【解决方案2】:

      virtualenv 在这种情况下也是一种选择。

      【讨论】:

        猜你喜欢
        • 2016-07-09
        • 1970-01-01
        • 1970-01-01
        • 2014-07-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-03-19
        • 2021-06-05
        相关资源
        最近更新 更多