mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 09:57:26 +03:00 
			
		
		
		
	* Remove dead code from ner.pyx
This commit is contained in:
		
							parent
							
								
									88ac5c6e98
								
							
						
					
					
						commit
						33e70b167f
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user