static Web web_ifThen(Web inputWeb, Web web) { Web patternWeb, Map patternMap = unpair cloneWebWithMap(web); web_dropRelationsStartingWith(patternWeb, "Then:"); Web thenWeb, Map thenMap = unpair cloneWebWithReverseMap(web); web_unpackRelationsStartingWith(thenWeb, "Then:"); Map match = web_matchAllPerms_partial(patternWeb, inputWeb); if (match != null) { // Then add relations from thenWeb for (WebRelation rel : web_relationObjects(thenWeb)) { WebNode a = mapGet(match, mapGet(patternMap, mapGet(thenMap, rel.a)); WebNode b = mapGet(match, mapGet(patternMap, mapGet(thenMap, rel.b)); if (a != null && b != null) { WebRelation rel2 = inputWeb.getRelation(a, b); web_addLabelsFromNodeToNode(rel, rel2); } } } ret inputWeb; }