You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@opennlp.apache.org by "Martin Wiesner (Jira)" <ji...@apache.org> on 2024/04/15 09:31:00 UTC
[jira] [Closed] (OPENNLP-1546) NER training code example in documentation requires update
[ https://issues.apache.org/jira/browse/OPENNLP-1546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Wiesner closed OPENNLP-1546.
-----------------------------------
Resolution: Fixed
> NER training code example in documentation requires update
> ----------------------------------------------------------
>
> Key: OPENNLP-1546
> URL: https://issues.apache.org/jira/browse/OPENNLP-1546
> Project: OpenNLP
> Issue Type: Documentation
> Components: Documentation
> Affects Versions: 2.0.0, 2.1.0, 2.2.0, 2.3.0
> Reporter: Jeff Zemerick
> Assignee: Martin Wiesner
> Priority: Major
> Fix For: 2.3.3
>
>
> The NER training code example needs updated.
> [https://opennlp.apache.org/docs/2.3.2/manual/opennlp.html#tools.namefind.training.api]
> * The `TokenNameFinderFactory nameFinderFactory` part won't compile.
> * The `model.serizialize(...)` part won't compile.
> * This code might be outdated in general.
> {code:java}
> ObjectStream<String> lineStream =
> new PlainTextByLineStream(new MarkableFileInputStreamFactory(new File("en-ner-person.train")), StandardCharsets.UTF_8);
> TokenNameFinderModel model;
> try (ObjectStream<NameSample> sampleStream = new NameSampleDataStream(lineStream)) {
> model = NameFinderME.train("eng", "person", sampleStream, TrainingParameters.defaultParams(), nameFinderFactory);
> }
> try (ObjectStream modelOut = new BufferedOutputStream(new FileOutputStream(modelFile)){
> model.serialize(modelOut);
> }
> {code}
> For reference (but not tested):
> {code:java}
> final InputStreamFactory in = new MarkableFileInputStreamFactory(convertedTrainingFile);
> final ObjectStream<NameSample> sampleStream = new NameSampleDataStream(new PlainTextByLineStream(in, StandardCharsets.UTF_8));
> final TokenNameFinderModel nameFinderModel = NameFinderME.train("en", null, sampleStream, TrainingParameters.defaultParams(), TokenNameFinderFactory.create(null, null, Collections.emptyMap(), new BioCodec())); {code}
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)