Skip to content
Snippets Groups Projects

Bump Python requirement prettytable to 3.16.0

Open Teklia Bot requested to merge bump-prettytable into master
Files
3
+ 10
11
@@ -2,8 +2,10 @@ from prettytable import MARKDOWN, PrettyTable
from nerval import ALL_ENTITIES
TABLE_HEADER = ["tag", "predicted", "matched", "Precision", "Recall", "F1", "Support"]
def print_markdown_table(header: list[str], rows: list[list]) -> None:
def print_markdown_table(header: list[str], rows: list[list]) -> list[list]:
"""Prints a Markdown table filled with the provided header and rows."""
table = PrettyTable()
table.field_names = header
@@ -26,8 +28,10 @@ def print_markdown_table(header: list[str], rows: list[list]) -> None:
table.add_rows(rows)
print(table)
return rows
def print_results(scores: dict) -> None:
def print_results(scores: dict) -> list[list]:
"""Display final results.
None values are kept to indicate the absence of a certain tag in either annotation or prediction.
@@ -50,13 +54,10 @@ def print_results(scores: dict) -> None:
],
)
print_markdown_table(
["tag", "predicted", "matched", "Precision", "Recall", "F1", "Support"],
results,
)
return print_markdown_table(TABLE_HEADER, results)
def print_result_compact(scores: dict) -> None:
def print_result_compact(scores: dict) -> list[list]:
result = [
ALL_ENTITIES,
scores[ALL_ENTITIES]["predicted"],
@@ -66,7 +67,5 @@ def print_result_compact(scores: dict) -> None:
round(scores[ALL_ENTITIES]["F1"], 3),
scores[ALL_ENTITIES]["Support"],
]
print_markdown_table(
["tag", "predicted", "matched", "Precision", "Recall", "F1", "Support"],
[result],
)
return print_markdown_table(TABLE_HEADER, [result])
Loading