mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 18:06:29 +03:00
Add tests for longer and mixed English texts
This commit is contained in:
parent
65f937d5c6
commit
8216ba599b
36
spacy/tests/en/tokenizer/test_text.py
Normal file
36
spacy/tests/en/tokenizer/test_text.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# coding: utf-8
|
||||||
|
"""Test that longer and mixed texts are tokenized correctly."""
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def test_tokenizer_handles_long_text(en_tokenizer):
|
||||||
|
text = """Tributes pour in for late British Labour Party leader
|
||||||
|
|
||||||
|
Tributes poured in from around the world Thursday
|
||||||
|
to the late Labour Party leader John Smith, who died earlier from a massive
|
||||||
|
heart attack aged 55.
|
||||||
|
|
||||||
|
In Washington, the US State Department issued a statement regretting "the
|
||||||
|
untimely death" of the rapier-tongued Scottish barrister and parliamentarian.
|
||||||
|
|
||||||
|
"Mr. Smith, throughout his distinguished"""
|
||||||
|
tokens = en_tokenizer(text)
|
||||||
|
assert len(tokens) == 76
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('text,length', [
|
||||||
|
("The U.S. Army likes Shock and Awe.", 8),
|
||||||
|
("U.N. regulations are not a part of their concern.", 10),
|
||||||
|
("“Isn't it?”", 6),
|
||||||
|
("""Yes! "I'd rather have a walk", Ms. Comble sighed. """, 15),
|
||||||
|
("""'Me too!', Mr. P. Delaware cried. """, 11),
|
||||||
|
("They ran about 10km.", 6),
|
||||||
|
# ("But then the 6,000-year ice age came...", 10)
|
||||||
|
])
|
||||||
|
def test_tokenizer_handles_cnts(en_tokenizer, text, length):
|
||||||
|
tokens = en_tokenizer(text)
|
||||||
|
assert len(tokens) == length
|
Loading…
Reference in New Issue
Block a user