Why can i not serialize a Dictionary ?

2016-10-25 Thread Damiano Porta
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 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


Re: Custom Features Generator example

2016-10-25 Thread Damiano Porta
Joern it works perfectly! I am extending the CustomFeatureGenerator, it is
called and init() method too.
Last thing...I need to use some resources like custom dictionaries and
specific finder with many regexes, how can i store those resouces into the
model? I am configuring the generators via xml, i read that it is saved on
the model (.bin file), but, what about those custom resources? are they
saved inside the model too ?

2016-10-25 14:04 GMT+02:00 Joern Kottmann :

> You can pass in custom parameters to configure your feature generator
> (depends on what you need) via attributes on the custom element in the
> descriptor.
>
> This is optional if you don't have any parameters, you don't need to pass
> anything at all.
>
> Jörn
>
>
> On Tue, Oct 25, 2016 at 2:00 PM, Damiano Porta 
> wrote:
>
> > Oh thanks! i try.
> > If I extend the CustomFeatureGenerator what parameters should i pass?
> >
> > Il 25/Ott/2016 13:39, "Joern Kottmann"  ha scritto:
> >
> > > You need to use a constructor which is public and has no arguments.
> > >
> > > The parameters can be passed in only if you extend
> > CustomFeatureGenerator.
> > > That one has an init method which gives you the attributes defined in
> the
> > > xml descriptor.
> > >
> > > HTH,
> > > Jörn
> > >
> > > On Tue, Oct 25, 2016 at 12:43 PM, Damiano Porta <
> damianopo...@gmail.com>
> > > wrote:
> > >
> > > > Joern,
> > > > However i also tried with:
> > > >
> > > > public SpanFeatureGenerator(Map properties,
> > > > FeatureGeneratorResourceProvider resourceProvider) throws
> > > > InvalidFormatException {
> > > >
> > > > }
> > > >
> > > > but i get the same exception.
> > > > Damiano
> > > >
> > > > 2016-10-25 12:30 GMT+02:00 Damiano Porta :
> > > >
> > > > > This at the moment:
> > > > >
> > > > > public SpanFeatureGenerator(String prefix, Object finder, int
> > > > > prevWindowSize,  int nextWindowSize) {
> > > > >
> > > > > System.out.println(prefix);
> > > > > System.out.println((String)finder);
> > > > > System.out.println(prevWindowSize);
> > > > > System.out.println(nextWindowSize);
> > > > > System.exit(1);
> > > > >
> > > > > }
> > > > >
> > > > > It is obviously a test to understand if my generator is called.
> > > > >
> > > > >
> > > > > 2016-10-25 12:23 GMT+02:00 Joern Kottmann :
> > > > >
> > > > >> What is the constructor of the
> > > > >> com.damiano.parser.generator.SpanFeatureGenerator
> > > > >> class?
> > > > >>
> > > > >> Jörn
> > > > >>
> > > > >> On Tue, Oct 25, 2016 at 11:51 AM, Damiano Porta <
> > > damianopo...@gmail.com
> > > > >
> > > > >> wrote:
> > > > >>
> > > > >> > Hello,
> > > > >> > I have created a custom generator implementing the
> > > > >> AdaptiveFeatureGenerator
> > > > >> > interface.
> > > > >> >
> > > > >> > I am getting this error:
> > > > >> >
> > > > >> > Exception in thread "main"
> > > > >> > opennlp.tools.util.ext.ExtensionNotLoadedException:
> > > > >> > java.lang.InstantiationException:
> > > > >> > com.damiano.parser.generator.SpanFeatureGenerator
> > > > >> > at
> > > > >> > opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
> > > > >> > ExtensionLoader.java:72)
> > > > >> > at
> > > > >> > opennlp.tools.util.featuregen.GeneratorFactory$
> > > > >> > CustomFeatureGeneratorFactory.create(GeneratorFactory.java:582)
> > > > >> > at
> > > > >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > > > >> > GeneratorFactory.java:661)
> > > > >> > at
> > > > >> > opennlp.tools.util.featuregen.GeneratorFactory$
> > > > >> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.
> > java:129)
> > > > >> > at
> > > > >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > > > >> > GeneratorFactory.java:661)
> > > > >> > at
> > > > >> > opennlp.tools.util.featuregen.GeneratorFactory$
> > > > >> > CachedFeatureGeneratorFactory.create(GeneratorFactory.java:171)
> > > > >> > at
> > > > >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > > > >> > GeneratorFactory.java:661)
> > > > >> > at
> > > > >> > opennlp.tools.util.featuregen.GeneratorFactory$
> > > > >> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.
> > java:129)
> > > > >> > at
> > > > >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > > > >> > GeneratorFactory.java:661)
> > > > >> > at
> > > > >> > opennlp.tools.util.featuregen.GeneratorFactory.create(
> > > > >> > GeneratorFactory.java:711)
> > > > >> > at
> > > > >> > opennlp.tools.namefind.TokenNameFinderFactory.
> > > > createFeatureGenerators(
> > > > >> > TokenNameFinderFactory.java:153)
> > > > >> > at
> > > > >> > opennlp.tools.namefind.TokenNameFinderFactory.
> > > createContextGenerator(
> > > > >> > TokenNameFinderFactory.java:118)
> > > > >> > at opennlp.tools.namefind.NameFinderME.train(
> > NameFinderME.java:333)
> > > > >> > at 

Re: Custom Features Generator example

2016-10-25 Thread Damiano Porta
Oh thanks! i try.
If I extend the CustomFeatureGenerator what parameters should i pass?

Il 25/Ott/2016 13:39, "Joern Kottmann"  ha scritto:

> You need to use a constructor which is public and has no arguments.
>
> The parameters can be passed in only if you extend CustomFeatureGenerator.
> That one has an init method which gives you the attributes defined in the
> xml descriptor.
>
> HTH,
> Jörn
>
> On Tue, Oct 25, 2016 at 12:43 PM, Damiano Porta 
> wrote:
>
> > Joern,
> > However i also tried with:
> >
> > public SpanFeatureGenerator(Map properties,
> > FeatureGeneratorResourceProvider resourceProvider) throws
> > InvalidFormatException {
> >
> > }
> >
> > but i get the same exception.
> > Damiano
> >
> > 2016-10-25 12:30 GMT+02:00 Damiano Porta :
> >
> > > This at the moment:
> > >
> > > public SpanFeatureGenerator(String prefix, Object finder, int
> > > prevWindowSize,  int nextWindowSize) {
> > >
> > > System.out.println(prefix);
> > > System.out.println((String)finder);
> > > System.out.println(prevWindowSize);
> > > System.out.println(nextWindowSize);
> > > System.exit(1);
> > >
> > > }
> > >
> > > It is obviously a test to understand if my generator is called.
> > >
> > >
> > > 2016-10-25 12:23 GMT+02:00 Joern Kottmann :
> > >
> > >> What is the constructor of the
> > >> com.damiano.parser.generator.SpanFeatureGenerator
> > >> class?
> > >>
> > >> Jörn
> > >>
> > >> On Tue, Oct 25, 2016 at 11:51 AM, Damiano Porta <
> damianopo...@gmail.com
> > >
> > >> wrote:
> > >>
> > >> > Hello,
> > >> > I have created a custom generator implementing the
> > >> AdaptiveFeatureGenerator
> > >> > interface.
> > >> >
> > >> > I am getting this error:
> > >> >
> > >> > Exception in thread "main"
> > >> > opennlp.tools.util.ext.ExtensionNotLoadedException:
> > >> > java.lang.InstantiationException:
> > >> > com.damiano.parser.generator.SpanFeatureGenerator
> > >> > at
> > >> > opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
> > >> > ExtensionLoader.java:72)
> > >> > at
> > >> > opennlp.tools.util.featuregen.GeneratorFactory$
> > >> > CustomFeatureGeneratorFactory.create(GeneratorFactory.java:582)
> > >> > at
> > >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > >> > GeneratorFactory.java:661)
> > >> > at
> > >> > opennlp.tools.util.featuregen.GeneratorFactory$
> > >> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
> > >> > at
> > >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > >> > GeneratorFactory.java:661)
> > >> > at
> > >> > opennlp.tools.util.featuregen.GeneratorFactory$
> > >> > CachedFeatureGeneratorFactory.create(GeneratorFactory.java:171)
> > >> > at
> > >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > >> > GeneratorFactory.java:661)
> > >> > at
> > >> > opennlp.tools.util.featuregen.GeneratorFactory$
> > >> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
> > >> > at
> > >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > >> > GeneratorFactory.java:661)
> > >> > at
> > >> > opennlp.tools.util.featuregen.GeneratorFactory.create(
> > >> > GeneratorFactory.java:711)
> > >> > at
> > >> > opennlp.tools.namefind.TokenNameFinderFactory.
> > createFeatureGenerators(
> > >> > TokenNameFinderFactory.java:153)
> > >> > at
> > >> > opennlp.tools.namefind.TokenNameFinderFactory.
> createContextGenerator(
> > >> > TokenNameFinderFactory.java:118)
> > >> > at opennlp.tools.namefind.NameFinderME.train(NameFinderME.java:333)
> > >> > at com.damiano.parser.trainer.NER.compileNER(NER.java:161)
> > >> > at com.damiano.parser.trainer.NER.main(NER.java:136)
> > >> >
> > >> > Caused by: java.lang.InstantiationException:
> > >> > com.damiano.parser.generator.SpanFeatureGenerator
> > >> > at java.lang.Class.newInstance(Class.java:427)
> > >> > at
> > >> > opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
> > >> > ExtensionLoader.java:70)
> > >> > ... 14 more
> > >> >
> > >> > Caused by: java.lang.NoSuchMethodException:
> > >> > com.damiano.parser.generator.SpanFeatureGenerator.()
> > >> > at java.lang.Class.getConstructor0(Class.java:3082)
> > >> > at java.lang.Class.newInstance(Class.java:412)
> > >> > ... 15 more
> > >> >
> > >> > the xml is:
> > >> >
> > >> > 
> > >> >   
> > >> > 
> > >> >   
> > >> > 
> > >> >   
> > >> >   
> > >> > 
> > >> >   
> > >> >   
> > >> >   
> > >> >   
> > >> >   
> > >> >> >> > prefix="name" finder="blablabla" prevWindowSize="3"
> > nextWindowSize="3"/>
> > >> > 
> > >> >   
> > >> > 
> > >> >
> > >> > What can i do?
> > >> > Thank you!
> > >> >
> > >> > Damiano
> > >> >
> > >>
> > >
> > >
> >
>


Re: Custom Features Generator example

2016-10-25 Thread Joern Kottmann
We should probably create an example and add it to our documentation.

Jörn

On Tue, Oct 25, 2016 at 1:39 PM, Joern Kottmann  wrote:

> You need to use a constructor which is public and has no arguments.
>
> The parameters can be passed in only if you extend CustomFeatureGenerator.
> That one has an init method which gives you the attributes defined in the
> xml descriptor.
>
> HTH,
> Jörn
>
> On Tue, Oct 25, 2016 at 12:43 PM, Damiano Porta 
> wrote:
>
>> Joern,
>> However i also tried with:
>>
>> public SpanFeatureGenerator(Map properties,
>> FeatureGeneratorResourceProvider resourceProvider) throws
>> InvalidFormatException {
>>
>> }
>>
>> but i get the same exception.
>> Damiano
>>
>> 2016-10-25 12:30 GMT+02:00 Damiano Porta :
>>
>> > This at the moment:
>> >
>> > public SpanFeatureGenerator(String prefix, Object finder, int
>> > prevWindowSize,  int nextWindowSize) {
>> >
>> > System.out.println(prefix);
>> > System.out.println((String)finder);
>> > System.out.println(prevWindowSize);
>> > System.out.println(nextWindowSize);
>> > System.exit(1);
>> >
>> > }
>> >
>> > It is obviously a test to understand if my generator is called.
>> >
>> >
>> > 2016-10-25 12:23 GMT+02:00 Joern Kottmann :
>> >
>> >> What is the constructor of the
>> >> com.damiano.parser.generator.SpanFeatureGenerator
>> >> class?
>> >>
>> >> Jörn
>> >>
>> >> On Tue, Oct 25, 2016 at 11:51 AM, Damiano Porta <
>> damianopo...@gmail.com>
>> >> wrote:
>> >>
>> >> > Hello,
>> >> > I have created a custom generator implementing the
>> >> AdaptiveFeatureGenerator
>> >> > interface.
>> >> >
>> >> > I am getting this error:
>> >> >
>> >> > Exception in thread "main"
>> >> > opennlp.tools.util.ext.ExtensionNotLoadedException:
>> >> > java.lang.InstantiationException:
>> >> > com.damiano.parser.generator.SpanFeatureGenerator
>> >> > at
>> >> > opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
>> >> > ExtensionLoader.java:72)
>> >> > at
>> >> > opennlp.tools.util.featuregen.GeneratorFactory$
>> >> > CustomFeatureGeneratorFactory.create(GeneratorFactory.java:582)
>> >> > at
>> >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
>> >> > GeneratorFactory.java:661)
>> >> > at
>> >> > opennlp.tools.util.featuregen.GeneratorFactory$
>> >> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
>> >> > at
>> >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
>> >> > GeneratorFactory.java:661)
>> >> > at
>> >> > opennlp.tools.util.featuregen.GeneratorFactory$
>> >> > CachedFeatureGeneratorFactory.create(GeneratorFactory.java:171)
>> >> > at
>> >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
>> >> > GeneratorFactory.java:661)
>> >> > at
>> >> > opennlp.tools.util.featuregen.GeneratorFactory$
>> >> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
>> >> > at
>> >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
>> >> > GeneratorFactory.java:661)
>> >> > at
>> >> > opennlp.tools.util.featuregen.GeneratorFactory.create(
>> >> > GeneratorFactory.java:711)
>> >> > at
>> >> > opennlp.tools.namefind.TokenNameFinderFactory.createFeatureG
>> enerators(
>> >> > TokenNameFinderFactory.java:153)
>> >> > at
>> >> > opennlp.tools.namefind.TokenNameFinderFactory.createContextG
>> enerator(
>> >> > TokenNameFinderFactory.java:118)
>> >> > at opennlp.tools.namefind.NameFinderME.train(NameFinderME.java:333)
>> >> > at com.damiano.parser.trainer.NER.compileNER(NER.java:161)
>> >> > at com.damiano.parser.trainer.NER.main(NER.java:136)
>> >> >
>> >> > Caused by: java.lang.InstantiationException:
>> >> > com.damiano.parser.generator.SpanFeatureGenerator
>> >> > at java.lang.Class.newInstance(Class.java:427)
>> >> > at
>> >> > opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
>> >> > ExtensionLoader.java:70)
>> >> > ... 14 more
>> >> >
>> >> > Caused by: java.lang.NoSuchMethodException:
>> >> > com.damiano.parser.generator.SpanFeatureGenerator.()
>> >> > at java.lang.Class.getConstructor0(Class.java:3082)
>> >> > at java.lang.Class.newInstance(Class.java:412)
>> >> > ... 15 more
>> >> >
>> >> > the xml is:
>> >> >
>> >> > 
>> >> >   
>> >> > 
>> >> >   
>> >> > 
>> >> >   
>> >> >   
>> >> > 
>> >> >   
>> >> >   
>> >> >   
>> >> >   
>> >> >   
>> >> >   > >> > prefix="name" finder="blablabla" prevWindowSize="3"
>> nextWindowSize="3"/>
>> >> > 
>> >> >   
>> >> > 
>> >> >
>> >> > What can i do?
>> >> > Thank you!
>> >> >
>> >> > Damiano
>> >> >
>> >>
>> >
>> >
>>
>
>


