Search code examples
javascalastanford-nlp

Invalid Stream header with Stanford nlp library


I am working through this Stanford POS tagger tutorial. I am doing it in Scala but I do not think that this matters.

The line that produces the error is

val tagger=new MaxentTagger("/Users/user1/Documents/taggers/left3words-wsj-0-18.tagger")

and the error is

edu.stanford.nlp.io.RuntimeIOException: java.io.StreamCorruptedException: invalid stream header: 0003CBE8

The filepath is correct.


Solution

  • By default the tagger treats the model file path as a classpath-relative resource path, but it also accepts a fully qualified URL:

    val tagger=new MaxentTagger("file:/Users/user1/Documents/taggers/left3words-wsj-0-18.tagger")