Stanford CoreNLP创建edu.stanford.nlp.time.TimeExpressionExtractorImpl时出错

我正在尝试学习斯坦福CoreNLP库。 我正在使用带有发布示例的C#( https://sergeytihon.wordpress.com/2013/10/26/stanford-corenlp-is-available-on-nuget-for-fc-devs/ )。 我通过nuget加载了包“Stanford.NLP.CoreNLP”(它添加了IKVM.NET)并下载了代码。 解压缩.jar模型。 我的目录是正确的。 我收到以下错误:

> edu.stanford.nlp.util.ReflectionLoading.ReflectionLoadingException was > unhandled HResult=-2146233088 Message=Error creating > edu.stanford.nlp.time.TimeExpressionExtractorImpl > Source=stanford-corenlp-3.5.0 StackTrace: at > edu.stanford.nlp.util.ReflectionLoading.loadByReflection(String > className, Object[] arguments) at > edu.stanford.nlp.time.TimeExpressionExtractorFactory.create(String > className, String name, Properties props) at > edu.stanford.nlp.time.TimeExpressionExtractorFactory.createExtractor(String > name, Properties props) at > edu.stanford.nlp.ie.regexp.NumberSequenceClassifier..ctor(Properties > props, Boolean useSUTime, Properties sutimeProps) at > edu.stanford.nlp.ie.NERClassifierCombiner..ctor(Boolean > applyNumericClassifiers, Boolean useSUTime, Properties nscProps, > String[] loadPaths) at > edu.stanford.nlp.pipeline.AnnotatorImplementations.ner(Properties > properties) at edu.stanford.nlp.pipeline.AnnotatorFactories.6.create() > at edu.stanford.nlp.pipeline.AnnotatorPool.get(String name) at > edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(Properties A_1, > Boolean A_2, AnnotatorImplementations A_3) at > edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(Properties props, > Boolean enforceRequirements) at > edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(Properties props) at > ConsoleApplication1.Program.Main(String[] args) in > d:\Programming_Code\VisualStudio\visual studio > 2013\Projects\AutoWikify\ConsoleApplication1\ConsoleApplication1\Program.cs:line > 30 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, > String[] args) at > Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at > System.Threading.ExecutionContext.RunInternal(ExecutionContext > executionContext, ContextCallback callback, Object state, Boolean > preserveSyncCtx) at > System.Threading.ExecutionContext.Run(ExecutionContext > executionContext, ContextCallback callback, Object state, Boolean > preserveSyncCtx) at > System.Threading.ExecutionContext.Run(ExecutionContext > executionContext, ContextCallback callback, Object state) at > System.Threading.ThreadHelper.ThreadStart() InnerException: > edu.stanford.nlp.util.MetaClass.ClassCreationException > HResult=-2146233088 Message=MetaClass couldn't create public > edu.stanford.nlp.time.TimeExpressionExtractorImpl(java.lang.String,java.util.Properties) > with args [sutime, {sutime.binders=0, annotators=tokenize, ssplit, > pos, lemma, ner, parse, dcoref}] Source=stanford-corenlp-3.5.0 > StackTrace: at > edu.stanford.nlp.util.MetaClass.ClassFactory.createInstance(Object[] > params) at edu.stanford.nlp.util.MetaClass.createInstance(Object[] > objects) at > edu.stanford.nlp.util.ReflectionLoading.loadByReflection(String > className, Object[] arguments) InnerException: > java.lang.reflect.InvocationTargetException HResult=-2146233088 > Message=”” Source=stanford-corenlp-3.5.0 StackTrace: at __(Object[] ) > at > Java_sun_reflect_ReflectionFactory.FastConstructorAccessorImpl.newInstance(Object[] > args) at java.lang.reflect.Constructor.newInstance(Object[] initargs, > CallerID ) at > edu.stanford.nlp.util.MetaClass.ClassFactory.createInstance(Object[] > params) InnerException: 

这是我的代码:

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using java.util; using java.io; using edu.stanford.nlp.pipeline; using Console = System.Console; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { // Path to the folder with models extracted from `stanford-corenlp-3.4-models.jar` var jarRoot = @”D:\Programming_SDKs\stanford-corenlp-full-2015-01-30\stanford-corenlp-3.5.1-models\”; // Text for processing var text = “Kosgi Santosh sent an email to Stanford University. He didn't get a reply.”; // Annotation pipeline configuration var props = new Properties(); props.setProperty(“annotators”, “tokenize, ssplit, pos, lemma, ner, parse, dcoref”); props.setProperty(“sutime.binders”, “0”); // We should change current directory, so StanfordCoreNLP could find all the model files automatically var curDir = Environment.CurrentDirectory; System.IO.Directory.SetCurrentDirectory(jarRoot); var pipeline = new StanfordCoreNLP(props); System.IO.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(); } } } } 

添加props.setProperty("ner.useSUTime", "false")为我解决了这个问题。

3.5.1目前(2015年11月2日)不受支持。 它适用于

http://nlp.stanford.edu/software/stanford-corenlp-full-2014-10-31.zip