btru
btru

Reputation: 129

OpenNLP model version 1.5.0 not supported by 0.0.0-SNAPSHOT

I'm trying to try a sample in the manual with OpenNLP (first time ever using it).

For some reason this:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import java.io.InputStream;

import opennlp.tools.sentdetect.SentenceDetectorME;
import opennlp.tools.sentdetect.SentenceModel;

public class Main {

/**
 * @param args
 */
public static void main(String[] args) {
    //-------------------------------------------------------------Check for input text file.
    if(args == null){
        System.out.print("hello");
    }
    
    //------------------------------------------------------------------Main algorithm
    else  {
        InputStream modelIn = null;
        
        SentenceModel model = null;
        
        try {
            modelIn = new FileInputStream("./src/train/en-sent.bin");
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }
        
        try {
            model = new SentenceModel(modelIn);
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            if (modelIn != null) {
                try {
                    modelIn.close();
                }
                catch (IOException e) {
                }
            }
            
        }
        SentenceDetectorME sentenceDetector = new SentenceDetectorME(model);
        
        String sentences[] = sentenceDetector.sentDetect("  First sentence. Second sentence. ");
        
        System.out.print(sentences[0]);
    }
        
        
    }

}

Gets an error:

opennlp.tools.util.InvalidFormatException: Model version 1.5.0 is not supported by this (0.0.0-SNAPSHOT) version of OpenNLP!
at opennlp.tools.util.model.BaseModel.validateArtifactMap(BaseModel.java:235)
at opennlp.tools.sentdetect.SentenceModel.validateArtifactMap(SentenceModel.java:78)
at opennlp.tools.util.model.BaseModel.<init>(BaseModel.java:142)
at opennlp.tools.sentdetect.SentenceModel.<init>(SentenceModel.java:73)
at Main.main(Main.java:34)

I haven't the slightest idea why this is occurring... It says here that 0.0.0-SNAPSHOT version of OpenNLP should never fail loading any models.

I haven't been able to find any other information on this error so far. It's probably something I did with the imports? or the model I'm using (I downloaded it from the OpenNLP website --- couldn't find any other version)? Regardless, I have no idea what's wrong...

Any ideas or help would be appreciated.

additional info: I'm using OpenNLP 1.5.2 incubating and the 1.5 model (project website says it should be completely compatible) on Ubuntu 12.04. And I'm not sure if this has any significance but I'm using Eclipse Indigo.

Upvotes: 0

Views: 641

Answers (1)

Daniel Naber
Daniel Naber

Reputation: 1654

One such bug (OPENNLP-406) was only fixed after 1.5.2-incubating. But your issue might be a classpath problem. OpenNLP takes its version from a file opennlp.version somewhere in your classpath. You might have none or more than one such file, confusing OpenNLP.

Upvotes: 1

Related Questions