mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 09:57:26 +03:00 
			
		
		
		
	* Fix Span.root calculation
This commit is contained in:
		
							parent
							
								
									165ca28b80
								
							
						
					
					
						commit
						031b00cb91
					
				| 
						 | 
					@ -150,7 +150,7 @@ def test_example_i_like_new_york5(toks, autumn, dot):
 | 
				
			||||||
    assert toks[autumn].head.orth_ == 'in'
 | 
					    assert toks[autumn].head.orth_ == 'in'
 | 
				
			||||||
    assert toks[dot].head.orth_ == 'like'
 | 
					    assert toks[dot].head.orth_ == 'like'
 | 
				
			||||||
    autumn_dot = toks[autumn:]
 | 
					    autumn_dot = toks[autumn:]
 | 
				
			||||||
    assert autumn_dot.root.orth_ == 'Autumn'
 | 
					    assert autumn_dot.root.orth_ == '.'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_navigating_the_parse_tree_lefts(doc):
 | 
					def test_navigating_the_parse_tree_lefts(doc):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -241,12 +241,6 @@ cdef class Span:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cdef int _count_words_to_root(const TokenC* token, int sent_length) except -1:
 | 
					cdef int _count_words_to_root(const TokenC* token, int sent_length) except -1:
 | 
				
			||||||
    # Don't allow spaces to be the root, if there are
 | 
					 | 
				
			||||||
    # better candidates
 | 
					 | 
				
			||||||
    if Lexeme.c_check_flag(token.lex, IS_SPACE) and token.l_kids == 0 and token.r_kids == 0:
 | 
					 | 
				
			||||||
        return sent_length-1
 | 
					 | 
				
			||||||
    if Lexeme.c_check_flag(token.lex, IS_PUNCT) and token.l_kids == 0 and token.r_kids == 0:
 | 
					 | 
				
			||||||
        return sent_length-1
 | 
					 | 
				
			||||||
    cdef int n = 0
 | 
					    cdef int n = 0
 | 
				
			||||||
    while token.head != 0:
 | 
					    while token.head != 0:
 | 
				
			||||||
        token += token.head
 | 
					        token += token.head
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user