简体   繁体   English

如何使用Stanford Parser使用Java获取POS标签?

[英]How to use Stanford Parser to get POS tags using java?

I am working on a project for plagiarism detection. 我正在从事抄袭检测项目。 I need to use Stanford Parser API to get Part of Speech (POS) tags for words in sentences stored in a text file. 我需要使用Stanford Parser API为存储在文本文件中的句子中的单词获取词性(POS)标记。

I understand that the class edu.Stanford.nlp.parser.lexparser.LexicalizedParser can be used for this purpose. 我知道可以将edu.Stanford.nlp.parser.lexparser.LexicalizedParser类用于此目的。 But I am unable to get it working. 但是我无法使其正常工作。

Can anyone please tell me how I can write a code in java that can make use of this class or some other class available in the API to get POS tags? 谁能告诉我如何用Java编写可利用此类或API中提供的其他类来获取POS标签的代码?

Thank you very much 非常感谢你

Look at the starter files ParserDemo.java and ParserDemo2.java included in the distribution. 查看分发中包含的启动文件ParserDemo.javaParserDemo2.java They show simple examples of calling the parser in code. 它们显示了在代码中调用解析器的简单示例。 In particular, in ParserDemo2.java see the call parse.taggedYield() , which returns a List of TaggedWord from which you can ask for the tag() of each item. 特别是,在ParserDemo2.java请参见parse.taggedYield()调用,该调用返回一个TaggedWord List ,您可以从中请求每个项目的tag()

However, if all you want is a part-of-speech tagger, you will find it is faster and less memory intensive to just use a part-of-speech tagger, such as the Stanford Part-of-Speech Tagger . 但是,如果您只想使用词性标记器,您会发现仅使用词性标记器(例如Stanford词性Tagger)会更快,内存占用更少。

The Javadoc can be found here: http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/package-summary.html . 可以在以下位置找到Javadoc: http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/package-summary.html : http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/parser/lexparser/package-summary.html Note that the package name ( edu.stanford.nlp.parser.lexparser ) is case-sensitive and you have written Stanford . 请注意,程序包名称( edu.stanford.nlp.parser.lexparser )区分大小写,并且您已编写Stanford This will mean you get "ClassNotFoundException". 这将意味着您收到“ ClassNotFoundException”。

You don't give any other information or error messages so it is difficult to give further help. 您不提供任何其他信息或错误消息,因此很难提供进一步的帮助。 Do you need help compiling and running Java packages? 您需要编译和运行Java软件包的帮助吗? If so, solve that before tackling the NLP. 如果是这样,请先解决该问题,再处理NLP。

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

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