Re: Custom Features Generator example

2016-10-25 Thread Joern Kottmann
You need to use a constructor which is public and has no arguments.

The parameters can be passed in only if you extend CustomFeatureGenerator.
That one has an init method which gives you the attributes defined in the
xml descriptor.

HTH,
Jörn

On Tue, Oct 25, 2016 at 12:43 PM, Damiano Porta 
wrote:

> Joern,
> However i also tried with:
>
> public SpanFeatureGenerator(Map properties,
> FeatureGeneratorResourceProvider resourceProvider) throws
> InvalidFormatException {
>
> }
>
> but i get the same exception.
> Damiano
>
> 2016-10-25 12:30 GMT+02:00 Damiano Porta :
>
> > This at the moment:
> >
> > public SpanFeatureGenerator(String prefix, Object finder, int
> > prevWindowSize,  int nextWindowSize) {
> >
> > System.out.println(prefix);
> > System.out.println((String)finder);
> > System.out.println(prevWindowSize);
> > System.out.println(nextWindowSize);
> > System.exit(1);
> >
> > }
> >
> > It is obviously a test to understand if my generator is called.
> >
> >
> > 2016-10-25 12:23 GMT+02:00 Joern Kottmann :
> >
> >> What is the constructor of the
> >> com.damiano.parser.generator.SpanFeatureGenerator
> >> class?
> >>
> >> Jörn
> >>
> >> On Tue, Oct 25, 2016 at 11:51 AM, Damiano Porta  >
> >> wrote:
> >>
> >> > Hello,
> >> > I have created a custom generator implementing the
> >> AdaptiveFeatureGenerator
> >> > interface.
> >> >
> >> > I am getting this error:
> >> >
> >> > Exception in thread "main"
> >> > opennlp.tools.util.ext.ExtensionNotLoadedException:
> >> > java.lang.InstantiationException:
> >> > com.damiano.parser.generator.SpanFeatureGenerator
> >> > at
> >> > opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
> >> > ExtensionLoader.java:72)
> >> > at
> >> > opennlp.tools.util.featuregen.GeneratorFactory$
> >> > CustomFeatureGeneratorFactory.create(GeneratorFactory.java:582)
> >> > at
> >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> >> > GeneratorFactory.java:661)
> >> > at
> >> > opennlp.tools.util.featuregen.GeneratorFactory$
> >> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
> >> > at
> >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> >> > GeneratorFactory.java:661)
> >> > at
> >> > opennlp.tools.util.featuregen.GeneratorFactory$
> >> > CachedFeatureGeneratorFactory.create(GeneratorFactory.java:171)
> >> > at
> >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> >> > GeneratorFactory.java:661)
> >> > at
> >> > opennlp.tools.util.featuregen.GeneratorFactory$
> >> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
> >> > at
> >> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> >> > GeneratorFactory.java:661)
> >> > at
> >> > opennlp.tools.util.featuregen.GeneratorFactory.create(
> >> > GeneratorFactory.java:711)
> >> > at
> >> > opennlp.tools.namefind.TokenNameFinderFactory.
> createFeatureGenerators(
> >> > TokenNameFinderFactory.java:153)
> >> > at
> >> > opennlp.tools.namefind.TokenNameFinderFactory.createContextGenerator(
> >> > TokenNameFinderFactory.java:118)
> >> > at opennlp.tools.namefind.NameFinderME.train(NameFinderME.java:333)
> >> > at com.damiano.parser.trainer.NER.compileNER(NER.java:161)
> >> > at com.damiano.parser.trainer.NER.main(NER.java:136)
> >> >
> >> > Caused by: java.lang.InstantiationException:
> >> > com.damiano.parser.generator.SpanFeatureGenerator
> >> > at java.lang.Class.newInstance(Class.java:427)
> >> > at
> >> > opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
> >> > ExtensionLoader.java:70)
> >> > ... 14 more
> >> >
> >> > Caused by: java.lang.NoSuchMethodException:
> >> > com.damiano.parser.generator.SpanFeatureGenerator.()
> >> > at java.lang.Class.getConstructor0(Class.java:3082)
> >> > at java.lang.Class.newInstance(Class.java:412)
> >> > ... 15 more
> >> >
> >> > the xml is:
> >> >
> >> > 
> >> >   
> >> > 
> >> >   
> >> > 
> >> >   
> >> >   
> >> > 
> >> >   
> >> >   
> >> >   
> >> >   
> >> >   
> >> >>> > prefix="name" finder="blablabla" prevWindowSize="3"
> nextWindowSize="3"/>
> >> > 
> >> >   
> >> > 
> >> >
> >> > What can i do?
> >> > Thank you!
> >> >
> >> > Damiano
> >> >
> >>
> >
> >
>


