diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index c0cc6803b..93be3e363 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -120,6 +120,9 @@ cdef class Doc: def __str__(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): if self.vector_norm == 0 or other.vector_norm == 0: return 0.0 diff --git a/spacy/tokens/spans.pyx b/spacy/tokens/spans.pyx index e8d2f2e59..e1b881f79 100644 --- a/spacy/tokens/spans.pyx +++ b/spacy/tokens/spans.pyx @@ -46,6 +46,12 @@ cdef class Span: return 0 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): if isinstance(i, slice): start, end = normalize_slice(len(self), i.start, i.stop, i.step) diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index a7447fb79..cce8eeeb4 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -43,6 +43,9 @@ cdef class Token: def __str__(self): return self.string + def __repr__(self): + return self.string + cpdef bint check_flag(self, attr_id_t flag_id) except -1: return Lexeme.c_check_flag(self.c.lex, flag_id)