# Path: pycryptics/utils/synonyms.py
# SYNONYMS = msgpack.load(f, use_list=False)
# 
# Path: pycryptics/utils/ngrams.py
# NGRAMS = msgpack.load(f, use_list=False)
# 
# Path: pycryptics/utils/transforms.py
# def split_words(ans, lengths):
#     j = 0
#     words = []
#     stop = 0
#     for l in lengths:
#         stop = j + l
#         if j >= len(ans):
#             return words
#         elif stop >= len(ans):
#             stop = len(ans)
#         words.append(ans[j:stop])
#         j += l
#     return words


from pycryptics.utils.synonyms import SYNONYMS
from pycryptics.utils.ngrams import NGRAMS
from pycryptics.utils.transforms import split_words
    from pycryptics.parse_and_solve import constraints
                candidate = partial + l
                valid = True
                for j, w in enumerate(split_words(candidate, constraints.lengths)):
                    if not w in NGRAMS[constraints.lengths[j]]:
                        valid = False
                        break
                if valid:
                    new_active_set[candidate] = lc.copy()
                    if new_active_set[candidate][l] == 1:
                        new_active_set[candidate].pop(l)
                    else:
                        new_active_set[candidate][l] -= 1
        # print new_active_set
        # import pdb; pdb.set_trace()
        if len(new_active_set) == 0:
            return None
        else:
            active_set = new_active_set
    # return active_set
    return [a for a in active_set if a != word]

def bigram_filter(answers, constraints):
    threshold = len(constraints.lengths) - 1  # allow violations across word boundaries

    valid_answers = []
    for ans in answers:
        violations = 0
        for i in range(len(ans)-1):
            ok = False
            for l in constraints.lengths:

# Path: pycryptics/utils/synonyms.py
# SYNONYMS = msgpack.load(f, use_list=False)
# 
# Path: pycryptics/utils/ngrams.py
# NGRAMS = msgpack.load(f, use_list=False)
# 
# Path: pycryptics/utils/transforms.py
# def split_words(ans, lengths):
#     j = 0
#     words = []
#     stop = 0
#     for l in lengths:
#         stop = j + l
#         if j >= len(ans):
#             return words
#         elif stop >= len(ans):
#             stop = len(ans)
#         words.append(ans[j:stop])
#         j += l
#     return words


# Path: pycryptics/utils/clue_funcs.py
from pycryptics.utils.synonyms import SYNONYMS
from pycryptics.utils.ngrams import NGRAMS
from pycryptics.utils.transforms import split_words
    from pycryptics.parse_and_solve import constraints

                candidate = partial + l
                valid = True
                for j, w in enumerate(split_words(candidate, constraints.lengths)):
                    if not w in NGRAMS[constraints.lengths[j]]:
                        valid = False
                        break
                if valid:
                    new_active_set[candidate] = lc.copy()
                    if new_active_set[candidate][l] == 1:
                        new_active_set[candidate].pop(l)
                    else:
                        new_active_set[candidate][l] -= 1
        # print new_active_set
        # import pdb; pdb.set_trace()
        if len(new_active_set) == 0:
            return None
        else:
            active_set = new_active_set
    # return active_set
    return [a for a in active_set if a != word]

def bigram_filter(answers, constraints):
    threshold = len(constraints.lengths) - 1  # allow violations across word boundaries

    valid_answers = []
    for ans in answers:
        violations = 0
        for i in range(len(ans)-1):
            ok = False
            for l in constraints.lengths:

                if ans[i:i+2] in NGRAMS[l]: