Type Initialization Exception on pipeline definition

3

Integrating Stanford-NLP into ASP.Net Core C# application getting the following error message: System.TypeInitializationException HResult=0x80131534 Message=The type initializer for 'edu.stanford.nlp.util.Timing' threw an exception. Source=stanford-corenlp-3.9.1 StackTrace: at edu.stanford.nlp.util.Timing..ctor() at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(Properties , Boolean , AnnotatorImplementations ) at edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(Properties props, Boolean enforceRequirements, AnnotatorPool annotatorPool) at edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(Properties props, Boolean enforceRequirements) at edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(Properties props) at _3x32018.Utility.SearchNLP.ParseNLG(String sent2) in G:\VSProjects\3x32018\3x32018\Utility\SearchNLP.cs:line 52

Inner Exception 1: TypeInitializationException: The type initializer for 'java.util.ResourceBundle' threw an exception.

Inner Exception 2: MissingMethodException: Method not found: 'Void System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.Security.AccessControl.FileSystemRights, System.IO.FileShare, Int32, System.IO.FileOptions)'.

Here's my simple code::

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); 
      } 
   } 
}

Any ideas why this is failing?

-Lester

stanford-nlp
asked on Stack Overflow Sep 28, 2018 by Lester Edwards

1 Answer

3

You are using ASP.NET Core which doesn't have the constructor for FileStream that the corenlp.net is using (IKVM to be exact). Check this page out, https://docs.microsoft.com/en-us/dotnet/api/system.io.filestream.-ctor?view=netcore-2.0.

answered on Stack Overflow Feb 25, 2019 by henrylilei • edited Feb 25, 2019 by henrylilei

User contributions licensed under CC BY-SA 3.0