Skip to content

Commit

Permalink
GH-19: fixed error in updating Metric
Browse files Browse the repository at this point in the history
  • Loading branch information
aakbik authored and tabergma committed Jul 31, 2018
1 parent 7ffcafd commit 5ca22d6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flair/data_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def read_conll_ud(path_to_conll_file: str) -> List[Sentence]:
if not "=" in morph: continue;
token.add_tag(morph.split('=')[0].lower(), morph.split('=')[1])

if str(fields[10]) == 'Y':
if len(fields) > 10 and str(fields[10]) == 'Y':
token.add_tag('frame', str(fields[11]))

sentence.add_token(token)
Expand Down
18 changes: 18 additions & 0 deletions flair/trainers/sequence_tagger_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,24 @@ def evaluate(self, evaluation: List[Sentence], out_path=None, evaluation_method:
else:
fp += 1

# positives
if predicted_tag != '':
# true positives
if predicted_tag == gold_tag:
metric.tp()
# false positive
if predicted_tag != gold_tag:
metric.fp()

# negatives
if predicted_tag == '':
# true negative
if predicted_tag == gold_tag:
metric.tn()
# false negative
if predicted_tag != gold_tag:
metric.fn()

lines.append(eval_line)

lines.append('\n')
Expand Down

0 comments on commit 5ca22d6

Please sign in to comment.