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