def decypher_code(code): """Yields all possible meanings of a number.""" ln_w = len(code) valid_codes = set(R_MAP.keys()) for grps in utils.all_groups_in_order(code, (1, 2, 3)): grps = tuple(("".join(grp) for grp in grps)) if set(grps) <= valid_codes: yield tuple((R_MAP[e] for e in grps))
def cypher_word(word): """Yields all possible cypherings of a word, as tuples (codes, factor_crypted). """ ln_w = len(word) for grps in utils.all_groups_in_order(word, (1, 2, 3)): cyphered = 0 y = [] for el in grps: el = "".join(el) if el in MAP: y.append(MAP[el]) cyphered += len(el) else: y.append(" ".join(el)) yield (" ".join(y), cyphered / ln_w)
def cypher_word(word, c_map, c_sep): """ Yields all possible cypherings of a word, as tuples (codes, factor_cyphered). factor_cyphered = nbr cyphered letters / nbr letters. """ ln_w = len(word) for grps in utils.all_groups_in_order(word, (1, 2, 3)): cyphered = 0 y = [] for el in grps: el = "".join(el) if el in c_map: y.append(c_map[el]) cyphered += len(el) else: y.append(c_sep.join(el)) yield (c_sep.join(y), cyphered / ln_w)
def cypher_word(word, syllable): """ Yields all possible cypherings of a word, as tuples (codes, factor_cyphered). factor_cyphered = nbr added syllables / nbr letters. """ ln_w = len(word) for grps in utils.all_groups_in_order(word, (1, 2)): cyphered = 0 y = [] first = True for el in grps: el = "".join(el) cyp = _obfuscate_syllable(el, syllable, first) if cyp != el: cyphered += 1 y.append(cyp) if first: first = False yield ("".join(y), cyphered / ln_w)