static bool web_matchNodeLists_x_debug; // nodeMatcher: func(WebNode, WebNode) -> double static int web_matchNodeLists_x(L l1, L l2, O nodeMatcher) { if (l(l1) != l(l2)) ret -1000; int score = 0; if (empty(l1)) ret score; HashMap map = twoListsToHashMap(l1, l2); Web web = first(l1).web, web2 = first(l2).web; // Score nodes for i over l1: { WebNode a = l1.get(i), b = l2.get(i); score += toDouble(callF(nodeMatcher, a, b)); } // Score relations for (WebRelation rel : web_relationObjects(web)) { WebNode aa = map.get(rel.a), bb = map.get(rel.b); if (aa == null || bb == null) continue; WebRelation rel2 = web2.getRelationOpt(aa, bb); if (web_matchNodeLists_x_debug) print("a=" + rel.a + ", b=" + rel.b + ", aa=" + aa + ", bb=" + bb + ", rel2 labels=" + (rel2 == null ? "-" : str(rel2.labels)) + ", labels=" + rel.labels); //if (rel2 == null || !containsAll(rel2.labels, rel.labels)) // --score; if (rel2 == null) --score; else score += toDouble(callF(nodeMatcher, rel, rel2)); } ret score; }