<commit_before>"""Test minimum edit distance corrections."""
import csv
import itertools
from nltk.corpus import cmudict
import numpy as np

# The magical arpabet.
ARPABET = cmudict.dict()

# Constants for generating command options.
BLOCK_IDS = [str(val) for val in range(1, 11)]
VALUE_SETS = [
    ['up', 'down'],
    ['left', 'right'],
    ['45', '72', '90', '120', '144'],
    ['2', '3', '4', '5']]
BLOCK_TYPES = ['move', 'turn', 'pen', 'color', 'repeat']

# Various corrections that are necessary to obtain a phonetic
# representation from arpabet.
SYM_MAP = {
    '1': 'one',
    '2': 'two',
    '3': 'three',
    '4': 'four',
    '5': 'five',
    '6': 'six',
    '7': 'seven',
    '8': 'eight',
    '9': 'nine',
    '10': 'ten',
    '45': 'forty five',
    '52': 'fifty two',
    '72': 'seventy two',
    '90': 'ninety',
    '95': 'ninety five',
    '100': 'one hundred',
    '120': 'one twenty',
    '124': 'one twenty four',
    '144': 'one forty four',
    '245': 'two forty five',
    '290': 'two ninety',
    '300': 'three hundred',
    '360': 'three sixty',
    '400': 'four hundred',
    '500': 'five hundred',
    '700': 'seven hundred',
    '+': 'plus',
    'k\'nex': 'connects',
    '6-2': 'six two',
    '1:20': 'one twenty',
    '1:44': 'one forty four',
    'lakhs': 'locks',
    '1/2': 'one half',
    'xbox': 'box',
    'blog': 'bog',
    '$2': 'two',
    'walkthrough': 'walk through',
    'nextflix': 'net flicks',
    'hr': 'her',
    '3-under': 'three under',
    '5-under': 'five under',
    'loc': 'lock',
    'kinect': 'connect',
    'tutuapp': 'two to'
}

def gen_get(block_types):
    """Generate all GET commands.

    Args:
        block_types: List of all possible block types.

    Returns:
        List of all valid GET commands.
    """
    get = lambda btype: 'get a ' + btype + ' block'
    return [get(btype) for btype in block_types]

def gen_move(block_ids):
    """Generate all MOVE commands.

    Args:
        block_ids: List of all block IDs that are (hypothetically) in the workspace.

    Returns:
        List of all valid MOVE commands.
    """
    # Useful lambdas.
    move_after = lambda bid1, bid2: 'move block ' + bid1 + ' after block ' + bid2
    move_inside = lambda bid1, bid2: 'move block ' + bid1 + ' inside block ' + bid2

    # Do the generating.
    coms = []
    for (bid1, bid2) in itertools.combinations(block_ids, 2):
        coms.append(move_after(bid1, bid2))
        coms.append(move_after(bid2, bid1))
        coms.append(move_inside(bid1, bid2))
        coms.append(move_inside(bid2, bid1))
    return coms

def gen_change(block_ids, value_sets):<commit_msg>Oops...generate "connect" commands instead of "move" commands<commit_after>"""Test minimum edit distance corrections."""
import csv
import itertools
from nltk.corpus import cmudict
import numpy as np

# The magical arpabet.
ARPABET = cmudict.dict()

# Constants for generating command options.
BLOCK_IDS = [str(val) for val in range(1, 11)]
VALUE_SETS = [
    ['up', 'down'],
    ['left', 'right'],
    ['45', '72', '90', '120', '144'],
    ['2', '3', '4', '5']]
BLOCK_TYPES = ['move', 'turn', 'pen', 'color', 'repeat']

# Various corrections that are necessary to obtain a phonetic
# representation from arpabet.
SYM_MAP = {
    '1': 'one',
    '2': 'two',
    '3': 'three',
    '4': 'four',
    '5': 'five',
    '6': 'six',
    '7': 'seven',
    '8': 'eight',
    '9': 'nine',
    '10': 'ten',
    '45': 'forty five',
    '52': 'fifty two',
    '72': 'seventy two',
    '90': 'ninety',
    '95': 'ninety five',
    '100': 'one hundred',
    '120': 'one twenty',
    '124': 'one twenty four',
    '144': 'one forty four',
    '245': 'two forty five',
    '290': 'two ninety',
    '300': 'three hundred',
    '360': 'three sixty',
    '400': 'four hundred',
    '500': 'five hundred',
    '700': 'seven hundred',
    '+': 'plus',
    'k\'nex': 'connects',
    '6-2': 'six two',
    '1:20': 'one twenty',
    '1:44': 'one forty four',
    'lakhs': 'locks',
    '1/2': 'one half',
    'xbox': 'box',
    'blog': 'bog',
    '$2': 'two',
    'walkthrough': 'walk through',
    'nextflix': 'net flicks',
    'hr': 'her',
    '3-under': 'three under',
    '5-under': 'five under',
    'loc': 'lock',
    'kinect': 'connect',
    'tutuapp': 'two to'
}

def gen_get(block_types):
    """Generate all GET commands.

    Args:
        block_types: List of all possible block types.

    Returns:
        List of all valid GET commands.
    """
    get = lambda btype: 'get a ' + btype + ' block'
    return [get(btype) for btype in block_types]

def gen_move(block_ids):
    """Generate all MOVE commands.

    Args:
        block_ids: List of all block IDs that are (hypothetically) in the workspace.

    Returns:
        List of all valid MOVE commands.
    """
    # Useful lambdas.
    connect_under = lambda bid1, bid2: 'connect block ' + bid1 + ' under block ' + bid2
    connect_inside = lambda bid1, bid2: 'connect block ' + bid1 + ' inside block ' + bid2

    # Do the generating.
    coms = []
    for (bid1, bid2) in itertools.combinations(block_ids, 2):
        coms.append(connect_under(bid1, bid2))
        coms.append(connect_under(bid2, bid1))
        coms.append(connect_inside(bid1, bid2))
        coms.append(connect_inside(bid2, bid1))
    return coms

def gen_change(block_ids, value_sets):
{'fraction_non_alphanumeric': 0.18098274568642161, 'fraction_numerical': 0.03938484621155289, 'mean_word_length': 2.8757267441860463, 'pattern_counts': {'":': 0, '<': 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': '6518586', 'n_tokens_mistral': 2032, 'n_tokens_neox': 1911, 'n_words': 579}