将Stanford-NLP集成到ASP.Net Core C#应用程序中,得到以下错误消息: System.TypeInitializationException HResult = 0x80131534 Message ='edu.stanford.nlp.util.Timing'的类型初始值设定项引发了异常。 资料来源= stanford-corenlp-3.9.1 堆栈跟踪: 在edu.stanford.nlp.util.Timing..ctor() 在edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(Properties,Boolean,AnnotatorImplementations) 在edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor处(属性道具,布尔值forceRequirements,AnnotatorPool和annotatorPool) 在edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor处(属性props,布尔forceRequirements) 在edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(Properties props) 在_3x32018.Utility.SearchNLP.ParseNLG(字符串send2)在G:\ VSProjects \ 3x32018 \ 3x32018 \ Utility \ SearchNLP.cs:line 52
内部异常1: TypeInitializationException:“ java.util.ResourceBundle”的类型初始值设定项引发了异常。
内部异常2: MissingMethodException:找不到方法:'Void System.IO.FileStream..ctor(System.String,System.IO.FileMode,System.Security.AccessControl.FileSystemRights,System.IO.FileShare,Int32,System.IO.FileOptions)'
这是我的简单代码:
using edu.stanford.nlp.pipeline;
using java.util;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
namespace _3x32018.Utility
{
public class SearchNLP
{
public HashSet<string> ParseNLG(string sent2)
{
CultureInfo ci = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma,
ner, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation document = new Annotation(sent2);
pipeline.annotate(document);
}
}
}
有什么想法为什么会失败?
-莱斯特
答案 0 :(得分:0)
您正在使用ASP.NET Core,它没有corenlp.net使用的FileStream构造函数(确切地说是IKVM)。检出此页面https://docs.microsoft.com/en-us/dotnet/api/system.io.filestream.-ctor?view=netcore-2.0。