NLTK was unable to find stanford-postagger.jar! Set the CLASSPATH environment variable

前端 未结 2 747
孤街浪徒
孤街浪徒 2021-02-19 20:37

I am working on a project that requires me to tag tokens using nltk and python. So I wanted to use this. But came up with a few problems. I went through a lot of other already a

2条回答
  •  面向向阳花
    2021-02-19 20:59

    I use Jupyter Notebook with Pycharm. I tried the Run Configuration in Pycharm to set env variable, but not work. So I use os.environ to set it in the code:

    import os
    
    os.environ["CLASSPATH"] = "/yourPath/stanford-parser-full-2018-10-17:yourPath/stanford-postagger-full-2018-10-16:yourPath/stanford-ner-2018-10-16"
    os.environ["STANFORD_MODELS"] = "yourPath/stanford-postagger-full-2018-10-16/models:yourPath/stanford-ner-2018-10-16/classifiers"
    
    stanford_tagger = StanfordPOSTagger('english-bidirectional-distsim.tagger')
    

    Hope it will help!

提交回复
热议问题