J'ai essayé d'analyser une phrase en utilisant l'analyseur Stanford, mais j'ai l'exception. Le fichier d'entrée, le code et l'exception sont spécifiés ci-dessous.Exception d'argument non valide avec Stanford Parser
Je pense que le problème vient du fait que le penn tree dans le fichier d'entrée ne gère pas la ponctuation. Comment générer un penn tree qui gère aussi la ponctuation?
fichier d'entrée
(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 posée:
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)