if (node.isLeaf() || node.children().length < 2) {
continue;
}
// every child with a different head (or repeated) is an argument
Label l = node.label();
TaggedWord w = null;
if (hf != null) {
Tree hwt = node.headPreTerminal(hf);
if (hwt != null) {
w = new TaggedWord(hwt.children()[0].label(), hwt.label());
}
} else {
if (l instanceof HasWord && l instanceof HasTag) {
w = new TaggedWord(((HasWord) l).word(), ((HasTag) l).tag());
}
}
boolean seenHead = false;
for (Tree child : node.children()) {
Label dl = child.label();
TaggedWord dw = null;
if (hf != null) {
Tree dwt = child.headPreTerminal(hf);
if (dwt != null) {
dw = new TaggedWord(dwt.children()[0].label(), dwt.label());
}
} else {
if (dl instanceof HasWord && dl instanceof HasTag) {
dw = new TaggedWord(((HasWord) dl).word(), ((HasTag) dl).tag());
}
}
// System.out.println("XX Doing pair: " + l + ", " + dl +
// " gives " + w + ", " +dw);
if (w != null && w.word() != null && w.tag() != null && dw != null && w.word().equals(dw.word()) && w.tag().equals(dw.tag()) && !seenHead) {
seenHead = true;
} else {
Dependency<Label, Label, Object> p = new UnnamedDependency(w, dw);
if (f.accept(p)) {
deps.add(p);