Stanford nlp 管道定义上的类型初始化异常
将Stanford NLP集成到ASP.Net核心C#应用程序中会收到以下错误消息: System.TypeInitializationException异常 HResult=0x80131534 Message='edu.stanford.nlp.util.Timing'的类型初始值设定项引发异常。 来源=斯坦福大学-corenlp-3.9.1 堆栈跟踪: 在edu.stanford.nlp.util.Timing..ctor()上 位于edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(属性、布尔值、注释实现) 位于edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(属性道具、布尔强制要求、注释器池注释器池) 在edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(属性道具,布尔强制要求) 在edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(属性道具) 位于G:\VSProjects\3x32018\3x32018\Utility\SearchNLP.cs中的\u 3x32018.Utility.SearchNLP.ParseNLG(字符串sent2):第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)” 以下是我的简单代码:Stanford nlp 管道定义上的类型初始化异常,stanford-nlp,Stanford Nlp,将Stanford NLP集成到ASP.Net核心C#应用程序中会收到以下错误消息: System.TypeInitializationException异常 HResult=0x80131534 Message='edu.stanford.nlp.util.Timing'的类型初始值设定项引发异常。 来源=斯坦福大学-corenlp-3.9.1 堆栈跟踪: 在edu.stanford.nlp.util.Timing..ctor()上 位于edu.stanford.nlp.pipeline.St
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);
}
}
}
使用edu.stanford.nlp.pipeline;
使用java.util;
使用System.Collections.Generic;
利用制度全球化;
使用系统线程;
命名空间_3x32018.Utility
{
公共类搜索NLP
{
公共HashSet ParseNLG(字符串sent2)
{
CultureInfo ci=新的CultureInfo(“美国”);
Thread.CurrentThread.CurrentCulture=ci;
Thread.CurrentThread.CurrentUICulture=ci;
Properties props=新属性();
props.setProperty(“注释器”、“标记化、ssplit、pos、引理、,
ner、parse、dcoref);
StanfordCoreNLP管道=新的StanfordCoreNLP(道具);
注释文件=新注释(sent2);
管道注释(文件);
}
}
}
你知道为什么会失败吗
-Lester您使用的是ASP.NET Core,它没有corenlp.NET使用的FileStream构造函数(确切地说是IKVM)。请查看此页。那么这是否意味着.NET核心与StanfordNLP.NET不兼容?还是有解决办法?Thanks@CarolAndorMartenLiebster我相信IKVM没有.NET核心或.NET标准版本。您可以尝试使用IKVM来修复丢失的方法调用,也可以将stanford corenlp作为一个独立的web服务器提供。已经有一些人能够解决这一限制: