From 33e70b167f65c6a3060abd487b2631c89354de2e Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 5 Jun 2015 17:12:47 +0200 Subject: [PATCH] * Remove dead code from ner.pyx --- spacy/syntax/ner.pyx | 85 -------------------------------------------- 1 file changed, 85 deletions(-) diff --git a/spacy/syntax/ner.pyx b/spacy/syntax/ner.pyx index 8e9dcffe4..79fb4ea31 100644 --- a/spacy/syntax/ner.pyx +++ b/spacy/syntax/ner.pyx @@ -363,91 +363,6 @@ cdef class Out: else: return 1 -""" - -# TODO: Move this logic into the cost functions -cdef int _get_cost(int move, int label, const State* s, const GoldParseC* gold) except -1: - cdef bint is_sunk = _entity_is_sunk(s, gold.ner) - cdef int next_act = gold.ner[s.i+1].move if s.i < s.sent_len else OUT - cdef bint is_gold = _is_gold(move, label, gold.ner[s.i].move, - gold.ner[s.i].label, next_act, is_sunk) - return not is_gold - - -cdef bint _is_gold(int act, int tag, int g_act, int g_tag, - int next_act, bint is_sunk): - if g_act == MISSING: - return True - if act == BEGIN: - if g_act == BEGIN: - # B, Gold B --> Label match - return tag == g_tag - else: - # B, Gold I --> False (P) - # B, Gold L --> False (P) - # B, Gold O --> False (P) - # B, Gold U --> False (P) - return False - elif act == IN: - if g_act == BEGIN: - # I, Gold B --> True (P of bad open entity sunk, R of this entity sunk) - return True - elif g_act == IN: - # I, Gold I --> True (label forced by prev, if mismatch, P and R both sunk) - return True - elif g_act == LAST: - # I, Gold L --> True iff this entity sunk and next tag == O - return is_sunk and (next_act == OUT or next_act == MISSING) - elif g_act == OUT: - # I, Gold O --> True iff next tag == O - return next_act == OUT or next_act == MISSING - elif g_act == UNIT: - # I, Gold U --> True iff next tag == O - return next_act == OUT - elif act == LAST: - if g_act == BEGIN: - # L, Gold B --> True - return True - elif g_act == IN: - # L, Gold I --> True iff this entity sunk - return is_sunk - elif g_act == LAST: - # L, Gold L --> True - return True - elif g_act == OUT: - # L, Gold O --> True - return True - elif g_act == UNIT: - # L, Gold U --> True - return True - elif act == OUT: - if g_act == BEGIN: - # O, Gold B --> False - return False - elif g_act == IN: - # O, Gold I --> True - return True - elif g_act == LAST: - # O, Gold L --> True - return True - elif g_act == OUT: - # O, Gold O --> True - return True - elif g_act == UNIT: - # O, Gold U --> False - return False - elif act == UNIT: - if g_act == UNIT: - # U, Gold U --> True iff tag match - return tag == g_tag - else: - # U, Gold B --> False - # U, Gold I --> False - # U, Gold L --> False - # U, Gold O --> False - return False -""" - class OracleError(Exception): pass