Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code fails with "Error creating > edu.stanford.nlp.time.TimeExpressionExtractorImpl" when using Stanford CoreNLP version 3.5.1 #11

Closed
mike-a-ellis opened this issue Feb 9, 2015 · 9 comments
Assignees

Comments

@mike-a-ellis
Copy link

I am trying to learn the Stanford CoreNLP library. I am using C# with the posted example (https://sergey-tihon.github.io/Stanford.NLP.NET/StanfordCoreNLP.html). 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();
}
}
}
}

NOTE: After more exploring, I only get the above error when using the 3.5.1. If I use the corenlp linked to in the original article (stanford-corenlp-full-2014-10-31), it works fine.

@sergey-tihon sergey-tihon self-assigned this Feb 9, 2015
@sergey-tihon
Copy link
Owner

@volhav Could you please test it on your machine? Thanks.

@volhav
Copy link
Contributor

volhav commented Feb 9, 2015

@bulltorious @sergey-tihon I've checked, as mentioned before, everything works fine with supported v3.5.0. I think the issue will be fixed when Sergey updates a package with a new version of Stanford.CoreNLP

@sergey-tihon
Copy link
Owner

@bulltorious Please try latest version from NuGet

@mike-a-ellis
Copy link
Author

It is working now with the latest corenlp version. Thanks Sergey.

@gimp-dad
Copy link

gimp-dad commented Jun 4, 2015

Hi Sergey,

I just ran into this exact same issue with the 3.5.2 package. Am I the only one?

It was working fine before I did a NuGet to go from 3.5.1 to 3.5.2.

Thanks,
Gimp

@sergey-tihon
Copy link
Owner

Please try this solution #19 (comment)

@gimp-dad
Copy link

gimp-dad commented Jun 9, 2015

Thanks, Sergey. Replacing code like

props.setProperty("sutime.binders", "0");

with

props.setProperty("ner.useSUTime", "0");

has fixed the issue.

@MichaelAtTrov
Copy link

Hey @sergey-tihon, any chance that your F# and C# samples could be updated to reflect this new requirement?

Thanks for your consideration. :)

@k-bx
Copy link

k-bx commented Mar 14, 2018

Hi. Just got this error on a freshly-downloaded corenlp command line utility (2018-02-27) on Ubuntu 17.10. Is there a way to fix a command-line utility without compiling from source with the patch mentioned? Thank you.

UPDATE: sorry, I see this is a repo for a .NET, not the Standford.NLP itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants