mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-11 04:08:09 +03:00
db55577c45
* Remove unicode declarations * Remove Python 3.5 and 2.7 from CI * Don't require pathlib * Replace compat helpers * Remove OrderedDict * Use f-strings * Set Cython compiler language level * Fix typo * Re-add OrderedDict for Table * Update setup.cfg * Revert CONTRIBUTING.md * Revert lookups.md * Revert top-level.md * Small adjustments and docs [ci skip]
26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
import pytest
|
|
from spacy.attrs import IS_ALPHA
|
|
from spacy.lang.en import English
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"sentence",
|
|
[
|
|
"The story was to the effect that a young American student recently called on Professor Christlieb with a letter of introduction.",
|
|
"The next month Barry Siddall joined Stoke City on a free transfer, after Chris Pearce had established himself as the Vale's #1.",
|
|
"The next month Barry Siddall joined Stoke City on a free transfer, after Chris Pearce had established himself as the Vale's number one",
|
|
"Indeed, making the one who remains do all the work has installed him into a position of such insolent tyranny, it will take a month at least to reduce him to his proper proportions.",
|
|
"It was a missed assignment, but it shouldn't have resulted in a turnover ...",
|
|
],
|
|
)
|
|
def test_issue3869(sentence):
|
|
"""Test that the Doc's count_by function works consistently"""
|
|
nlp = English()
|
|
doc = nlp(sentence)
|
|
|
|
count = 0
|
|
for token in doc:
|
|
count += token.is_alpha
|
|
|
|
assert count == doc.count_by(IS_ALPHA).get(1, 0)
|