Re: Custom Features Generator example

2016-10-25 Thread Damiano Porta
This at the moment:

public SpanFeatureGenerator(String prefix, Object finder, int
prevWindowSize,  int nextWindowSize) {

System.out.println(prefix);
System.out.println((String)finder);
System.out.println(prevWindowSize);
System.out.println(nextWindowSize);
System.exit(1);

}

It is obviously a test to understand if my generator is called.


2016-10-25 12:23 GMT+02:00 Joern Kottmann :

> What is the constructor of the
> com.damiano.parser.generator.SpanFeatureGenerator
> class?
>
> Jörn
>
> On Tue, Oct 25, 2016 at 11:51 AM, Damiano Porta 
> wrote:
>
> > Hello,
> > I have created a custom generator implementing the
> AdaptiveFeatureGenerator
> > interface.
> >
> > I am getting this error:
> >
> > Exception in thread "main"
> > opennlp.tools.util.ext.ExtensionNotLoadedException:
> > java.lang.InstantiationException:
> > com.damiano.parser.generator.SpanFeatureGenerator
> > at
> > opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
> > ExtensionLoader.java:72)
> > at
> > opennlp.tools.util.featuregen.GeneratorFactory$
> > CustomFeatureGeneratorFactory.create(GeneratorFactory.java:582)
> > at
> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > GeneratorFactory.java:661)
> > at
> > opennlp.tools.util.featuregen.GeneratorFactory$
> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
> > at
> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > GeneratorFactory.java:661)
> > at
> > opennlp.tools.util.featuregen.GeneratorFactory$
> > CachedFeatureGeneratorFactory.create(GeneratorFactory.java:171)
> > at
> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > GeneratorFactory.java:661)
> > at
> > opennlp.tools.util.featuregen.GeneratorFactory$
> > AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
> > at
> > opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> > GeneratorFactory.java:661)
> > at
> > opennlp.tools.util.featuregen.GeneratorFactory.create(
> > GeneratorFactory.java:711)
> > at
> > opennlp.tools.namefind.TokenNameFinderFactory.createFeatureGenerators(
> > TokenNameFinderFactory.java:153)
> > at
> > opennlp.tools.namefind.TokenNameFinderFactory.createContextGenerator(
> > TokenNameFinderFactory.java:118)
> > at opennlp.tools.namefind.NameFinderME.train(NameFinderME.java:333)
> > at com.damiano.parser.trainer.NER.compileNER(NER.java:161)
> > at com.damiano.parser.trainer.NER.main(NER.java:136)
> >
> > Caused by: java.lang.InstantiationException:
> > com.damiano.parser.generator.SpanFeatureGenerator
> > at java.lang.Class.newInstance(Class.java:427)
> > at
> > opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
> > ExtensionLoader.java:70)
> > ... 14 more
> >
> > Caused by: java.lang.NoSuchMethodException:
> > com.damiano.parser.generator.SpanFeatureGenerator.()
> > at java.lang.Class.getConstructor0(Class.java:3082)
> > at java.lang.Class.newInstance(Class.java:412)
> > ... 15 more
> >
> > the xml is:
> >
> > 
> >   
> > 
> >   
> > 
> >   
> >   
> > 
> >   
> >   
> >   
> >   
> >   
> >> prefix="name" finder="blablabla" prevWindowSize="3" nextWindowSize="3"/>
> > 
> >   
> > 
> >
> > What can i do?
> > Thank you!
> >
> > Damiano
> >
>


