Hi,
I tried to parse a sentence using stanford parser, but i get the exception please help me. the input file, code and exception are specified below
I think the problem is because the penn tree in input file doesnot handle punctuations, how to generate penn tree that handles punctuation too?
Input file
(ROOT
(S
(NP (DT A) (NN doctor) (NN investigation) (NN system) (NN (DIS)))
(VP (VBZ is)
(NP
(NP (DT a) (NN part))
(PP (IN of)
(NP (DT a) (NN hospital) (NN information) (NN system) (NN (HIS).)))))))
code
String str="-collapsed -treeFile temp.txt";
String ar[]=str.split(" ");
edu.stanford.nlp.trees.EnglishGrammaticalStructure.main(ar);
try {
FileOutputStream fw = new FileOutputStream("k.txt");
PrintStream out = new PrintStream(fw);
System.setOut(out);
} catch (Exception e) {
System.out.print(e);
}
Exception raised :
Head is null: NN-37
Exception in thread "main" java.lang.IllegalArgumentException: governor or dependent cannot be null
at edu.stanford.nlp.trees.UnnamedDependency.<init>(UnnamedDependency.java:105)
at edu.stanford.nlp.trees.TreeGraphNode.dependencies(TreeGraphNode.java:519)
at edu.stanford.nlp.trees.Tree.dependencies(Tree.java:1090)
at edu.stanford.nlp.trees.GrammaticalStructure.<init>(GrammaticalStructure.java:71)
at edu.stanford.nlp.trees.EnglishGrammaticalStructure.<init>(EnglishGrammaticalStructure.java:115)
at edu.stanford.nlp.trees.EnglishGrammaticalStructure.<init>(EnglishGrammaticalStructure.java:89)
at edu.stanford.nlp.trees.EnglishGrammaticalStructure.<init>(EnglishGrammaticalStructure.java:61)
at edu.stanford.nlp.trees.EnglishGrammaticalStructure.<init>(EnglishGrammaticalStructure.java:53)