Skip to content
Snippets Groups Projects
Commit fdb4aec2 authored by Franck Dary's avatar Franck Dary
Browse files

conll eval script now takes into account any extra column after the 10nth

parent 2ad1daab
No related branches found
No related tags found
No related merge requests found
......@@ -450,7 +450,7 @@ def evaluate(gold_ud, system_ud):
alignment = align_words(gold_ud.words, system_ud.words)
# Compute the F1-scores
return {
scores = {
"Tokens": spans_score(gold_ud.tokens, system_ud.tokens),
"Sentences": spans_score(gold_ud.sentences, system_ud.sentences),
"Words": alignment_score(alignment),
......@@ -472,6 +472,11 @@ def evaluate(gold_ud, system_ud):
filter_fn=lambda w: w.is_content_deprel),
}
for i in range(len(gold_ud.words[0].columns[10:])) :
scores.update({"COLUMN_"+str(11+i) : alignment_score(alignment, lambda w, _: w.columns[10+i])})
return scores
def load_conllu_file(path):
_file = open(path, mode="r", **({"encoding": "utf-8"} if sys.version_info >= (3, 0) else {}))
......@@ -527,6 +532,24 @@ def main():
100 * evaluation[metric].f1,
"{:10.2f}".format(100 * evaluation[metric].aligned_accuracy) if evaluation[metric].aligned_accuracy is not None else ""
))
for i in range(len(evaluation)-13) :
metric = "COLUMN_"+str(i+11)
if args.counts:
print("{:11}|{:10} |{:10} |{:10} |{:10}".format(
metric,
evaluation[metric].correct,
evaluation[metric].gold_total,
evaluation[metric].system_total,
evaluation[metric].aligned_total or (evaluation[metric].correct if metric == "Words" else "")
))
else:
print("{:11}|{:10.2f} |{:10.2f} |{:10.2f} |{}".format(
metric,
100 * evaluation[metric].precision,
100 * evaluation[metric].recall,
100 * evaluation[metric].f1,
"{:10.2f}".format(100 * evaluation[metric].aligned_accuracy) if evaluation[metric].aligned_accuracy is not None else ""
))
if __name__ == "__main__":
main()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment