<commit_before>GENDERS = ("masc", "femn", "neut", "Ms-f", "GNdr")

def get_token_features(candidate, case, grammemes):
    return ((g in t[3]["grammemes"] for g in grammemes) for t in (case, candidate))

def gram_label(token, value, stack):
    return value in token[3]["grammemes"]

def gram_not_label(token, value, stack):
    return not value in token[3]["grammemes"]

def gender_match_label(token, index, stack, genders=GENDERS):
    results = get_token_features(token, stack[index], genders)

    *case_token_genders, case_token_msf, case_token_gndr = next(results)
    *candidate_token_genders, candidate_token_msf, candidate_token_gndr = next(results)

    if not candidate_token_genders == case_token_genders:
        if case_token_msf:
            if any(candidate_token_genders[:2]):
                return True
        elif case_token_gndr or candidate_token_gndr:
            return True
    elif all(("plur" in stack[index][3]["grammemes"], "plur" in token[3]["grammemes"])):
        return True
    else:
        return True
    return False

def dictionary_label(token, values, stack):
    return any((n in values) for n in token[3]["forms"])

LABELS_LOOKUP_MAP = {
    "gram": gram_label,
    "gram-not": gram_not_label,
    "dictionary": dictionary_label,<commit_msg>Add gram-in and gram-not-in shortcut labels<commit_after>GENDERS = ("masc", "femn", "neut", "Ms-f", "GNdr")

def get_token_features(candidate, case, grammemes):
    return ((g in t[3]["grammemes"] for g in grammemes) for t in (case, candidate))

def gram_label(token, value, stack):
    return value in token[3]["grammemes"]

def gram_in_label(token, values, stack):
    return all(gram_label(token, value, stack) for value in values)

def gram_not_label(token, value, stack):
    return not value in token[3]["grammemes"]

def gram_not_in_label(token, values, stack):
    return all(gram_not_label(token, value, stack) for value in values)

def gender_match_label(token, index, stack, genders=GENDERS):
    results = get_token_features(token, stack[index], genders)

    *case_token_genders, case_token_msf, case_token_gndr = next(results)
    *candidate_token_genders, candidate_token_msf, candidate_token_gndr = next(results)

    if not candidate_token_genders == case_token_genders:
        if case_token_msf:
            if any(candidate_token_genders[:2]):
                return True
        elif case_token_gndr or candidate_token_gndr:
            return True
    elif all(("plur" in stack[index][3]["grammemes"], "plur" in token[3]["grammemes"])):
        return True
    else:
        return True
    return False

def dictionary_label(token, values, stack):
    return any((n in values) for n in token[3]["forms"])

LABELS_LOOKUP_MAP = {
    "gram": gram_label,
    "gram-in": gram_in_label,
    "gram-not": gram_not_label,
    "gram-not-in": gram_not_in_label,
    "dictionary": dictionary_label,
{'fraction_non_alphanumeric': 0.11817553559087768, 'fraction_numerical': 0.0048375950241879755, 'mean_word_length': 4.188172043010753, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1597667', 'n_tokens_mistral': 995, 'n_tokens_neox': 989, 'n_words': 244}