def load_grounding_map(grounding_map_path, ignore_path=None,
                       lineterminator='\r\n'):
    """Return a grounding map dictionary loaded from a csv file.

    In the file pointed to by grounding_map_path, the number of name_space ID
    pairs can vary per row and commas are
    used to pad out entries containing fewer than the maximum amount of
    name spaces appearing in the file. Lines should be terminated with \r\n
    both a carriage return and a new line by default.

    Optionally, one can specify another csv file (pointed to by ignore_path)
    containing agent texts that are degenerate and should be filtered out.

    Parameters
    ----------
    grounding_map_path : str
        Path to csv file containing grounding map information. Rows of the file
        should be of the form <agent_text>,<name_space_1>,<ID_1>,...
        <name_space_n>,<ID_n>
    ignore_path : Optional[str]
        Path to csv file containing terms that should be filtered out during
        the grounding mapping process. The file Should be of the form
        <agent_text>,,..., where the number of commas that
        appear is the same as in the csv file at grounding_map_path.
        Default: None
    lineterminator : Optional[str]
        Line terminator used in input csv file. Default: \r\n

    Returns
    -------
    g_map : dict
        The grounding map constructed from the given files.
    """
    g_map = {}
    map_rows = read_unicode_csv(grounding_map_path, delimiter=',',
                                quotechar='"',
                                quoting=csv.QUOTE_MINIMAL,
                                lineterminator='\r\n')
    if ignore_path and os.path.exists(ignore_path):
        ignore_rows = read_unicode_csv(ignore_path, delimiter=',',
                                       quotechar='"',
                                       quoting=csv.QUOTE_MINIMAL,
                                       lineterminator=lineterminator)
    else:
        ignore_rows = []
    csv_rows = chain(map_rows, ignore_rows)
    for row in csv_rows:
        key = row[0]
        db_refs = {'TEXT': key}
        keys = [entry for entry in row[1::2] if entry != '']
        values = [entry for entry in row[2::2] if entry != '']
        if len(keys) != len(values):
            logger.info('ERROR: Mismatched keys and values in row %s' %
                        str(row))
            continue
        else:
            db_refs.update(dict(zip(keys, values)))
            if len(db_refs.keys()) > 1:
                g_map[key] = db_refs
            else:
                g_map[key] = None
    return g_map
Return a grounding map dictionary loaded from a csv file.

    In the file pointed to by grounding_map_path, the number of name_space ID
    pairs can vary per row and commas are
    used to pad out entries containing fewer than the maximum amount of
    name spaces appearing in the file. Lines should be terminated with \r\n
    both a carriage return and a new line by default.

    Optionally, one can specify another csv file (pointed to by ignore_path)
    containing agent texts that are degenerate and should be filtered out.

    Parameters
    ----------
    grounding_map_path : str
        Path to csv file containing grounding map information. Rows of the file
        should be of the form <agent_text>,<name_space_1>,<ID_1>,...
        <name_space_n>,<ID_n>
    ignore_path : Optional[str]
        Path to csv file containing terms that should be filtered out during
        the grounding mapping process. The file Should be of the form
        <agent_text>,,..., where the number of commas that
        appear is the same as in the csv file at grounding_map_path.
        Default: None
    lineterminator : Optional[str]
        Line terminator used in input csv file. Default: \r\n

    Returns
    -------
    g_map : dict
        The grounding map constructed from the given files.