sergey-tihon / Stanford.NLP.NET

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

Multi languages #81

Closed WEMAPP closed 6 years ago

WEMAPP commented 6 years ago

Hi, could I know how to change the code below to use it with multiple languages ​​at the same time? thank you


            var jarRoot = @"stanford-corenlp-full-2017-06-09\";

            var props = new Properties();

            props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
            props.setProperty("sutime.binders", "0");
            props.setProperty("ner.useSUTime", "false");
            // We should change current directory, so StanfordCoreNLP could find all the model files automatically 
            var curDir = AppDomain.CurrentDomain.BaseDirectory;
            var sutimeRules = Path.Combine(curDir, jarRoot) + @"edu\stanford\nlp\models\sutime\defs.sutime.txt,"
          + Path.Combine(curDir, jarRoot) + @"edu\stanford\nlp\models\sutime\english.holidays.sutime.txt,"
          + Path.Combine(curDir, jarRoot) + @"edu\stanford\nlp\models\sutime\english.sutime.txt";
            props.setProperty("sutime.rules", sutimeRules);

            Classifier = CRFClassifier.getClassifierNoExceptions(
                Path.Combine(curDir, jarRoot) + @"edu\stanford\nlp\models\ner\english.all.3class.distsim.crf.ser.gz");

            pipeline = new StanfordCoreNLP(props);
            pipeline.addAnnotator(new TimeAnnotator("sutime", props));
            var annotation = new Annotation(@"");

            pipeline.annotate(annotation);
sergey-tihon commented 6 years ago

Sorry, but I think that this is not supported.

You may try to

  1. Find tools that have language identification capability (with the quality acceptable for your task). Note that Stanford NLP does not provide such API - https://stackoverflow.com/questions/29290107/detecting-language-using-stanford-nlp

  2. Create different pipelines for all languages you want to support and for which you can find trained models (or train your own) - https://github.com/stanfordnlp/CoreNLP/issues/474

  3. Choose pipeline based on prediction from 1.