# Path: implementation/primaries/ExtractMetadata/classes/helpers.py
# def combine_dictionaries(dict1, dict2):
#     new_dict = dict1
#     for key in dict2:
#         if key not in new_dict:
#             new_dict[key] = dict2[key]
#         elif isinstance(new_dict[key], dict):
#             new_dict[key] = combine_dictionaries(new_dict[key], dict2[key])
#         elif isinstance(new_dict[key], dict):
#             new_dict[key]["other"] = dict2[key]
#         elif isinstance(dict2[key], dict):
#             cpy = new_dict[key]
#             new_dict[key] = {"other": cpy}
#             new_dict[key].update(dict2[key])
#         else:
#             new_dict[key].extend(dict2[key])
#     return new_dict


from implementation.primaries.ExtractMetadata.classes.helpers import combine_dictionaries
        new_unit = unit.split(" ")
        if isinstance(new_unit, list):
            # filter out empty strings
            new_unit = list(filter(None, new_unit))
            data.append(new_unit)
        elif new_unit != '':
            data.append(new_unit)
    spaced_input.append(data)
    return spaced_input


def handle_colons_and_semicolons(entry):
    tokens = entry.split(";")
    result = {}
    last_key = None
    first_value = None
    for token in tokens:
        kv = token.split(":")
        if len(kv) > 1:
            last_key = kv[0]
            if first_value is None:
                first_value = kv[1]
                dict_entry = {last_key: [kv[1]]}
                result = combine_dictionaries(result, dict_entry)
            else:
                dict_entry = {last_key: {first_value: [kv[1]]}}
                result = combine_dictionaries(result, dict_entry)
        else:
            if last_key is not None:
                dict_entry = {last_key: [kv[0]]}

# Path: implementation/primaries/ExtractMetadata/classes/helpers.py
# def combine_dictionaries(dict1, dict2):
#     new_dict = dict1
#     for key in dict2:
#         if key not in new_dict:
#             new_dict[key] = dict2[key]
#         elif isinstance(new_dict[key], dict):
#             new_dict[key] = combine_dictionaries(new_dict[key], dict2[key])
#         elif isinstance(new_dict[key], dict):
#             new_dict[key]["other"] = dict2[key]
#         elif isinstance(dict2[key], dict):
#             cpy = new_dict[key]
#             new_dict[key] = {"other": cpy}
#             new_dict[key].update(dict2[key])
#         else:
#             new_dict[key].extend(dict2[key])
#     return new_dict


# Path: implementation/primaries/ExtractMetadata/classes/SearchProcessor.py
from implementation.primaries.ExtractMetadata.classes.helpers import combine_dictionaries

        new_unit = unit.split(" ")
        if isinstance(new_unit, list):
            # filter out empty strings
            new_unit = list(filter(None, new_unit))
            data.append(new_unit)
        elif new_unit != '':
            data.append(new_unit)
    spaced_input.append(data)
    return spaced_input


def handle_colons_and_semicolons(entry):
    tokens = entry.split(";")
    result = {}
    last_key = None
    first_value = None
    for token in tokens:
        kv = token.split(":")
        if len(kv) > 1:
            last_key = kv[0]
            if first_value is None:
                first_value = kv[1]
                dict_entry = {last_key: [kv[1]]}
                result = combine_dictionaries(result, dict_entry)
            else:
                dict_entry = {last_key: {first_value: [kv[1]]}}
                result = combine_dictionaries(result, dict_entry)
        else:
            if last_key is not None:
                dict_entry = {last_key: [kv[0]]}

                result = combine_dictionaries(result, dict_entry)