from pathlib import Path


def parse_results(f: Path):
    """
    Load text from results file f and parse.
    File is generated with following format
        gold: ever since joes has changed hands it 's gotten better and better .
        2.0: ever since brother 's gotten worse it has always been just hands worse .
        3.0: ever since brother has gotten worse it 's always been just worse and overpriced .
        4.0: ever since brother has gotten worse it 's always been just hands worse .
        5.0: ever since always has gotten worse it 's always been great and makes overpriced .
        6.0: since always ever works has gotten great prices and it 's always worse .
        7.0: since always has seasoned hands has gotten great prices and it 's always worse .
        8.0: since always has seasoned hands has great prices and it 's always gotten worse .

        gold: there is so much room in that part of the venue
        ...

    """
    examples = [x.split("\n") for x in f.read_text()[1:-1].split("\n\n")]
    model_out = [x[1:] for x in examples]

    results_dict = {x[:3] : [] for x in model_out[0]}
    for example in examples:
        for x in example[1:]:
            results_dict[x[:3]] += [x[5:]]

    results_dict["gold"] = [x[0][6:] for x in examples]
    return results_dict