@Override public int hashCode() { return this.toString().hashCode(); }
@Override public int hashCode() { return this.toString().hashCode(); }
@Override public String toString() { String s = toString(true, 0); if (this.isLeaf()) s = "(" + s + ")"; return s; }
@Override public String toString() { String s = toString(true, 0); if (this.isLeaf()) s = "(" + s + ")"; return s; }
@Override public String toString() { return this.getPattern().toString(); }
@Override public String toString() { return this.getPattern().toString(); }
private List<String> getUniqueList(Tree<String> tree) { List<String> f = new ArrayList<>(); f.add(tree.getLabel()); for (Tree<String> child : tree.getChildren()) { f.add(child.toString().replaceAll("\\s+", " ")); } Collections.sort(f); return f; }
private List<String> getUniqueList(Tree<String> tree) { List<String> f = new ArrayList<>(); f.add(tree.getLabel()); for (Tree<String> child : tree.getChildren()) { f.add(child.toString().replaceAll("\\s+", " ")); } Collections.sort(f); return f; }
@Override public String toString() { if (trees == null) makeTrees(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < this.getTextAnnotation().getNumberOfSentences(); i++) { if (this.trees.get(i) != null) sb.append(this.getTree(i).toString()).append("\n"); } return sb.toString(); }
@Override public String toString() { if (trees == null) makeTrees(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < this.getTextAnnotation().getNumberOfSentences(); i++) { if (this.trees.get(i) != null) sb.append(this.getTree(i).toString()).append("\n"); } return sb.toString(); }
Tree<T> child = iterator.next(); treeString.append(child.toString(first, len));
Tree<T> child = iterator.next(); treeString.append(child.toString(first, len));
if (verbose) { logger.info("Comparing node: "); logger.info(node.toString());
if (verbose) { logger.info("Comparing node: "); logger.info(node.toString());
tree = ParseUtils.stripFunctionTags(tree); String[] treeLines = tree.toString().split("\n");
protected void addDependencyTree(Tree<Pair<String, Integer>> depTree, int sentStart, Constituent parent) { String word = depTree.getLabel().getFirst(); String token = this.getTextAnnotation().getToken(parent.getStartSpan()); word = treebankTokenHacks(word); token = treebankTokenHacks(token); assert word.trim().length() > 0; assert token.trim().length() > 0; if (!word.equals(token)) { logger.error(parent.getTextAnnotation().toString()); logger.error(depTree.toString()); throw new IllegalStateException("Expecting " + token + ", found " + word + " instead while constructing the dependency tree"); } for (int i = 0; i < depTree.getNumberOfChildren(); i++) { String relationLabel = depTree.getEdgeLabel(i).getFirst(); Tree<Pair<String, Integer>> child = depTree.getChild(i); Constituent childConstituent = getConstituentRelativeToSentenceStart(child, 1.0, sentStart, relationLabel); this.addConstituent(childConstituent, true); this.addRelation(new Relation(relationLabel, parent, childConstituent, 1.0)); addDependencyTree(child, sentStart, childConstituent); } }
protected void addDependencyTreeWithHack(Tree<Pair<String, Integer>> depTree, Constituent parent, int sentenceStart) { String word = depTree.getLabel().getFirst(); String token = this.getTextAnnotation().getToken(parent.getStartSpan()); word = treebankTokenHacks(word); token = treebankTokenHacks(token); assert word.trim().length() > 0; assert token.trim().length() > 0; if (!word.equals(token)) { logger.info(parent.getTextAnnotation().toString()); logger.info(depTree.toString()); throw new IllegalStateException("Expecting " + token + ", found " + word + " instead while constructing the dependency tree"); } for (int i = 0; i < depTree.getNumberOfChildren(); i++) { String relationLabel = depTree.getEdgeLabel(i).getFirst(); Tree<Pair<String, Integer>> child = depTree.getChild(i); Constituent childConstituent = getConstituentRelativeToSentenceStart(child, 1.0, sentenceStart, relationLabel); this.addConstituent(childConstituent); this.addRelation(new Relation(relationLabel, parent, childConstituent, 1.0)); addDependencyTreeWithHack(child, childConstituent, sentenceStart); } }
protected void addDependencyTree(Tree<Pair<String, Integer>> depTree, int sentStart, Constituent parent) { String word = depTree.getLabel().getFirst(); String token = this.getTextAnnotation().getToken(parent.getStartSpan()); word = treebankTokenHacks(word); token = treebankTokenHacks(token); assert word.trim().length() > 0; assert token.trim().length() > 0; if (!word.equals(token)) { logger.error(parent.getTextAnnotation().toString()); logger.error(depTree.toString()); throw new IllegalStateException("Expecting " + token + ", found " + word + " instead while constructing the dependency tree"); } for (int i = 0; i < depTree.getNumberOfChildren(); i++) { String relationLabel = depTree.getEdgeLabel(i).getFirst(); Tree<Pair<String, Integer>> child = depTree.getChild(i); Constituent childConstituent = getConstituentRelativeToSentenceStart(child, 1.0, sentStart, relationLabel); this.addConstituent(childConstituent); this.addRelation(new Relation(relationLabel, parent, childConstituent, 1.0)); addDependencyTree(child, sentStart, childConstituent); } }
protected void addDependencyTreeWithHack(Tree<Pair<String, Integer>> depTree, Constituent parent, int sentenceStart) { String word = depTree.getLabel().getFirst(); String token = this.getTextAnnotation().getToken(parent.getStartSpan()); word = treebankTokenHacks(word); token = treebankTokenHacks(token); assert word.trim().length() > 0; assert token.trim().length() > 0; if (!word.equals(token)) { logger.info(parent.getTextAnnotation().toString()); logger.info(depTree.toString()); throw new IllegalStateException("Expecting " + token + ", found " + word + " instead while constructing the dependency tree"); } for (int i = 0; i < depTree.getNumberOfChildren(); i++) { String relationLabel = depTree.getEdgeLabel(i).getFirst(); Tree<Pair<String, Integer>> child = depTree.getChild(i); Constituent childConstituent = getConstituentRelativeToSentenceStart(child, 1.0, sentenceStart, relationLabel); this.addConstituent(childConstituent, true); this.addRelation(new Relation(relationLabel, parent, childConstituent, 1.0)); addDependencyTreeWithHack(child, childConstituent, sentenceStart); } }