<commit_before>def get_dtype(parameter_value):
    """Get the TopoFlow data type of a parameter.

    Parameters
    ----------
    parameter_value : object
      An object, a scalar.

    """
    try:
        float(parameter_value)
    except ValueError:
        return 'string'
    else:
        return 'float'


def assign_parameters(env, file_list):
    """Assign values for input parameters in a TopoFlow component.

    A subset of TopoFlow input parameters can take a scalar value, or,
    through an uploaded file, a time series, a grid, or a grid
    sequence. This function assigns such parameters a scalar value, or
    the name of a file, based on the user's selection in WMT.

    Parameters
    ----------
    env : dict
      A dict of component parameter values from WMT.
    file_list : list
      A list of file names used by the component.

    """
    terminator = '_ptype'
    for key in env.copy().iterkeys():
        if key.endswith(terminator):
            key_root, sep, end = key.partition(terminator)
            if env[key] == 'Scalar':
                env[key_root] = env[key_root + '_scalar']
            else:
                env[key_root] = env[key_root + '_file']
                file_list.append(key_root)
            env[key_root + '_dtype'] = get_dtype(env[key_root])
<commit_msg>Add choices_map and units_map global variables<commit_after>"""Routines used by WMT hooks for TopoFlow components."""

choices_map = {
    'Yes': 1,
    'No': 0
}
units_map = {
    'meters': 'm^2',
    'kilometers': 'km^2'
}


def get_dtype(parameter_value):
    """Get the TopoFlow data type of a parameter.

    Parameters
    ----------
    parameter_value : object
      An object, a scalar.

    """
    try:
        float(parameter_value)
    except ValueError:
        return 'string'
    else:
        return 'float'


def assign_parameters(env, file_list):
    """Assign values for input parameters in a TopoFlow component.

    A subset of TopoFlow input parameters can take a scalar value, or,
    through an uploaded file, a time series, a grid, or a grid
    sequence. This function assigns such parameters a scalar value, or
    the name of a file, based on the user's selection in WMT.

    Parameters
    ----------
    env : dict
      A dict of component parameter values from WMT.
    file_list : list
      A list of file names used by the component.

    """
    terminator = '_ptype'
    for key in env.copy().iterkeys():
        if key.endswith(terminator):
            key_root, sep, end = key.partition(terminator)
            if env[key] == 'Scalar':
                env[key_root] = env[key_root + '_scalar']
            else:
                env[key_root] = env[key_root + '_file']
                file_list.append(key_root)
            env[key_root + '_dtype'] = get_dtype(env[key_root])

{'fraction_non_alphanumeric': 0.10134180790960452, 'fraction_numerical': 0.0014124293785310734, 'mean_word_length': 2.2340182648401825, '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': '1742821', 'n_tokens_mistral': 836, 'n_tokens_neox': 811, 'n_words': 287}