mirror of https://github.com/explosion/spaCy.git
ensure span.text works for an empty span (#6772)
This commit is contained in:
parent
fdf8c77630
commit
5ace559201
|
@ -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):
|
def text(self):
|
||||||
"""RETURNS (unicode): The original verbatim text of the span."""
|
"""RETURNS (unicode): The original verbatim text of the span."""
|
||||||
text = self.text_with_ws
|
text = self.text_with_ws
|
||||||
if self[-1].whitespace_:
|
if len(self) > 0 and self[-1].whitespace_:
|
||||||
text = text[:-1]
|
text = text[:-1]
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue