【问题标题】:Stanford NLP Java Method Translation Issue斯坦福 NLP Java 方法翻译问题
【发布时间】:2019-06-26 21:11:31
【问题描述】:

我通过 IKVM Java 接口在 C# 中使用斯坦福 NLP 工具。也从https://sergey-tihon.github.io/Stanford.NLP.NET/StanfordCoreNLP.html得到想法

String text = "This is a test sentence.";
var props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, parse");
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(modelsDirectory);
var pipeline = new StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);
var annotation = new Annotation(text);
pipeline.annotate(annotation);

此代码可以很好地获取我的Annotation。但是,当我尝试访问注释以提取注释中的各种实体时,我遇到了麻烦。使用以下代码:How can I split a text into sentences using the Stanford parser?

List<CoreMap> sentences = annotation.get(SentencesAnnotation.class);

不清楚如何将SentencesAnnotation.class 翻译成 C# 可以接受的东西。

【问题讨论】:

    标签: java c# stanford-nlp translate


    【解决方案1】:

    一般来说,Java Foo.class 转换为 C# typeof(Foo),所以 C# 应该接受以下内容:

    IList<CoreMap> sentences = annotation.get(typeof(SentencesAnnotation));
    

    【讨论】:

    • 我只能使用 var 类型来编译代码和 sentences 填充。
    猜你喜欢
    • 2014-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-03
    • 2010-12-23
    • 2015-04-30
    • 2014-04-20
    相关资源
    最近更新 更多