Re: Custom Features Generator example

2016-10-25 Thread Joern Kottmann
What is the constructor of the
com.damiano.parser.generator.SpanFeatureGenerator
class?

Jörn

On Tue, Oct 25, 2016 at 11:51 AM, Damiano Porta 
wrote:

> Hello,
> I have created a custom generator implementing the AdaptiveFeatureGenerator
> interface.
>
> I am getting this error:
>
> Exception in thread "main"
> opennlp.tools.util.ext.ExtensionNotLoadedException:
> java.lang.InstantiationException:
> com.damiano.parser.generator.SpanFeatureGenerator
> at
> opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
> ExtensionLoader.java:72)
> at
> opennlp.tools.util.featuregen.GeneratorFactory$
> CustomFeatureGeneratorFactory.create(GeneratorFactory.java:582)
> at
> opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> GeneratorFactory.java:661)
> at
> opennlp.tools.util.featuregen.GeneratorFactory$
> AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
> at
> opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> GeneratorFactory.java:661)
> at
> opennlp.tools.util.featuregen.GeneratorFactory$
> CachedFeatureGeneratorFactory.create(GeneratorFactory.java:171)
> at
> opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> GeneratorFactory.java:661)
> at
> opennlp.tools.util.featuregen.GeneratorFactory$
> AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
> at
> opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(
> GeneratorFactory.java:661)
> at
> opennlp.tools.util.featuregen.GeneratorFactory.create(
> GeneratorFactory.java:711)
> at
> opennlp.tools.namefind.TokenNameFinderFactory.createFeatureGenerators(
> TokenNameFinderFactory.java:153)
> at
> opennlp.tools.namefind.TokenNameFinderFactory.createContextGenerator(
> TokenNameFinderFactory.java:118)
> at opennlp.tools.namefind.NameFinderME.train(NameFinderME.java:333)
> at com.damiano.parser.trainer.NER.compileNER(NER.java:161)
> at com.damiano.parser.trainer.NER.main(NER.java:136)
>
> Caused by: java.lang.InstantiationException:
> com.damiano.parser.generator.SpanFeatureGenerator
> at java.lang.Class.newInstance(Class.java:427)
> at
> opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(
> ExtensionLoader.java:70)
> ... 14 more
>
> Caused by: java.lang.NoSuchMethodException:
> com.damiano.parser.generator.SpanFeatureGenerator.()
> at java.lang.Class.getConstructor0(Class.java:3082)
> at java.lang.Class.newInstance(Class.java:412)
> ... 15 more
>
> the xml is:
>
> 
>   
> 
>   
> 
>   
>   
> 
>   
>   
>   
>   
>   
>prefix="name" finder="blablabla" prevWindowSize="3" nextWindowSize="3"/>
> 
>   
> 
>
> What can i do?
> Thank you!
>
> Damiano
>


