mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	* Fix negative indices in Span
This commit is contained in:
		
							parent
							
								
									74d8cb3980
								
							
						
					
					
						commit
						9590968fc1
					
				| 
						 | 
				
			
			@ -41,13 +41,17 @@ cdef class Span:
 | 
			
		|||
 | 
			
		||||
    def __getitem__(self, int i):
 | 
			
		||||
        if i < 0:
 | 
			
		||||
            i = len(self) - i
 | 
			
		||||
        return self._seq[self.start + i]
 | 
			
		||||
            return self._seq[self.end + i]
 | 
			
		||||
        else:
 | 
			
		||||
            return self._seq[self.start + i]
 | 
			
		||||
 | 
			
		||||
    def __iter__(self):
 | 
			
		||||
        for i in range(self.start, self.end):
 | 
			
		||||
            yield self._seq[i]
 | 
			
		||||
 | 
			
		||||
    def merge(self, unicode tag, unicode lemma, unicode ent_type):
 | 
			
		||||
        self._seq.merge(self[0].idx, self[-1].idx + len(self[-1]), tag, lemma, ent_type)
 | 
			
		||||
 | 
			
		||||
    property root:
 | 
			
		||||
        """The first ancestor of the first word of the span that has its head
 | 
			
		||||
        outside the span.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user