mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 09:57:26 +03:00 
			
		
		
		
	added __repr__ that prints text in ipython for doc, token, and span objects
This commit is contained in:
		
							parent
							
								
									f02a428fc7
								
							
						
					
					
						commit
						93ada458e2
					
				| 
						 | 
					@ -120,6 +120,9 @@ cdef class Doc:
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return u''.join([t.string for t in self])
 | 
					        return u''.join([t.string for t in self])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __repr__(self):
 | 
				
			||||||
 | 
					        return u''.join([t.string for t in self])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def similarity(self, other):
 | 
					    def similarity(self, other):
 | 
				
			||||||
        if self.vector_norm == 0 or other.vector_norm == 0:
 | 
					        if self.vector_norm == 0 or other.vector_norm == 0:
 | 
				
			||||||
            return 0.0
 | 
					            return 0.0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,6 +46,12 @@ cdef class Span:
 | 
				
			||||||
            return 0
 | 
					            return 0
 | 
				
			||||||
        return self.end - self.start
 | 
					        return self.end - self.start
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __repr__(self):
 | 
				
			||||||
 | 
					        text = self.text_with_ws
 | 
				
			||||||
 | 
					        if self[-1].whitespace_:
 | 
				
			||||||
 | 
					            text = text[:-1]
 | 
				
			||||||
 | 
					        return text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __getitem__(self, object i):
 | 
					    def __getitem__(self, object i):
 | 
				
			||||||
        if isinstance(i, slice):
 | 
					        if isinstance(i, slice):
 | 
				
			||||||
            start, end = normalize_slice(len(self), i.start, i.stop, i.step)
 | 
					            start, end = normalize_slice(len(self), i.start, i.stop, i.step)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,6 +43,9 @@ cdef class Token:
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return self.string
 | 
					        return self.string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __repr__(self):
 | 
				
			||||||
 | 
					        return self.string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cpdef bint check_flag(self, attr_id_t flag_id) except -1:
 | 
					    cpdef bint check_flag(self, attr_id_t flag_id) except -1:
 | 
				
			||||||
        return Lexeme.c_check_flag(self.c.lex, flag_id)
 | 
					        return Lexeme.c_check_flag(self.c.lex, flag_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user