summary refs log tree commit diff stats
path: root/classification/output.py
blob: 971c3830e7c4856519c0aaf30e4e9662f212defd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
from os import path, makedirs

def output(text : str, category : str, labels : list, scores : list, identifier : str):
    file_path = f"output/{category}/{identifier}"
    makedirs(path.dirname(file_path), exist_ok = True)

    with open(file_path, "w") as file:
        for label, score in zip(labels, scores):
            file.write(f"{label}: {score:.3f}\n")

        file.write("\n")
        file.write(text)