C# 在c中运行Stanford.NLP.CoreNLP 3.8示例时出现TypeInitializationException#

C# 在c中运行Stanford.NLP.CoreNLP 3.8示例时出现TypeInitializationException#,c#,stanford-nlp,C#,Stanford Nlp,我意识到这个问题是通过包含 props.setProperty(“ner.useSUTime”、“0”); 但是,错误仍然存在。我通过nuget添加了corenlp 3.8,我使用的是c#visual studio 2017,配置为NetStandard2.0 我的代码: ` 这是一个项目。IKVM是.NET中的Java虚拟机实现。它不支持.NET标准2.0,只支持.NET Framework和Mono 因此,您的选择是: 目标是.NETFramework或Mono 将端口连接到.NET标准 将

我意识到这个问题是通过包含 props.setProperty(“ner.useSUTime”、“0”); 但是,错误仍然存在。我通过nuget添加了corenlp 3.8,我使用的是c#visual studio 2017,配置为NetStandard2.0

我的代码: `

这是一个项目。IKVM是.NET中的Java虚拟机实现。它不支持.NET标准2.0,只支持.NET Framework和Mono

因此,您的选择是:

  • 目标是.NETFramework或Mono
  • 将端口连接到.NET标准
  • 将IKVM.NET项目移植到.NET标准(最好是开源项目,以便其他需要在.NET标准中快速运行Java代码的人可以这样做)。请注意,目前正在进行一项名为的工作
  • 使用Pinvoke调用Java和一个普通的C包装器作为中间人,它使用JNI加载JVM并公开使用JNI调用Java的函数,如图所示
  • 用Java或Java实现您的应用程序
  • 这是一个项目。IKVM是.NET中的Java虚拟机实现。它不支持.NET标准2.0,只支持.NET Framework和Mono

    因此,您的选择是:

  • 目标是.NETFramework或Mono
  • 将端口连接到.NET标准
  • 将IKVM.NET项目移植到.NET标准(最好是开源项目,以便其他需要在.NET标准中快速运行Java代码的人可以这样做)。请注意,目前正在进行一项名为的工作
  • 使用Pinvoke调用Java和一个普通的C包装器作为中间人,它使用JNI加载JVM并公开使用JNI调用Java的函数,如图所示
  • 用Java或Java实现您的应用程序

  • 您是否尝试添加对System.Configuration的引用?上面说它不见了,同意。但在我开始调查之前,我想确定我没有遗漏更明显的东西-请参阅下面的帖子您是否尝试添加对System.Configuration的引用?上面说它不见了,同意。但在我开始调查之前,我想确定我没有遗漏更明显的东西-见下文谢谢!你提供了一个极好的答案。根据您的输入,权宜之计是创建proc并通过cmd行运行coreNLP。选项#1为我节省了很多时间。谢谢非常感谢。你提供了一个极好的答案。根据您的输入,权宜之计是创建proc并通过cmd行运行coreNLP。选项#1为我节省了很多时间。谢谢
    public Dictionary<int, List<Word>> GetPOSFromStandforNLP(string sent)
            {
                var pos = new Dictionary<int, List<Word>>();
                var jarRoot = @"../vendor/stanford-corenlp-3.8.0-models";
    
                // Annotation pipeline configuration
                var props = new Properties();
                // Annotation pipeline configuration
                var props = new Properties();
                props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
                props.setProperty("ner.useSUTime", "0");
    
                try
                {
                    CultureInfo ci = new CultureInfo("en-US");
                    Thread.CurrentThread.CurrentCulture = ci;
                    Thread.CurrentThread.CurrentUICulture = ci;
    
                    var curDir = Environment.CurrentDirectory;
                    Directory.SetCurrentDirectory(jarRoot);   
                    var pipeline = new StanfordCoreNLP(props);
                    Directory.SetCurrentDirectory(curDir);
                    // Annotation
                    var annotation = new Annotation(text);
                    pipeline.annotate(annotation);
                    // Result - Pretty Print
                    using (var stream = new ByteArrayOutputStream())
                    {
                        pipeline.prettyPrint(annotation, new PrintWriter(stream));
                        Console.WriteLine(stream.toString());
                        stream.close();
                    }
    
    System.TypeInitializationException: The type initializer for 'edu.stanford.nlp.pipeline.AnnotationPipeline' threw an exception. ---> System.TypeInitializationException: The type initializer for 'edu.stanford.nlp.util.logging.Redwood' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.     at IKVM.Internal.AssemblyClassLoader.LoadCustomClassLoaderRedirects()    at IKVM.Internal.AssemblyClassLoader.GetCustomClassLoaderType()    at IKVM.Internal.AssemblyClassLoader.GetJavaClassLoader()    at java.lang.Class.getClassLoader(CallerID )    at java.lang.Class.desiredAssertionStatus()    at edu.stanford.nlp.util.logging.Redwood..cctor(