mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-07 13:44:55 +03:00
Merge 8edd58492e
into 4fb038a9eb
This commit is contained in:
commit
b11fff8317
98
spacy/tests/print/test_print.py
Normal file
98
spacy/tests/print/test_print.py
Normal file
|
@ -0,0 +1,98 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
|
||||
def test_print_doc(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the coffee store')
|
||||
print(doc)
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_repr_doc(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the coffee store')
|
||||
print(repr(doc))
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_print_doc_unicode(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the café')
|
||||
print(doc)
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_repr_doc_unicode(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the café')
|
||||
print(repr(doc))
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_print_span(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the coffee store')[-3:]
|
||||
print(doc)
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_repr_span(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the coffee store')[-3:]
|
||||
print(repr(doc))
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_print_span_unicode(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the café')[-3:]
|
||||
print(doc)
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_repr_span_unicode(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the café')[-3:]
|
||||
print(repr(doc))
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_print_token(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the coffee store')[-1]
|
||||
print(doc)
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_repr_token(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the coffee store')[-1]
|
||||
print(repr(doc))
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_print_token_unicode(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the café')[-1]
|
||||
print(doc)
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
||||
|
||||
|
||||
def test_repr_token_unicode(EN):
|
||||
try:
|
||||
doc = EN(u'I sat down for coffee at the café')[-1]
|
||||
print(repr(doc))
|
||||
except Exception:
|
||||
pytest.fail("Printing failed")
|
|
@ -118,10 +118,10 @@ cdef class Doc:
|
|||
return u''.join([t.string for t in self])
|
||||
|
||||
def __str__(self):
|
||||
return u''.join([t.string for t in self])
|
||||
return u''.join([t.string for t in self]).encode('utf-8')
|
||||
|
||||
def __repr__(self):
|
||||
return u''.join([t.string for t in self])
|
||||
return u''.join([t.string for t in self]).encode('utf-8')
|
||||
|
||||
def similarity(self, other):
|
||||
if self.vector_norm == 0 or other.vector_norm == 0:
|
||||
|
|
|
@ -50,7 +50,7 @@ cdef class Span:
|
|||
text = self.text_with_ws
|
||||
if self[-1].whitespace_:
|
||||
text = text[:-1]
|
||||
return text
|
||||
return text.encode('utf-8')
|
||||
|
||||
def __getitem__(self, object i):
|
||||
if isinstance(i, slice):
|
||||
|
|
|
@ -41,10 +41,10 @@ cdef class Token:
|
|||
return self.string
|
||||
|
||||
def __str__(self):
|
||||
return self.string
|
||||
return self.string.encode('utf-8')
|
||||
|
||||
def __repr__(self):
|
||||
return self.string
|
||||
return self.string.encode('utf-8')
|
||||
|
||||
cpdef bint check_flag(self, attr_id_t flag_id) except -1:
|
||||
return Lexeme.c_check_flag(self.c.lex, flag_id)
|
||||
|
|
Loading…
Reference in New Issue
Block a user