Custom Features Generator example

2016-10-25 Thread Damiano Porta
Hello,
I have created a custom generator implementing the AdaptiveFeatureGenerator
interface.

I am getting this error:

Exception in thread "main"
opennlp.tools.util.ext.ExtensionNotLoadedException:
java.lang.InstantiationException:
com.damiano.parser.generator.SpanFeatureGenerator
at
opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(ExtensionLoader.java:72)
at
opennlp.tools.util.featuregen.GeneratorFactory$CustomFeatureGeneratorFactory.create(GeneratorFactory.java:582)
at
opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(GeneratorFactory.java:661)
at
opennlp.tools.util.featuregen.GeneratorFactory$AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
at
opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(GeneratorFactory.java:661)
at
opennlp.tools.util.featuregen.GeneratorFactory$CachedFeatureGeneratorFactory.create(GeneratorFactory.java:171)
at
opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(GeneratorFactory.java:661)
at
opennlp.tools.util.featuregen.GeneratorFactory$AggregatedFeatureGeneratorFactory.create(GeneratorFactory.java:129)
at
opennlp.tools.util.featuregen.GeneratorFactory.createGenerator(GeneratorFactory.java:661)
at
opennlp.tools.util.featuregen.GeneratorFactory.create(GeneratorFactory.java:711)
at
opennlp.tools.namefind.TokenNameFinderFactory.createFeatureGenerators(TokenNameFinderFactory.java:153)
at
opennlp.tools.namefind.TokenNameFinderFactory.createContextGenerator(TokenNameFinderFactory.java:118)
at opennlp.tools.namefind.NameFinderME.train(NameFinderME.java:333)
at com.damiano.parser.trainer.NER.compileNER(NER.java:161)
at com.damiano.parser.trainer.NER.main(NER.java:136)

Caused by: java.lang.InstantiationException:
com.damiano.parser.generator.SpanFeatureGenerator
at java.lang.Class.newInstance(Class.java:427)
at
opennlp.tools.util.ext.ExtensionLoader.instantiateExtension(ExtensionLoader.java:70)
... 14 more

Caused by: java.lang.NoSuchMethodException:
com.damiano.parser.generator.SpanFeatureGenerator.()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
... 15 more

the xml is:


  

  

  
  

  
  
  
  
  
  

  


What can i do?
Thank you!

Damiano