private static List<String> myMakeObjects(Tree tree) { List<String> cats = new LinkedList<>(); for (Tree st : tree.subTreeList()) { cats.add(st.value()); } return cats; }
/** * Build the set of dependencies for evaluation. This set excludes all dependencies for which the * argument is a punctuation tag. */ @Override protected Set<?> makeObjects(Tree tree) { Set<Dependency<Label, Label, Object>> deps = new HashSet<Dependency<Label, Label, Object>>(); for (Tree node : tree.subTreeList()) { if (DEBUG) EncodingPrintWriter.err.println("Considering " + node.label()); // every child with a different head is an argument, as are ones with // the same head after the first one found if (node.isLeaf() || node.children().length < 2) { continue; } // System.err.println("XXX node is " + node + "; label type is " + // node.label().getClass().getName()); String head = ((HasWord) node.label()).word(); boolean seenHead = false; for (int cNum = 0; cNum < node.children().length; cNum++) { Tree child = node.children()[cNum]; String arg = ((HasWord) child.label()).word(); if (DEBUG) EncodingPrintWriter.err.println("Considering " + head + " --> " + arg); if (head.equals(arg) && !seenHead) { seenHead = true; if (DEBUG) EncodingPrintWriter.err.println(" ... is head"); } else if (!punctFilter.accept(arg)) { deps.add(new UnnamedDependency(head, arg)); if (DEBUG) EncodingPrintWriter.err.println(" ... added"); } else if (DEBUG) { if (DEBUG) EncodingPrintWriter.err.println(" ... is punct dep"); } } } if (DEBUG) { EncodingPrintWriter.err.println("Deps: " + deps); } return deps; }
@Override protected Set<String> makeObjects(Tree tree) { Set<String> localTrees = Generics.newHashSet(); for (Tree st : tree.subTreeList()) { localTrees.add(localize(st)); } return localTrees; }