简体   繁体   中英

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.

I understand that the class edu.Stanford.nlp.parser.lexparser.LexicalizedParser can be used for this purpose. 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?

Thank you very much

Look at the starter files ParserDemo.java and ParserDemo2.java included in the distribution. 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.

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 .

The Javadoc can be found here: 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 . This will mean you get "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? If so, solve that before tackling the NLP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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