Je voudrais trouver le mot de tête de chaque phrase (constituant) d'un Tree
dans Stanford CoreNLP
, mais lorsque je tente tree.Parent()
pour l'une des constituents
, je reçois UnsupportedOperationException
. Qu'est-ce que je fais mal?Pourquoi ai-je UnsupportedOperationException avec Stanford CoreNLP
Voici mon code:
List<Tree> allConstituents = new ArrayList<>();
private Tree parseTree;
List<CoreMap> sentences = LoadAndParse(language, filetype, modelPath, text);
for (CoreMap sentence : sentences) {
Tree parse = sentence.get(TreeAnnotation.class);
allConstituents = parseTree.subTreeList();
for (int i = 0; i < allConstituents.size(); i++) {
Tree constituentTree = allConstituents.get(i);
HeadFinder headFinder = new SemanticHeadFinder();
String head = constituentTree.headTerminal(headFinder, constituentTree.parent());
}
}
Voici un exemple que j'ai:
Your tasks are challenging:
Je reçois 13 comme la taille de la parseTree.subTreeList()
, mais pour chacun d'eux, je reçois la UnsupportedOperationException
sur la méthode constituentTree.parent()
. Quelqu'un peut-il m'aider quelle est la bonne façon d'obtenir la tête sémantique de «tous» les constituants de l'arbre?
le problème semble être la méthode parente n'est pas implémentée pour ce type. Y a-t-il de la documentation sur Stanford CoreNLP? – Stultuske