繁体   English   中英

斯坦福大学NLP Java方法转换问题

[英]Stanford NLP Java Method Translation Issue

我正在通过IKVM Java接口在C#中使用Stanford 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 但是,当我尝试访问注释以提取注释中的各种实体时,我遇到了麻烦。 使用以下代码: 如何使用Stanford解析器将文本拆分为句子?

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

尚不清楚如何将SentencesAnnotation.class转换为C#将接受的内容。

通常,Java Foo.class转换为C#typeof(Foo),因此C#应该接受以下内容:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM