nltk StanfordNERTagger : NoClassDefFoundError: org/slf4j/LoggerFactory (In Windows)

后端 未结 9 2063
轮回少年
轮回少年 2020-12-15 09:43

NOTE: I am using Python 2.7 as part of Anaconda distribution. I hope this is not a problem for nltk 3.1.

I am trying to use nltk for NER as

import nl         


        
9条回答
  •  时光取名叫无心
    2020-12-15 10:27

    For those who want to use Stanford NER >= 3.6.0 instead of the 2015-01-30 (3.5.1) or other old version, do this instead:

    1. Put the stanford-ner.jar and slf4j-api.jar into the same folder

      For example, I put the following files to /path-to-libs/

      • stanford-ner-3.6.0.jar
      • slf4j-api-1.7.18.jar
    2. Then:

      classpath = "/path-to-libs/*"
      
      st = nltk.tag.StanfordNERTagger(
          "/path-to-model/ner-model.ser.gz",
          "/path-to-libs/stanford-ner-3.6.0.jar"
      )
      st._stanford_jar = classpath
      result = st.tag(["Hello"])
      

提交回复
热议问题