mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-12 04:38:28 +03:00
968aff2f6a
<!--- Provide a general summary of your changes in the title. --> ## Description - [x] Replace marks in params for pytest 4.0 compat ([see here](https://docs.pytest.org/en/latest/deprecations.html#marks-in-pytest-mark-parametrize)) - [x] Un-xfail passing tests (some fixes in a recent update resolved a bunch of issues, but tests were apparently never updated here) ### Types of change <!-- What type of change does your PR cover? Is it a bug fix, an enhancement or new feature, or a change to the documentation? --> ## Checklist <!--- Before you submit the PR, go over this checklist and make sure you can tick off all the boxes. [] -> [x] --> - [x] I have submitted the spaCy Contributor Agreement. - [x] I ran the tests, and all new and existing tests passed. - [x] My changes don't require a change to the documentation, or if they do, I've added all required information.
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
# coding: utf-8
|
|
"""Test that longer and mixed texts are tokenized correctly."""
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import pytest
|
|
|
|
|
|
def test_en_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),
|
|
pytest.param("But then the 6,000-year ice age came...", 10, marks=pytest.mark.xfail())])
|
|
def test_en_tokenizer_handles_cnts(en_tokenizer, text, length):
|
|
tokens = en_tokenizer(text)
|
|
assert len(tokens) == length
|
|
|
|
|
|
@pytest.mark.parametrize('text,match', [
|
|
('10', True), ('1', True), ('10,000', True), ('10,00', True),
|
|
('999.0', True), ('one', True), ('two', True), ('billion', True),
|
|
('dog', False), (',', False), ('1/2', True)])
|
|
def test_lex_attrs_like_number(en_tokenizer, text, match):
|
|
tokens = en_tokenizer(text)
|
|
assert len(tokens) == 1
|
|
assert tokens[0].like_num == match
|