mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-30 03:04:07 +03:00
* Begin writing score_senses method
This commit is contained in:
parent
8464378a85
commit
b7e9c1da85
|
@ -2,6 +2,8 @@ from __future__ import division
|
||||||
|
|
||||||
from .gold import tags_to_entities
|
from .gold import tags_to_entities
|
||||||
|
|
||||||
|
from .senses import STRINGS as SENSE_STRINGS
|
||||||
|
|
||||||
|
|
||||||
class PRFScore(object):
|
class PRFScore(object):
|
||||||
"""A precision / recall / F score"""
|
"""A precision / recall / F score"""
|
||||||
|
@ -71,6 +73,8 @@ class Scorer(object):
|
||||||
def score(self, tokens, gold, verbose=False):
|
def score(self, tokens, gold, verbose=False):
|
||||||
assert len(tokens) == len(gold)
|
assert len(tokens) == len(gold)
|
||||||
|
|
||||||
|
#self._score_senses(tokens, gold)
|
||||||
|
|
||||||
gold_deps = set()
|
gold_deps = set()
|
||||||
gold_tags = set()
|
gold_tags = set()
|
||||||
gold_ents = set(tags_to_entities([annot[5] for annot in gold.orig_annot]))
|
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]
|
print 'F', gold_words[w_id], dep, gold_words[h_id]
|
||||||
for w_id, h_id, dep in (gold_deps - cand_deps):
|
for w_id, h_id, dep in (gold_deps - cand_deps):
|
||||||
print 'M', gold_words[w_id], dep, gold_words[h_id]
|
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user