user1906563
user1906563

Reputation: 45

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

Upvotes: 0

Views: 3497

Answers (2)

Christopher Manning
Christopher Manning

Reputation: 9450

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.

Upvotes: 1

peter.murray.rust
peter.murray.rust

Reputation: 38033

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.

Upvotes: 0

Related Questions