Skip to content
Snippets Groups Projects

Expose parsing/evaluation code

Merged Manon Blanco requested to merge parse-evaluate-without-files into master
All threads resolved!
Files
5
+ 8
7
# -*- coding: utf-8 -*-
import glob
import logging
import os
from csv import reader
@@ -9,7 +8,7 @@ from typing import List
import editdistance
import edlib
import termtables as tt
from prettytable import MARKDOWN, PrettyTable
from nerval.parse import (
BEGINNING_POS,
@@ -340,7 +339,7 @@ def run_multiple(file_csv, folder, threshold, verbose):
list_cor = list(csv_reader)
if os.path.isdir(folder):
list_bio_file = glob.glob(str(folder) + "/**/*.bio", recursive=True)
list_bio_file = list(folder.rglob("*.bio"))
count = 0
precision = 0
@@ -367,17 +366,19 @@ def run_multiple(file_csv, folder, threshold, verbose):
raise Exception(f"No file found for files {annot}, {predict}")
if count:
logger.info("Average score on all corpus")
tt.print(
table = PrettyTable()
table.field_names = ["Precision", "Recall", "F1"]
table.set_style(MARKDOWN)
table.add_rows(
[
[
round(precision / count, 3),
round(recall / count, 3),
round(f1 / count, 3),
]
],
["Precision", "Recall", "F1"],
style=tt.styles.markdown,
]
)
print(table)
else:
raise Exception("No file were counted")
else:
Loading