sergey-tihon / Stanford.NLP.NET

Stanford NLP for .NET
http://sergey-tihon.github.io/Stanford.NLP.NET/
MIT License
598 stars 123 forks source link

{"edu.stanford.nlp.io.RuntimeIOException: Error while loading a tagger model (probably missing model file)"} #71

Closed ltdhvktqs closed 2 years ago

ltdhvktqs commented 7 years ago

I download this project and try to run but it error at:

var pipeline = new StanfordCoreNLP(props);

Can you help me to fix it. 2017-07-26_16-25-36

sergey-tihon commented 7 years ago

The error says that you have to model on your machine. You should start from build.cmd in the project root. (it downloads several DB of zips from Stanford first)

zahra1394 commented 5 years ago

The error says that you have to model on your machine. You should start from build.cmd in the project root. (it downloads several DB of zips from Stanford first)

excuse me I couldn't understand what should be done exactly. can you describe the solution?

sergey-tihon commented 5 years ago
ghost commented 5 years ago

@ltdhvktqs did you solve your problem? I am also facing the same problem :(

ghost commented 5 years ago

@sergey-tihon I am not able to find a build.cmd file

This is the extracted folder when I downloaded stanford-corenlp-full-2018-10-05.zip

image

I am also facing the same problem

image

I have also posted a question on SO here

sergey-tihon commented 5 years ago

build.cmd is the way to compile this Githug repo. - https://github.com/sergey-tihon/Stanford.NLP.NET/blob/master/build.cmd if you clone or download this.

@kunalm3701 In your case you need change current directory to D:\stanford-corenlp-full-2018-10-05\

P.S. http://apollo13cn.blogspot.com/2018/10/f-stanford-nlp-is-running.html

ghost commented 5 years ago

@sergey-tihon I am still getting the missing model file error even after explicitly placing the edu folder into the bin>debug folder.

image


This is the source code which I am using to programmatically train the custom relation model to get the serialized .ser file.

using java.util;
using System.Collections.Generic;

namespace StanfordRelationDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            //string jarRoot = @"D:\Stanford English Model\stanford-english-corenlp-2018-10-05-models\";
            //string modelsDirectory = jarRoot + @"edu\stanford\nlp\models";
            //string sutimeRules = modelsDirectory + @"\sutime\defs.sutime.txt,"
            //                  //+ modelsDirectory + @"\sutime\english.holidays.sutime.txt,"
            //                  + modelsDirectory + @"\sutime\english.sutime.txt";

            Properties props = new Properties();
            props.setProperty("annotators", "pos, lemma, parse");
            props.setProperty("parse.maxlen", "100");
            props.setProperty("datasetReaderClass", "edu.stanford.nlp.ie.machinereading.domains.roth.RothCONLL04Reader");
            props.setProperty("trainPath", "D://stanford-corenlp-full-2017-06-09//birthplace.corp");
            props.setProperty("crossValidate", "false");
            props.setProperty("kfold", "10");
            props.setProperty("trainOnly", "true");
            props.setProperty("trainUsePipelineNER", "true");
            props.setProperty("serializedTrainingSentencesPath", "D://stanford-corenlp-full-2017-06-09//rel//sentences.ser");
            props.setProperty("serializedEntityExtractorPath", "D://stanford-corenlp-full-2017-06-09//rel//entity_model.ser");
            props.setProperty("serializedRelationExtractorPath", "D://stanford-corenlp-full-2017-06-09//rel//roth_relation_model_pipeline.ser");
            props.setProperty("relationResultsPrinters", "edu.stanford.nlp.ie.machinereading.RelationExtractorResultsPrinter");
            props.setProperty("entityClassifier", "edu.stanford.nlp.ie.machinereading.domains.roth.RothEntityExtractor");
            props.setProperty("extractRelations", "true");
            props.setProperty("extractEvents", "false");
            props.setProperty("extractEntities", "false");

            props.setProperty("trainOnly", "true");
            props.setProperty("relationFeatures", "arg_words,arg_type,dependency_path_lowlevel,dependency_path_words,surface_path_POS,entities_between_args,full_tree_path");

            var propertyKeys = props.keys();
            var propertyStringArray = new List<string>();
            while (propertyKeys.hasMoreElements())
            {
                var key = propertyKeys.nextElement();
                propertyStringArray.Add($"-{key}");
                propertyStringArray.Add(props.getProperty(key.ToString(), string.Empty));
            }

            var machineReader = edu.stanford.nlp.ie.machinereading.MachineReading.makeMachineReading(propertyStringArray.ToArray());
            var utestResultList = machineReader.run();
        }
    }
}

Its throwing an exception on this line:

var machineReader = edu.stanford.nlp.ie.machinereading.MachineReading.makeMachineReading(propertyStringArray.ToArray());

image

sergey-tihon commented 2 years ago

Close as an old issue