Skip to content

Commit

Permalink
fix for error in nel with non-matching mentions (issue #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhachey committed Oct 13, 2014
1 parent ca83514 commit 46d9233
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions neleval/analyze.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .document import ENC
from .document import Reader
from .document import by_mention
from .evaluate import get_measure
from .evaluate import get_measure, Evaluate
from collections import Counter
from collections import namedtuple

Expand Down Expand Up @@ -53,11 +53,12 @@ def __str__(self):
class Analyze(object):
"""Analyze errors"""
def __init__(self, system, gold=None, unique=False, summary=False, with_correct=False):
self.system = system
self.gold = gold
self.system = list(Reader(open(system)))
self.gold = list(Reader(open(gold)))
self.unique = unique
self.summary = summary
self.with_correct = with_correct
self.measure = get_measure('strong_mention_match')

def __call__(self):
if self.unique:
Expand All @@ -79,12 +80,9 @@ def _data():
return u'\n'.join(unicode(error) for error in _data()).encode(ENC)

def iter_errors(self):
system = list(Reader(open(self.system), group=by_mention))
gold = list(Reader(open(self.gold), group=by_mention))
measure = get_measure('strong_mention_match')
for g, s in zip(gold, system):
for s, g in Evaluate.iter_pairs(self.system, self.gold):
assert g.id == s.id
tp, fp, fn = measure.get_matches(g.annotations, s.annotations)
tp, fp, fn = self.measure.get_matches(g.annotations, s.annotations)
for g_m, s_m in tp:
if g_m.kbid == s_m.kbid and not self.with_correct:
#continue # Correct case.
Expand Down

0 comments on commit 46d9233

Please sign in to comment.