OpenNLP
を使用してnl-personTest.bin
ファイルに余分な訓練データを追加しようとしています。 私は、余分なトレーニングデータを追加するためにコードを実行すると、既存のデータを削除し、新しいデータのみを追加するという私の問題です。既存のモデルに訓練データを追加する(ビンファイル)
私は余分なトレーニングデータを置き換える代わりに追加することができますか?
私は、誰でも任意のアイデアがこの問題を解決するための
public class TrainNames
{
public static void main(String[] args)
{
train("nl", "person", "namen.txt", "nl-ner-personTest.bin");
}
public static String train(String lang, String entity,InputStreamFactory inputStream, FileOutputStream modelStream) {
Charset charset = Charset.forName("UTF-8");
TokenNameFinderModel model = null;
ObjectStream<NameSample> sampleStream = null;
try {
ObjectStream<String> lineStream = new PlainTextByLineStream(inputStream, charset);
sampleStream = new NameSampleDataStream(lineStream);
TokenNameFinderFactory nameFinderFactory = new TokenNameFinderFactory();
model = NameFinderME.train("nl", "person", sampleStream, TrainingParameters.defaultParams(),
nameFinderFactory);
} catch (FileNotFoundException fio) {
} catch (IOException io) {
} finally {
try {
sampleStream.close();
} catch (IOException io) {
}
}
BufferedOutputStream modelOut = null;
try {
modelOut = new BufferedOutputStream(modelStream);
model.serialize(modelOut);
} catch (IOException io) {
} finally {
if (modelOut != null) {
try {
modelOut.close();
} catch (IOException io) {
}
}
}
return "Something goes wrong with training module.";
}
public static String train(String lang, String entity, String taggedCoprusFile,
String modelFile) {
try {
InputStreamFactory inputStream = new InputStreamFactory() {
FileInputStream fileInputStream = new FileInputStream("namen.txt");
public InputStream createInputStream() throws IOException {
return fileInputStream;
}
};
return train(lang, entity, inputStream,
new FileOutputStream(modelFile));
} catch (Exception e) {
e.printStackTrace();
}
return "Something goes wrong with training module.";
} }
(Open NLP NER is not properly trainedからそれを得た)、次のコードを使用しましたか?
正確なトレーニングセットが必要な場合は、少なくとも15Kが必要です。 文章に書類が記載されています。
おかげ@Schrieveslaach – Patrick
@Patrickを使用するように変更例:私はあなたが注釈付きコーパスからのNLPモデルを作成するのに役立つツールセットを開発しています。こちらをご覧ください(https://git.noc.fh-aachen.de/marc.schreiber/Towards-Effective-NLP-Application-Development)。ご不明な点がございましたら、お知らせください。 ;-) – Schrieveslaach
ありがとう、私はそれを見ています。@ Schrieveslaach – Patrick