Can't make Stanford POS tagger working in nltk

后端 未结 2 1817
夕颜
夕颜 2021-01-03 02:31

I\'m trying to work with Stanford POS tagger within NLTK. I\'m using the example shown here:

http://www.nltk.org/api/nltk.tag.html#module-nltk.tag.stanford

I

相关标签:
2条回答
  • 2021-01-03 02:37

    Lot has changed since this solution.Here is my solution to the code,after I too faced the error.Basically increasing JAVA heapsize solved it.

    import os
    java_path = "C:\\Program Files\\Java\\jdk1.8.0_102\\bin\\java.exe"
    os.environ['JAVAHOME'] = java_path
    
    from nltk.tag.stanford import StanfordPOSTagger
    path_to_model = "stanford-postagger-2015-12-09/models/english-bidirectional-distsim.tagger"
    path_to_jar = "stanford-postagger-2015-12-09/stanford-postagger.jar"
    tagger=StanfordPOSTagger(path_to_model, path_to_jar)
    tagger.java_options='-mx4096m'          ### Setting higher memory limit for long sentences
    sentence = 'This is testing'
    print tagger.tag(sentence.split())
    
    0 讨论(0)
  • 2021-01-03 02:57

    The best thing to do is simply to download the latest version of the Stanford POS tagger where the dependency problem is now fixed (March 2018).

    wget https://nlp.stanford.edu/software/stanford-postagger-full-2017-06-09.zip
    
    0 讨论(0)
提交回复
热议问题