def extract_seed(path, key):
    """ Scrape the 5-character seed from the path and return it as an integer.

    :param path: path to the tsv file containing results
    :param key: substring preceding the seed, "batch-train" for splits, seed-" for shuffles
    """
    try:
        i = path.find(key) + len(key)
        return int(path[i:i + 5])
    except ValueError:
        return 0