def preds_to_dict_single()

in code/source/postprocessing.py [0:0]


def preds_to_dict_single(sent, y_pred_tags):
    """
    Postprocessing to format tag predictions into a dictionary of {tagged propertis: corresponding words}
    for each initial sentence.

    Function to transform the output into a dict of Tags and Values
    Same function as preds_to_dict_single with lower casing and replacing spaces by underscores in tags

    :param sent: (list) list of initial sentences as list of words
    :param y_pred_tags: (list) list of grouped predictions created by map_split_preds_to_idx
    :return: dictionary of {tagged propertis: corresponding words}
    for each initial sentence.
    """
    properties = {}
    for word, tag in zip(sent, y_pred_tags):
        tag_values = properties.get(tag, [])# Get tag if existing, otherwise set it to an empty list
        tag_values.append(word)
        properties[tag] = tag_values

    if "O" in properties.keys():
        del properties["O"]

    conc_properties = dict((k.lower().replace(' ', '_'), list(v)) for k, v in properties.items())
        
    return conc_properties