Hello,
i am getting a strange error during the compiling of a NER model.
Basically, the end of the build output is:
98: ... loglikelihood=-13340.018762351776 0.999005934601099
99: ... loglikelihood=-13258.358751926637 0.9990120681028991
100: ... loglikelihood=-13178.039964721707 0.9990177634974279
Exception in thread "main" java.lang.IllegalStateException: Missing
serializer for *mydictionary*
at opennlp.tools.util.model.BaseModel.serialize(BaseModel.java:610)
Where "mydictionary" is the key of my custom dictionary (that i add on the
resources)
I load the dictionary with this code:
HashMap<String, Object> map = new HashMap<>();
try (InputStream modelIn = new
FileInputStream("/home/damiano/mydictionary.xml")) {
Dictionary dictionary = new Dictionary(modelIn);
map.put("mydictionary", dictionary);
}
catch(Exception e) {
System.out.println(e.getMessage());
}
Then i create the TokenNameFinderFactory with:
TokenNameFinderFactory factory = new TokenNameFinderFactory(
IOUtils.toByteArray(in),
map,
new BioCodec()
);
where "*in"* is the InputStream of my featuregenerators.xml
and map is the Map with my resources.
then train the model with:
TokenNameFinderModel model = NameFinderME.train("it", "person",
sampleStream, TrainingParameters.defaultParams(), factory);
at the end i serialize the model doing:
try (BufferedOutputStream modelOut = new BufferedOutputStream(new
FileOutputStream(outputFile.toFile()))) {
model.serialize(modelOut);
}
As i wrote at the beginning it cant serialize my dictionary so the build of
the model does not finish properly.
I read that a Dictionary can be serialized, so why this error?
Thank you!
Damiano