1

我在 C# 语言中使用 opennlp 工具。我写了以下代码:

string modelpath = @"D:\models\en-sent.bin";
java.io.FileInputStream modelInpStream = new java.io.FileInputStream(modelpath);
SentenceModel model = new SentenceModel(modelInpStream);
SentenceDetectorME sentenceDetector = new SentenceDetectorME(model);

但它在该行中导致了 TypeInitializationException:

SentenceModel model = new SentenceModel(modelInpStream);

异常消息:

TypeInitializationException was unhandled
The type initializer for 'java.nio.charset.StandardCharsets' threw an exception.
4

1 回答 1

0

假设您使用 IKVM 代码将 openNLP jar 文件转换为 .Net,您应该只需要在您的项目中包含 IKVM Charsets dll 以使其工作。

于 2012-05-01T22:12:10.833 回答