Closed leezhihui closed 3 years ago
Do you have an error message?)
My initial guess that you still use jarRoot
directory models instead of jarRoot2
Directory.SetCurrentDirectory(jarRoot);
var pipeline = new StanfordCoreNLP(props);
when i use the jarRoot2 error message:
edu.stanford.nlp.io.RuntimeIOException occurred
HResult=0x80131500
Message=Error while loading a tagger model (probably missing model file)
Source=stanford-corenlp-3.8.0
StackTrace:
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(Properties config, String modelFileOrUrl, Boolean printLoading)
at edu.stanford.nlp.tagger.maxent.MaxentTagger..ctor(String modelFile, Properties config, Boolean printLoading)
at edu.stanford.nlp.tagger.maxent.MaxentTagger..ctor(String modelFile)
at edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(String , Boolean )
at edu.stanford.nlp.pipeline.POSTaggerAnnotator..ctor(String annotatorName, Properties props)
at edu.stanford.nlp.pipeline.AnnotatorImplementations.posTagger(Properties properties)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.lambda$getNamedAnnotators$42(Properties , AnnotatorImplementations )
at edu.stanford.nlp.pipeline.StanfordCoreNLP.__<>Anon4.apply(Object , Object )
at edu.stanford.nlp.pipeline.StanfordCoreNLP.lambda$getDefaultAnnotatorPool$65(Entry , Properties , AnnotatorImplementations )
at edu.stanford.nlp.pipeline.StanfordCoreNLP.__<>Anon27.get()
at edu.stanford.nlp.util.Lazy.3.compute()
at edu.stanford.nlp.util.Lazy.get()
at edu.stanford.nlp.pipeline.AnnotatorPool.get(String name)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(Properties , Boolean , AnnotatorImplementations , AnnotatorPool )
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 StanfordNLP.Program.Main(String[] args) in C:\Users\admin\source\repos\StanfordNLP\StanfordNLP\Program.cs:line 34
Inner Exception 1:
IOException: Unable to open "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger" as class path, filename or URL
thank you for your concerning . because i am in China, there is a 12 hours time difference, after one hour you may get up .
你好,我也是中国学生,目前也在试着做句法分析,能沟通一下吗?
I do not have ready solution for correct bootstrapping for chinese, sorry
I can only suggest the direction
jarRoot
to jarRoot2
(merge dirs)
// Path to the folder with models extracted from `stanford-corenlp-3.8.0-models.jar`
//var jarRoot = @"..\..\..\..\data\paket-files\nlp.stanford.edu\stanford-corenlp-full-2017-06-09\models";
var jarRoot2 = @"..\..\..\..\data\paket-files\nlp.stanford.edu\stanford-chinese-corenlp-2017-06-09-models";
// Text for processing var text = "你好,我也是中国学生,目前也在试着做句法分析,能沟通一下吗?";
// Annotation pipeline configuration var propsFile = Path.Combine(jarRoot2, "StanfordCoreNLP-chinese.properties"); var props = new Properties(); //props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, mention, coref"); props.load(new FileReader(propsFile)); props.setProperty("ner.useSUTime", "0");
// We should change current directory, so StanfordCoreNLP could find all the model files automatically var curDir = Environment.CurrentDirectory; Directory.SetCurrentDirectory(jarRoot2); var pipeline = new StanfordCoreNLP(props); 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(); }
- try to understand new errors/find java sample that works
thank you
My email 1446129333@qq.com @cherryywei
i use the code you paste above ,it works a little but occurs erro the error message is
`java.lang.RuntimeException occurred HResult=0x80131500 Message=java.lang.RuntimeException: Error initializing coref system Source=stanford-corenlp-3.8.0 StackTrace: at edu.stanford.nlp.pipeline.CorefAnnotator..ctor(Properties props) at edu.stanford.nlp.pipeline.AnnotatorImplementations.coref(Properties properties) at edu.stanford.nlp.pipeline.StanfordCoreNLP.lambda$getNamedAnnotators$53(Properties , AnnotatorImplementations ) at edu.stanford.nlp.pipeline.StanfordCoreNLP.<>Anon15.apply(Object , Object ) at edu.stanford.nlp.pipeline.StanfordCoreNLP.lambda$getDefaultAnnotatorPool$65(Entry , Properties , AnnotatorImplementations ) at edu.stanford.nlp.pipeline.StanfordCoreNLP.<>Anon27.get() at edu.stanford.nlp.util.Lazy.3.compute() at edu.stanford.nlp.util.Lazy.get() at edu.stanford.nlp.pipeline.AnnotatorPool.get(String name) at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(Properties , Boolean , AnnotatorImplementations , AnnotatorPool ) 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 StanfordNLP.Program.Main(String[] args) in C:\Users\admin\source\repos\StanfordNLP\StanfordNLP\Program.cs:line 47
Inner Exception 1: RuntimeException: Error initializing coref system
Inner Exception 2: RuntimeIOException: java.io.IOException: Unable to open "edu/stanford/nlp/models/dcoref/demonyms.txt" as class path, filename or URL
Inner Exception 3: IOException: Unable to open "edu/stanford/nlp/models/dcoref/demonyms.txt" as class path, filename or URL`
i open the folder along the path, and do not find the directory [coref] in the location ,so there is no file dmonyms.txt.
if you have time please pay some attention .
I think that if should exist in http://nlp.stanford.edu/software/stanford-corenlp-full-2017-06-09.zip
the code is like this it can run when process english text but it can not process the chinese text
the code is comes from here ,i want to do some annotation about chinese text http://sergey-tihon.github.io/Stanford.NLP.NET/StanfordCoreNLP.html and i change the model directory to chinese but it did't work. the program still under the english model ,how can i set someting to deal with the chinese . can you help me ?