diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-05-30 15:56:00 +0200 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-05-30 15:56:00 +0200 |
| commit | 712310482c3dbef91c3eb6458d1bff82a275fa52 (patch) | |
| tree | a1bcdb8df87d90ef121a093d4ea416838f84f856 /classification/test.py | |
| parent | fb84fa98ea1effc76cea3b3426546b4a3851af0b (diff) | |
| download | qemu-analysis-712310482c3dbef91c3eb6458d1bff82a275fa52.tar.gz qemu-analysis-712310482c3dbef91c3eb6458d1bff82a275fa52.zip | |
add test script for the classifier
Diffstat (limited to 'classification/test.py')
| -rw-r--r-- | classification/test.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/classification/test.py b/classification/test.py new file mode 100644 index 000000000..e0db00313 --- /dev/null +++ b/classification/test.py @@ -0,0 +1,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("") |