当我尝试序列化训练的分类器时,我收到此错误。
未处理的类型异常 'edu.stanford.nlp.io.RuntimeIOException'发生在 斯坦福大学corenlp-3.9.1.dll
将分类器序列化为D:... FAILED
我的代码看起来像这样
public static void trainAndWrite(String modelOutPath, String prop, String trainingFilepath)
{
Properties props = edu.stanford.nlp.util.StringUtils.propFileToProperties(prop);
props.setProperty("serializeTo", modelOutPath);
//if input use that, else use from properties file.
if (trainingFilepath != null)
{
props.setProperty("trainFile", trainingFilepath);
}
SeqClassifierFlags flags = new SeqClassifierFlags(props);
CRFClassifier crf = new CRFClassifier(flags);
crf.train();
crf.serializeClassifier(modelOutPath);
}
我称之为
trainAndWrite(@"D:\", @"Y:\NLP\_sampledata\props.txt", @"Y:\NLP\_sampledata\tokenized.txt");
仅供参考:我使用的是StanfordNLP.NET