mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-11 12:18:04 +03:00
b6e991440c
* Auto-format tests with black * Add flake8 config * Tidy up and remove unused imports * Fix redefinitions of test functions * Replace orths_and_spaces with words and spaces * Fix compatibility with pytest 4.0 * xfail test for now Test was previously overwritten by following test due to naming conflict, so failure wasn't reported * Unfail passing test * Only use fixture via arguments Fixes pytest 4.0 compatibility
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
# encoding: utf8
|
|
from __future__ import unicode_literals
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"text,expected_tokens",
|
|
[("פייתון היא שפת תכנות דינמית", ["פייתון", "היא", "שפת", "תכנות", "דינמית"])],
|
|
)
|
|
def test_he_tokenizer_handles_abbreviation(he_tokenizer, text, expected_tokens):
|
|
tokens = he_tokenizer(text)
|
|
token_list = [token.text for token in tokens if not token.is_space]
|
|
assert expected_tokens == token_list
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"text,expected_tokens",
|
|
[
|
|
(
|
|
"עקבת אחריו בכל רחבי המדינה.",
|
|
["עקבת", "אחריו", "בכל", "רחבי", "המדינה", "."],
|
|
),
|
|
(
|
|
"עקבת אחריו בכל רחבי המדינה?",
|
|
["עקבת", "אחריו", "בכל", "רחבי", "המדינה", "?"],
|
|
),
|
|
(
|
|
"עקבת אחריו בכל רחבי המדינה!",
|
|
["עקבת", "אחריו", "בכל", "רחבי", "המדינה", "!"],
|
|
),
|
|
(
|
|
"עקבת אחריו בכל רחבי המדינה..",
|
|
["עקבת", "אחריו", "בכל", "רחבי", "המדינה", ".."],
|
|
),
|
|
(
|
|
"עקבת אחריו בכל רחבי המדינה...",
|
|
["עקבת", "אחריו", "בכל", "רחבי", "המדינה", "..."],
|
|
),
|
|
],
|
|
)
|
|
def test_he_tokenizer_handles_punct(he_tokenizer, text, expected_tokens):
|
|
tokens = he_tokenizer(text)
|
|
assert expected_tokens == [token.text for token in tokens]
|