summary refs log tree commit diff stats
path: root/classification/test.py
blob: e0db00313b8f7734d0487246c34ea03371ddc428 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from os import listdir, path

directory : str = "./test_input"

def test(classifier):
    for name in listdir(directory):
        with open(path.join(directory, name), "r") as file:
            sequence_to_classify = file.read()

        candidate_labels = ['semantic', 'other', 'mistranslation', 'instruction']
        result = classifier(sequence_to_classify, candidate_labels, multi_label=True)

        print(name)
        for label, score in zip(result["labels"], result["scores"]):
            print(f"{label}: {score:.3f}")
        print("")