/** * Get the path from the source TreebankNode to the target TreebankNode via the least common * ancestor. * * @param source * The TreebankNode where the path should start. * @param target * The TreebankNode where the path should end. * @return The path from the source node to the target node. */ public static TreebankNodePath getPath(TreebankNode source, TreebankNode target) { List<TreebankNode> sourceToRoot = getPathToRoot(source); List<TreebankNode> targetToRoot = getPathToRoot(target); TreebankNode ancestor = null; while (sourceToRoot.size() > 0 && targetToRoot.size() > 0 && sourceToRoot.get(sourceToRoot.size() - 1) == targetToRoot.get(targetToRoot.size() - 1)) { ancestor = sourceToRoot.remove(sourceToRoot.size() - 1); ancestor = targetToRoot.remove(targetToRoot.size() - 1); } return new TreebankNodePath(ancestor, sourceToRoot, targetToRoot); }
throws CleartkExtractorException { List<TreebankNode> fromStart = TreebankNodeUtil.getPathToRoot(leftConstituent); List<TreebankNode> fromEnd = TreebankNodeUtil.getPathToRoot(rightConstituent); String pathFeatureName = null; String lengthFeatureName = null;