mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-26 13:41:21 +03:00 
			
		
		
		
	ensure span.text works for an empty span (#6772)
This commit is contained in:
		
							parent
							
								
									fdf8c77630
								
							
						
					
					
						commit
						5ace559201
					
				
							
								
								
									
										9
									
								
								spacy/tests/regression/test_issue6755.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								spacy/tests/regression/test_issue6755.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | |||
| # coding: utf8 | ||||
| from __future__ import unicode_literals | ||||
| 
 | ||||
| 
 | ||||
| def test_issue6755(en_tokenizer): | ||||
|     doc = en_tokenizer("This is a magnificent sentence.") | ||||
|     span = doc[:0] | ||||
|     assert span.text_with_ws == "" | ||||
|     assert span.text == "" | ||||
|  | @ -500,7 +500,7 @@ cdef class Span: | |||
|     def text(self): | ||||
|         """RETURNS (unicode): The original verbatim text of the span.""" | ||||
|         text = self.text_with_ws | ||||
|         if self[-1].whitespace_: | ||||
|         if len(self) > 0 and self[-1].whitespace_: | ||||
|             text = text[:-1] | ||||
|         return text | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user