def run_compare_sgb_and_siy_to_base(fs): """[str] -> {utf-8-char:set<lev.Rule>} ((sgb <=> base) & (sgb <=> base)) - (map (<=> base) rest)""" sgb = fs[2] siy = fs[8] base = fs[0] del fs[8] del fs[2] del fs[0] # dangerous but who cares outsiders = dct.zipwith(and_, classify(compare(base, sgb)), classify(compare(base, siy)), default=set()) others = map(compose(classify, cur(compare, base)), fs) kws = {"default": set()} return dct.zipwith((lambda v, *rest: reduce(sub, rest, v)), outsiders, *others, **kws)
def run_compare_all_to_sgbsiy(fs): """[str] -> {utf-8-char:set<lev.Rule>} (siy<=>sgb) - (map (base<=>) rest)""" sgb = fs[2] siy = fs[8] base = fs[0] del fs[8] del fs[2] del fs[0] # dangerous but who cares diff = classify(compare(sgb, siy)) others = map(compose(classify, cur(compare, base)), fs) # return dct_mapall(lambda v,*rest: reduce(sub, rest, v), diff, *others) kws = {"default": set()} return dct.zipwith((lambda v, *rest: reduce(sub, rest, v)), diff, *others, **kws)
def groupavg((c1,c2)): "group average" return avg(map(compose(edges.__getitem__, frozenset), cross(flatten(c1), flatten(c2))))
def complete((c1,c2)): "complete link" return max(map(compose(edges.__getitem__, frozenset), cross(flatten(c1), flatten(c2))))
def single((c1,c2)): "single link" return min(map(compose(edges.__getitem__, frozenset), cross(flatten(c1), flatten(c2))))