* Begin writing score_senses method

This commit is contained in:
Matthew Honnibal 2015-07-03 05:10:52 +02:00
parent 8464378a85
commit b7e9c1da85

View File

@ -2,6 +2,8 @@ from __future__ import division
from .gold import tags_to_entities
from .senses import STRINGS as SENSE_STRINGS
class PRFScore(object):
"""A precision / recall / F score"""
@ -71,6 +73,8 @@ class Scorer(object):
def score(self, tokens, gold, verbose=False):
assert len(tokens) == len(gold)
#self._score_senses(tokens, gold)
gold_deps = set()
gold_tags = set()
gold_ents = set(tags_to_entities([annot[5] for annot in gold.orig_annot]))
@ -121,3 +125,11 @@ class Scorer(object):
print 'F', gold_words[w_id], dep, gold_words[h_id]
for w_id, h_id, dep in (gold_deps - cand_deps):
print 'M', gold_words[w_id], dep, gold_words[h_id]
def _score_senses(self, tokens, gold):
for i, g_annot in enumerate(gold.orig_annot):
gold_senses = g_annot[-1]
if gold_senses:
cand_i = gold.gold_to_cand[i]
sense_str = tokens[cand_i].sense_
print sense_str, gold_senses