斯坦福CoreNLP错误创建edu.stanford.nlp.time.TimeExpressionExtractorImpl [英] Stanford CoreNLP Error creating edu.stanford.nlp.time.TimeExpressionExtractorImpl

查看:1791
本文介绍了斯坦福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是
>未处理的HResult = -2146233088消息=错误创建
> edu.stanford.nlp.time.TimeExpressionExtractorImpl
>来源=斯坦福大学corenlp-3.5.0堆栈跟踪:在
> edu.stanford.nlp.util.ReflectionLoading.loadByReflection(字符串
个类名,对象[]参数)在
> edu.stanford.nlp.time.TimeExpressionExtractorFactory.create(字符串
个类名,字符串名称,属性道具)在
> edu.stanford.nlp.time.TimeExpressionExtractorFactory.createExtractor(字符串
>名,属性道具)在
> edu.stanford.nlp.ie.regexp.NumberSequenceClassifier..ctor(属性
个道具,布尔useSUTime,属性sutimeProps)在
>在
> edu.stanford.nlp.ie.NERClassifierCombiner..ctor(字符串[] loadPaths布尔值
> applyNumericClassifiers,布尔useSUTime,属性nscProps,
>); (在edu.stanford.nlp.pipeline.AnnotatorFactories.6.create)
> edu.stanford.nlp.pipeline.AnnotatorImplementations.ner(属性属性
>);在edu.stanford.nlp.pipeline.AnnotatorPool.get(字符串名称)在
> edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(属性A_1,
>布尔A_2,A_3 AnnotatorImplementations)在
> edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(属性道具,
>布尔enforceRequirements)在
> edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(属性道具)在
> ConsoleApplication1.Program.Main(字串[] args)在
> D:\Programming_Code\VisualStudio\visual工作室
> 2013\Projects\AutoWikify\ConsoleApplication1\ConsoleApplication1\Program.cs:行
> 30日System.AppDomain._nExecuteAssembly(RuntimeAssembly组装,
>字串[] args)在
> Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()在
>在
> System.Threading.ExecutionContext.RunInternal(preserveSyncCtx的ExecutionContext
>的ExecutionContext,ContextCallback回调,对象状态,布尔
>);在
> System.Threading.ExecutionContext.Run(preserveSyncCtx的ExecutionContext
>的ExecutionContext,ContextCallback回调,对象状态,布尔
>);在
> System.Threading.ExecutionContext.Run(ExecutionContext中,ContextCallback回调,对象状态的ExecutionContext
>); System.Threading.ThreadHelper.ThreadStart()的InnerException:
> edu.stanford.nlp.util.MetaClass.ClassCreationException
>的HResult = -2146233088消息=的MetaClass无法创建公共
> edu.stanford.nlp.time.TimeExpressionExtractorImpl(java.lang.String中,java.util.Properties)
>与ARGS [sutime,{sutime.binders = 0,注解=记号化,SSPLIT,
个POS,引理,净入学率,解析,dcoref}]来源=斯坦福大学corenlp-3.5.0
>堆栈跟踪:在
> edu.stanford.nlp.util.MetaClass.ClassFactory.createInstance(Object []对象
> PARAMS)在edu.stanford.nlp.util.MetaClass.createInstance(Object []对象
>对象)在
> edu.stanford.nlp.util.ReflectionLoading.loadByReflection(字符串
个类名,对象[]参数)的InnerException:
> java.lang.reflect.InvocationTargetException的HResult = -2146233088
>消息=来源=斯坦福大学corenlp-3.5.0堆栈跟踪:在__(对象[])
>在
> Java_sun_reflect_ReflectionFactory.FastConstructorAccessorImpl.newInstance(Object []对象
个参数)在java.lang.reflect.Constructor.newInstance(Object []对象initargs,
>来电显示)在
> edu.stanford.nlp.util.MetaClass.ClassFactory.createInstance(Object []对象
> PARAMS)的InnerException:

下面是我的代码:

 使用系统; 
使用System.Collections.Generic;
使用System.Linq的;
使用System.Text;
使用的java.util;
使用java.io;
使用edu.stanford.nlp.pipeline;使用控制台= System.Console
;

命名ConsoleApplication1
{
类节目
{
静态无效的主要(字串[] args)
{
//路径与模式从'斯坦福大学corenlp-3.4-models.jar`
VAR jarRoot = @提取D文件夹:\Programming_SDKs\stanford-corenlp-全2015-01-30\stanford- corenlp-3.5.1-models\

//处理
变种文字=Kosgi桑托斯文本发送电子邮件至斯坦福大学。他没有得到答复。;

//注解管道配置
变种道具=新特性();
props.setProperty(注解,记号化,SSPLIT,POS,引理,净入学率,解析,dcoref);
props.setProperty(sutime.binders,0);

//我们应该改变当前目录,因此StanfordCoreNLP能找到所有的模型文件自动
VAR CURDIR = Environment.CurrentDirectory;
System.IO.Directory.SetCurrentDirectory(jarRoot);
变种管道=新StanfordCoreNLP(道具);
System.IO.Directory.SetCurrentDirectory(CURDIR);

//注释
变种注释=新的注解(文本);
pipeline.annotate(注释);

//结果 - 用漂亮的打印
(VAR流=新ByteArrayOutputStream())
{
pipeline.prettyPrint(注释,新的PrintWriter(流));
Console.WriteLine(stream.toString());
stream.close();
}
}
}
}


解决方案

3.5.1目前(2015年2月11日)不支持。它与



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


I am trying to learn the Stanford CoreNLP library. I am using C# with the posted example (https://sergeytihon.wordpress.com/2013/10/26/stanford-corenlp-is-available-on-nuget-for-fc-devs/). I loaded the package "Stanford.NLP.CoreNLP" (it added IKVM.NET) via nuget and downloaded the code. Unzipped the .jar models. My directory is correct. I get the following error:

> 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:

Here is my code:

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

解决方案

3.5.1 is currently (2/11/2015) not supported. It works with

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

这篇关于斯坦福CoreNLP错误创建edu.stanford.nlp.time.TimeExpressionExtractorImpl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