Rebuild OPENNLP Error

I am trying to train a name entity model using OpenNLP, but getting this error does not know what is missing. I'm new to this OPENNLP, anyone, please help, can provide the Train.txt file if necessary

lineStream = opennlp.tools.util.PlainTextByLineStream@b52598
Indexing events using cutoff of 0

Computing event counts...  done. 514 events
Indexing...  done.
Sorting and merging events... done. Reduced 514 events to 492.
Done indexing.
Incorporating indexed data for training...  
done.
Number of Event Tokens: 492
    Number of Outcomes: 1
  Number of Predicates: 3741
...done.
Computing model parameters ...
Performing 1 iterations.
1:  ... loglikelihood=0.0   1.0
Exception in thread "main" java.lang.IllegalArgumentException: Model not compatible with     name finder!
at opennlp.tools.namefind.TokenNameFinderModel.<init>(TokenNameFinderModel.java:81)
at opennlp.tools.namefind.TokenNameFinderModel.<init>(TokenNameFinderModel.java:106)
at opennlp.tools.namefind.NameFinderME.train(NameFinderME.java:374)
at opennlp.tools.namefind.NameFinderME.train(NameFinderME.java:432)
at opennlp.tools.namefind.NameFinderME.train(NameFinderME.java:443)
at Train2.main(Train2.java:36)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)

My code is

    File fileTrainer=new File("/home/ashfaq/Documents/Train.txt");
    File output=new File("/home/ashfaq/Documents/trainedModel.bin");
    ObjectStream<String> lineStream = new PlainTextByLineStream(new    FileInputStream(fileTrainer), "UTF-8");
    ObjectStream<NameSample> sampleStream = new NameSampleDataStream(lineStream);
    System.out.println("lineStream = " + lineStream);
    TokenNameFinderModel model = NameFinderME.train("en", "location", sampleStream, Collections.<String, Object>emptyMap(), 1, 0);

    BufferedOutputStream modelOut = null;
    try {
        modelOut = new BufferedOutputStream(new FileOutputStream(output));
        model.serialize(modelOut);
    } finally {
        if (modelOut != null)
            modelOut.close();
    }
+4
source share
2 answers

I know that aeons asked it back, I ran into a similar categorization problem in which the corresponding restriction solved my problem. Therefore, if you give circumcision as 1, this may help (disclaimer: - I have not tested it)

If you want to keep the default cutoff (which is 5), you must train it at least 5 times in order to recognize

0
source

- . ,

<START:person>bob<END> 
will fail but 
<START:person> bob <END> 
will succeed.

, . , , .. , \n \n

+14

All Articles