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 <[email protected]>:

> 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 <[email protected]>
> wrote:
>
> > Oh thanks! i try.
> > If I extend the CustomFeatureGenerator what parameters should i pass?
> >
> > Il 25/Ott/2016 13:39, "Joern Kottmann" <[email protected]> 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 <
> [email protected]>
> > > wrote:
> > >
> > > > Joern,
> > > > However i also tried with:
> > > >
> > > >     public SpanFeatureGenerator(Map<String, String> properties,
> > > > FeatureGeneratorResourceProvider resourceProvider) throws
> > > > InvalidFormatException {
> > > >
> > > >     }
> > > >
> > > > but i get the same exception.
> > > > Damiano
> > > >
> > > > 2016-10-25 12:30 GMT+02:00 Damiano Porta <[email protected]>:
> > > >
> > > > > 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 <[email protected]>:
> > > > >
> > > > >> 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 <
> > > [email protected]
> > > > >
> > > > >> 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.<init>()
> > > > >> > at java.lang.Class.getConstructor0(Class.java:3082)
> > > > >> > at java.lang.Class.newInstance(Class.java:412)
> > > > >> > ... 15 more
> > > > >> >
> > > > >> > the xml is:
> > > > >> >
> > > > >> > <generators>
> > > > >> >   <cache>
> > > > >> >     <generators>
> > > > >> >       <window prevLength="6" nextLength="3">
> > > > >> >         <tokenclass/>
> > > > >> >       </window>
> > > > >> >       <window prevLength="6" nextLength="3">
> > > > >> >         <token/>
> > > > >> >       </window>
> > > > >> >       <definition/>
> > > > >> >       <prevmap/>
> > > > >> >       <bigram/>
> > > > >> >       <sentence begin="true" end="false"/>
> > > > >> >       <custom class="com.damiano.parser.generator.
> > > > SpanFeatureGenerator"
> > > > >> > prefix="name" finder="blablabla" prevWindowSize="3"
> > > > nextWindowSize="3"/>
> > > > >> >     </generators>
> > > > >> >   </cache>
> > > > >> > </generators>
> > > > >> >
> > > > >> > What can i do?
> > > > >> > Thank you!
> > > > >> >
> > > > >> > Damiano
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > >
> > >
> >
>

Reply via email to