【问题标题】:Stanford NLP CoreNLP .NET斯坦福 NLP CoreNLP .NET
【发布时间】:2017-06-12 08:31:10
【问题描述】:

尝试运行示例但我一直无法打开“english-left3words-distim.tagger”文件可能丢失。文件没有丢失,目录指向模型jar文件的位置,jar文件中路径:edu\stanford\nlp\models\pos-tagger\english-left3words是正确的。

我正在使用 3.7.0,从 Visual Studio 2015 中的 nuget 安装。

下面是代码:

var jarRoot = @"E:\VS Projects\Stanford.NLP.NET-master\Jar-files";


        // 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, parse, ner, dcoref");


        // We should change current directory, so StanfordCoreNLP could find all the model files automatically
        var curDir = Environment.CurrentDirectory;
        Directory.SetCurrentDirectory(jarRoot);
        var pipeline = new StanfordCoreNLP(props);
        Directory.SetCurrentDirectory(curDir);


        // Annotation
        var document = new Annotation(text);
        pipeline.annotate(document);

        // Result - Pretty Print
        using (var stream = new ByteArrayOutputStream())
        {
            pipeline.prettyPrint(document, new PrintWriter(stream));
            Console.WriteLine(stream.toString());
            stream.close();
        }

我确实在 Stack 上看到了一个类似的问题,他们没有指向 jar 文件,但我指向的是 jar 文件所在的正确位置。有什么想法吗?

【问题讨论】:

    标签: c# stanford-nlp


    【解决方案1】:

    最终我将目录指向实际的文件夹,解压后的 jar 文件,并且成功了。一个堆栈问题正好相反,这非常令人困惑......

    【讨论】:

      猜你喜欢
      • 2019-03-17
      • 2014-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-05
      • 1970-01-01
      相关资源
      最近更新 更多