Hello,
could someone explain how to add a dictionary resource during the train of
a NER model?

At the moment i add a map of resources doing:

try (InputStream modelIn = new FileInputStream("/home/damiano/fake.xml")) {
Dictionary dictionary = new Dictionary(modelIn);

map.put("damiano", dictionary);
}

TokenNameFinderFactory factory = new TokenNameFinderFactory(
IOUtils.toByteArray(in),
map,
new BioCodec()
);

then i can use "damiano" dictionary on my custom FeatureGenerator.
Example:


public class SpanWindowFeatureGenerator extends CustomFeatureGenerator
    implements ArtifactToSerializerMapper {

    @Override
    public void init(Map<String, String> properties,
FeatureGeneratorResourceProvider resourceProvider) throws
InvalidFormatException {

        Dictionary dic = (Dictionary)
resourceProvider.getResource("damiano");
        // I can read it. It works!

    }

}

the problem is when i try to build the NER model (.bin).

OpenNLP does not find a serializer for my Dictionary "damiano".
When i add a resource i only can save the name (key) and the Object, how
can i set the serializer too?

Damiano

Reply via email to