From b7e9c1da8501cffeeb06d75ba5bcd4ecf552504b Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 3 Jul 2015 05:10:52 +0200 Subject: [PATCH] * Begin writing score_senses method --- spacy/scorer.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spacy/scorer.py b/spacy/scorer.py index f1341418e..9adcb154f 100644 --- a/spacy/scorer.py +++ b/spacy/scorer.py @@ -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