def get_conclusion(types_: List[WordType], matchings: Dict[int, int]) -> Atom: atomic_types = map(lambda type_: type_.get_atomic(), types_) atomic_types = list(chain.from_iterable(atomic_types)) atomic_indexes = set(map(lambda atomic: atomic.index, atomic_types)) missing = fst(list(set(k for k in matchings.keys()) - atomic_indexes)) missing = matchings[missing] conclusion = fst( list(filter(lambda atomic: atomic.index == missing, atomic_types))) return atomic_type_to_atom(conclusion, matchings)
def print_one( wpt: Tuple[Tuple[str, str], Sequence[Tuple[str, int]]]) -> str: def print_inner(inner: Sequence[Tuple[str, int]]) -> str: def print_pair(pair: Tuple[str, int]) -> str: return fst(pair) + ' #= ' + str(snd(pair)) return ' | '.join(list(map(print_pair, inner))) return fst(fst(wpt)) + '\t' + snd(fst(wpt)) + '\t' + print_inner( snd(wpt))
def project_one_dag(dag: DAG) -> List[Sequence[str]]: leaves = set(filter(dag.is_leaf, dag.nodes)) leaves = order_nodes(dag, leaves) leaves = list(map(lambda leaf: project_leaf(dag, leaf)[0:3], leaves)) return list( map( lambda leaf: (fst(leaf), snd(leaf).depolarize().__str__(), last(leaf)), leaves))
def print_pair(pair: Tuple[str, int]) -> str: return fst(pair) + ' #= ' + str(snd(pair))
def getkey(wtp: Sequence[str]) -> Tuple[str, str]: return fst(wtp), last(wtp)