c# - Unrecoverable error while loading a tagger model using nugetpackages -
i have been trying create , run simple program using stanford-corenlp-3.5.2 nugetpackage.
however after looking beginner code start have found following code props.setproperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");(link code example : http://sergey-tihon.github.io/stanford.nlp.net/stanfordcorenlp.html)
but whenever console app loads pos fires off runtime error stating not load tagger.
i wondering if missing nugetpackages or if there additional setup have go through. (note. time have tried add postagger nuget package error saying class annotation referenced in 2 dlls.)
i have found if remove of properties application run correctly new line looks "props.setproperty("annotators", "tokenize, ssplit");
any past runtime error can continue further analyse of sample text appreciated. thank you.
attached picture reference.(apparently need more reputation in order post pic when can :) edit have added picture :)
stack trace @ line exception follows:
at edu.stanford.nlp.pipeline.annotatorfactories.4.create() @ edu.stanford.nlp.pipeline.annotatorpool.get(string name) @ edu.stanford.nlp.pipeline.stanfordcorenlp.construct(properties , boolean , annotatorimplementations ) @ edu.stanford.nlp.pipeline.stanfordcorenlp..ctor(properties props, boolean enforcerequirements) @ edu.stanford.nlp.pipeline.stanfordcorenlp..ctor(properties props) @ conapplicationsabrinanlp.testclass.donlp() in c:\users\justin\documents\visual studio 2013\projects\conapplicationsabrinanlp\conapplicationsabrinanlp\testclass.cs:line 28 @ conapplicationsabrinanlp.program.main(string[] args) in c:\users\justin\documents\visual studio 2013\projects\conapplicationsabrinanlp\conapplicationsabrinanlp\program.cs:line 20 @ system.appdomain._nexecuteassembly(runtimeassembly assembly, string[] args) @ system.appdomain.executeassembly(string assemblyfile, evidence assemblysecurity, string[] args) @ microsoft.visualstudio.hostingprocess.hostproc.runusersassembly() @ system.threading.threadhelper.threadstart_context(object state) @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx) @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx) @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state) @ system.threading.threadhelper.threadstart()
the problem haven't downloaded models. nuget package doesn't work itself. must download lastest version here pos-tagger
once have done put in project directory. point code it. in "3.6.0 2015-12-09 updated compatibility" version tagger has different name, "english-bidirectional-distsim.tagger" example. make sure point code correct folder , files , work.
the following working example windows forms project.
using java.io; using java.util; using edu.stanford.nlp.ling; using edu.stanford.nlp.tagger.maxent; using console = system.console; using system.io; using system.windows.forms; namespace stanford.nlp.postagger.csharp { class postagger { // base folder project public static string getappfolder() { return path.getdirectoryname(application.executablepath).replace(@"*your project directory here*\bin\debug", string.empty); } public void testtagger() { var jarroot = path.combine(getappfolder(), @"packages\stanford-postagger-2015-12-09"); console.writeline(jarroot.tostring()); var modelsdirectory = jarroot + @"\models"; // loading pos tagger var tagger = new maxenttagger(modelsdirectory + @"\english-bidirectional-distsim.tagger"); // text tagging var text = "a part-of-speech tagger (pos tagger) piece of software reads text" + "in language , assigns parts of speech each word (and other token)," + " such noun, verb, adjective, etc., although computational " + "applications use more fine-grained pos tags 'noun-plural'."; var sentences = maxenttagger.tokenizetext(new java.io.stringreader(text)).toarray(); foreach (arraylist sentence in sentences) { var taggedsentence = tagger.tagsentence(sentence); console.writeline(sentence.listtostring(taggedsentence, false)); } } } }
Comments
Post a Comment