new PlainTextByLineStream(
new java.io.FileReader(inFile)));
int iterations = 100;
int cutoff = 5;
TokenNameFinderModel model = NameFinderME.train( //<co id="co.opennlp.name.train2"/>
"en", // language
"person", // type
nss,
featureGenerators,
Collections.<String,Object>emptyMap(),
iterations,
cutoff);
File outFile = new File(destDir,"person-custom2.bin");
FileOutputStream outFileStream = new FileOutputStream(outFile);
model.serialize(outFileStream); //<co id="co.opennlp.name.persist2"/>
/*<calloutlist>
<callout arearefs="co.opennlp.name.initfeat"><para>Create the sample stream..</para></callout>
<callout arearefs="co.opennlp.name.train2"><para>Train the model with a custom feature generator.</para></callout>
<callout arearefs="co.opennlp.name.persist2"><para>Save the model to a file.</para></callout>
</calloutlist>*/
//<end id="ne-features-train"/>
//<start id="ne-features-test"/>
NameFinderME finder = new NameFinderME(
new TokenNameFinderModel(
new FileInputStream(
new File(destDir, "person-custom2.bin")
)), featureGenerators, NameFinderME.DEFAULT_BEAM_SIZE);
//<end id="ne-features-test"/>
}