Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[java-nlp-user] 答复: NER - CRFClassifier Classes

Gerber Daniel dgerber at informatik.uni-leipzig.de
Fri Apr 8 02:20:24 PDT 2011


Hi John,

On 08.04.2011, at 00:22, John Bauer wrote:

> 2011/4/7 Gerber Daniel <dgerber at informatik.uni-leipzig.de>:
>> Thanks for your answer.
>> 
>> I've tried to train the classifier with my annotated file (as described at http://nlp.stanford.edu/software/crf-faq.shtml#b). This seems to work well with the Stanford NER package. However I'm using the (most-recent) Stanford-CoreNLP in my project and with this, it's not possible to train the classifier nor to load the trained one (from NER package). I'm getting this error message:
>> 
>> Exception in thread "main" java.lang.RuntimeException: java.io.InvalidClassException: edu.stanford.nlp.util.Index; local class incompatible: stream classdesc serialVersionUID = 5398562825928375260, local class serialVersionUID = 533612384823468898
>> 
>> I know multiple people dealt with this error before, but I found no real answer to my problem. Is there any way to train my model with this release?
> 
> Can you follow the same commands used to train the model with the NER
> release, but use the CoreNLP jar in the classpath instead of the NER
> jars?  It should be the case that all the code you need to train a
> model is included.

The command: 
$ java -cp stanford-corenlp-2010-11-12.jar edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier ~/ner-date-model.ser.gz -testFile ~/Date-Training.tsv

leads to the same result :( 

testFile=/Users/gerb/Date-Training.tsv
loadClassifier=/Users/gerb/ner-date-model.ser.gz
Loading classifier from /Users/gerb/ner-date-model.ser.gz ... Error deserializing /Users/gerb/ner-date-model.ser.gz
Exception in thread "main" java.lang.RuntimeException: java.io.InvalidClassException: edu.stanford.nlp.util.Index; local class incompatible: stream classdesc serialVersionUID = 5398562825928375260, local class serialVersionUID = 533612384823468898
	at edu.stanford.nlp.ie.AbstractSequenceClassifier.loadClassifierNoExceptions(AbstractSequenceClassifier.java:1223)
	at edu.stanford.nlp.ie.AbstractSequenceClassifier.loadClassifierNoExceptions(AbstractSequenceClassifier.java:1174)
	at edu.stanford.nlp.ie.crf.CRFClassifier.main(CRFClassifier.java:2293)
Caused by: java.io.InvalidClassException: edu.stanford.nlp.util.Index; local class incompatible: stream classdesc serialVersionUID = 5398562825928375260, local class serialVersionUID = 533612384823468898

> 
> 
>> One more thing: Is it somehow possible to add the trained DATE class to let's say the "conll.closed.iob2.crf"-classifier? I would really like to avoid recreating it or using different classifiers in my code?
> 
> You mean, is it possible to use part of one model and ignore the rest?
> Not without coding for that yourself.

Let me explain this in sample code:

What I don't want to do:

AbstractSequenceClassifier companyPersonLocationClassifier = CRFClassifier.getClassifierNoExceptions(companyPersonLocationModel);
AbstractSequenceClassifier dateClassifier = CRFClassifier.getClassifierNoExceptions(dateModel);

String companyPersonLocationTagged = companyPersonLocationClassifier.classify(string);
String companyPersonLocationDateTagged = dateClassifier.classify(companyPersonLocationTagged);

What I want to do:

AbstractSequenceClassifier classifier = CRFClassifier.getClassifierNoExceptions(companyPersonLocationModel);
classifier.addModel(dateModel)

String companyPersonLocationDateTagged = dateClassifier.classify(string);

> 
> John
> 




More information about the java-nlp-user mailing list