Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Extract subject Verb Object using nlp java

Tags:

nlp

How to Extract SVO using NLP in java, i am new in nlp.i am currently using opennlp. but how to do in java with a perticular in java sentence.

LexicalizedParser lp = **new LexicalizedParser("englishPCFG.ser.gz");**
String[] sent = { "This", "is", "an", "easy", "sentence", "." };
Tree parse = (Tree) lp.apply(Arrays.asList(sent));
parse.pennPrint();
System.out.println();
TreePrint tp = new TreePrint("penn,typedDependenciesCollapsed");
tp.print(parse);

getting an compilation error at new LexicalizedParser("englishPCFG.ser.gz");** The constructor LexicalizedParser(String) is undefined

like image 563
Sonia Gupta Avatar asked Nov 03 '22 19:11

Sonia Gupta


1 Answers

it seems as if you are using new version of Stanford NLP parser. in new version of this parser constructors are not used to allocate memory, instead we are having dedicated functions . you can use :

LexicalizedParser lp = LexicalizedParser.loadModel("englishPCFG.ser.gz");

you can use various overloads of this API.

Stanford documentation for various overloads of loadModel

like image 187
Jyoti Gupta Avatar answered Nov 09 '22 08:11

Jyoti Gupta