repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
spaCy
spacy/tests/util.py
.py
import contextlib import re import tempfile import numpy import srsly from thinc.api import get_current_ops from spacy.tokens import Doc from spacy.training import split_bilu_label from spacy.util import make_tempdir # noqa: F401 from spacy.vocab import Vocab @contextlib.contextmanager def make_tempfile(mode="r"):...
105
3,281
spaCy
spacy/tests/test_scorer.py
.py
import pytest from numpy.testing import assert_almost_equal, assert_array_almost_equal from pytest import approx from spacy.lang.en import English from spacy.scorer import PRFScore, ROCAUCScore, Scorer, _roc_auc_score, _roc_curve from spacy.tokens import Doc, Span from spacy.training import Example from spacy.training...
538
17,478
spaCy
spacy/tests/test_ty.py
.py
import spacy from spacy import ty def test_component_types(): nlp = spacy.blank("en") tok2vec = nlp.create_pipe("tok2vec") tagger = nlp.create_pipe("tagger") entity_ruler = nlp.create_pipe("entity_ruler") assert isinstance(tok2vec, ty.TrainableComponent) assert isinstance(tagger, ty.TrainableC...
19
748
spaCy
spacy/tests/test_factory_registrations.py
.py
import json from pathlib import Path import pytest from spacy.util import registry # Path to the reference factory registrations, relative to this file REFERENCE_FILE = Path(__file__).parent / "factory_registrations.json" # Monkey patch the util.is_same_func to handle Cython functions from spacy import util origi...
95
2,942
spaCy
spacy/tests/test_models.py
.py
from typing import List import numpy import pytest from numpy.testing import assert_array_almost_equal, assert_array_equal from thinc.api import ( Adam, Logistic, Ragged, Relu, chain, fix_random_seed, reduce_mean, set_dropout_rate, ) from spacy.lang.en import English from spacy.lang.en...
302
9,585
spaCy
spacy/tests/test_displacy.py
.py
import numpy import pytest from spacy import displacy from spacy.displacy.render import DependencyRenderer, EntityRenderer, SpanRenderer from spacy.lang.en import English from spacy.lang.fa import Persian from spacy.tokens import Doc, Span @pytest.mark.issue(2361) def test_issue2361(de_vocab): """Test if < is es...
491
17,774
spaCy
spacy/tests/test_language.py
.py
import itertools import logging import warnings from unittest import mock import pytest from thinc.api import CupyOps, NumpyOps, get_current_ops import spacy from spacy.lang.de import German from spacy.lang.en import English from spacy.language import Language from spacy.scorer import Scorer from spacy.tokens import ...
801
27,022
spaCy
spacy/tests/tok2vec.py
.py
from typing import List from thinc.api import Model from thinc.types import Floats2d from spacy.tokens import Doc from spacy.util import registry @registry.architectures("test.LazyInitTok2Vec.v1") def build_lazy_init_tok2vec(*, width: int) -> Model[List[Doc], List[Floats2d]]: """tok2vec model of which the outpu...
37
1,001
spaCy
spacy/tests/test_pickles.py
.py
import numpy import pytest import srsly from spacy.attrs import NORM from spacy.lang.en import English from spacy.strings import StringStore from spacy.tokens import Doc from spacy.vocab import Vocab @pytest.mark.parametrize("text1,text2", [("hello", "bye")]) def test_pickle_string_store(text1, text2): stringsto...
63
2,023
spaCy
spacy/tests/test_architectures.py
.py
import pytest from catalogue import RegistryError from thinc.api import Linear from spacy import registry def test_get_architecture(): @registry.architectures("my_test_function") def create_model(nr_in, nr_out): return Linear(nr_in, nr_out) arch = registry.architectures.get("my_test_function") ...
17
448
spaCy
spacy/tests/test_cli.py
.py
import math import os from collections import Counter from pathlib import Path from typing import Any, Dict, List, Tuple import pytest import srsly from click import NoSuchOption from packaging.specifiers import SpecifierSet from thinc.api import Config import spacy from spacy import about from spacy.cli import downl...
1,240
44,024
spaCy
spacy/tests/conftest.py
.py
import pytest from hypothesis import settings from spacy.util import get_lang_class # Functionally disable deadline settings for tests # to prevent spurious test failures in CI builds. settings.register_profile("no_deadlines", deadline=2 * 60 * 1000) # in ms settings.load_profile("no_deadlines") def pytest_addopti...
535
12,096
spaCy
spacy/tests/tokenizer/test_exceptions.py
.py
import sys import pytest def test_tokenizer_handles_emoticons(tokenizer): # Tweebo challenge (CMU) text = ( """:o :/ :'( >:o (: :) >.< XD -__- o.O ;D :-) @_@ :P 8D :1 >:( :D =| :> ....""" ) tokens = tokenizer(text) assert tokens[0].text == ":o" assert tokens[1].text == ":/" assert...
55
1,757
spaCy
spacy/tests/tokenizer/test_urls.py
.py
import pytest from spacy.lang.tokenizer_exceptions import BASE_EXCEPTIONS URLS_BASIC = [ "http://www.nytimes.com/2016/04/20/us/politics/new-york-primary-preview.html?hp&action=click&pgtype=Homepage&clickSource=story-heading&module=a-lede-package-region&region=top-news&WT.nav=top-news&_r=0", "www.red-stars.com...
206
6,462
spaCy
spacy/tests/tokenizer/test_explain.py
.py
import re import string import hypothesis import hypothesis.strategies import pytest import spacy from spacy.tokenizer import Tokenizer from spacy.util import get_lang_class # Only include languages with no external dependencies # "is" seems to confuse importlib, so we're also excluding it for now # excluded: ja, ru...
146
5,441
spaCy
spacy/tests/tokenizer/test_tokenizer.py
.py
import re import numpy import pytest from spacy.lang.de import German from spacy.lang.en import English from spacy.symbols import ORTH from spacy.tokenizer import Tokenizer from spacy.tokens import Doc from spacy.training import Example from spacy.util import ( compile_infix_regex, compile_prefix_regex, c...
558
18,588
spaCy
spacy/tests/tokenizer/test_naughty_strings.py
.py
import pytest # Examples taken from the "Big List of Naughty Strings" # https://github.com/minimaxir/big-list-of-naughty-strings NAUGHTY_STRINGS = [ # ASCII punctuation r",./;'[]\-=", r'<>?:"{}|_+', r'!@#$%^&*()`~"', # Unicode additional control characters, byte order marks r"­؀؁؂؃؄؅؜۝܏᠎​‌‍‎‏...
116
7,466
spaCy
spacy/tests/tokenizer/test_whitespace.py
.py
import pytest @pytest.mark.parametrize("text", ["lorem ipsum"]) def test_tokenizer_splits_single_space(tokenizer, text): tokens = tokenizer(text) assert len(tokens) == 2 @pytest.mark.parametrize("text", ["lorem ipsum"]) def test_tokenizer_splits_double_space(tokenizer, text): tokens = tokenizer(text) ...
46
1,295
spaCy
spacy/tests/lang/test_lemmatizers.py
.py
import pytest from spacy import registry from spacy.lookups import Lookups from spacy.util import get_lang_class # fmt: off # Only include languages with no external dependencies # excluded: ru, uk # excluded for custom tables: es, pl LANGUAGES = ["bn", "ca", "el", "en", "fa", "fr", "nb", "nl", "sv"] # fmt: on @pyt...
55
1,910
spaCy
spacy/tests/lang/test_initialize.py
.py
import pytest from spacy.util import get_lang_class # fmt: off # Only include languages with no external dependencies # excluded: ja, ko, th, vi, zh LANGUAGES = ["af", "am", "ar", "az", "bg", "bn", "ca", "cs", "da", "de", "el", "en", "es", "et", "eu", "fa", "fi", "fr", "ga", "gu", "he", "hi", ...
25
929
spaCy
spacy/tests/lang/test_attrs.py
.py
import pytest from spacy.attrs import ENT_IOB, IS_ALPHA, LEMMA, NORM, ORTH, intify_attrs from spacy.lang.en.stop_words import STOP_WORDS from spacy.lang.lex_attrs import ( is_ascii, is_currency, is_punct, is_stop, like_url, word_shape, ) @pytest.mark.parametrize("word", ["the"]) @pytest.mark....
136
3,532
spaCy
spacy/tests/lang/it/test_prefix_suffix_infix.py
.py
import pytest @pytest.mark.parametrize( "text,expected_tokens", [("c'è", ["c'", "è"]), ("l'ha", ["l'", "ha"])] ) def test_contractions(it_tokenizer, text, expected_tokens): """Test that the contractions are split into two tokens""" tokens = it_tokenizer(text) assert len(tokens) == 2 assert [t.text...
12
359
spaCy
spacy/tests/lang/it/test_stopwords.py
.py
import pytest @pytest.mark.parametrize( "word", ["un", "lo", "dell", "dall", "si", "ti", "mi", "quest", "quel", "quello"] ) def test_stopwords_basic(it_tokenizer, word): tok = it_tokenizer(word)[0] assert tok.is_stop @pytest.mark.parametrize( "word", ["quest'uomo", "l'ho", "un'amica", "dell'olio", "...
18
449
spaCy
spacy/tests/lang/it/test_noun_chunks.py
.py
import pytest from spacy.tokens import Doc # fmt: off @pytest.mark.parametrize( "words,heads,deps,pos,chunk_offsets", [ # determiner + noun # un pollo -> un pollo ( ["un", "pollo"], [1, 1], ["det", "ROOT"], ["DET", "NOUN"], [...
223
8,618
spaCy
spacy/tests/lang/it/test_text.py
.py
import pytest @pytest.mark.issue(2822) def test_issue2822(it_tokenizer): """Test that the abbreviation of poco is kept as one word.""" doc = it_tokenizer("Vuoi un po' di zucchero?") assert len(doc) == 6 assert doc[0].text == "Vuoi" assert doc[1].text == "un" assert doc[2].text == "po'" ass...
15
411
spaCy
spacy/tests/lang/lg/test_tokenizer.py
.py
import pytest LG_BASIC_TOKENIZATION_TESTS = [ ( "Abooluganda ab’emmamba ababiri", ["Abooluganda", "ab’emmamba", "ababiri"], ), ] @pytest.mark.parametrize("text,expected_tokens", LG_BASIC_TOKENIZATION_TESTS) def test_lg_tokenizer_basic(lg_tokenizer, text, expected_tokens): tokens = lg_toke...
16
449
spaCy
spacy/tests/lang/ga/test_tokenizer.py
.py
import pytest # fmt: off GA_TOKEN_EXCEPTION_TESTS = [ ("Niall Ó Domhnaill, Rialtas na hÉireann 1977 (lch. 600).", ["Niall", "Ó", "Domhnaill", ",", "Rialtas", "na", "hÉireann", "1977", "(", "lch.", "600", ")", "."]), ("Daoine a bhfuil Gaeilge acu, m.sh. tusa agus mise", ["Daoine", "a", "bhfuil", "Gaeilge", "acu...
16
684
spaCy
spacy/tests/lang/tt/test_tokenizer.py
.py
import pytest INFIX_HYPHEN_TESTS = [ ("Явым-төшем күләме.", "Явым-төшем күләме .".split()), ("Хатын-кыз киеме.", "Хатын-кыз киеме .".split()), ] PUNC_INSIDE_WORDS_TESTS = [ ( "Пассаҗир саны - 2,13 млн — кеше/көндә (2010), 783,9 млн. кеше/елда.", "Пассаҗир саны - 2,13 млн — кеше / көндә ( 2...
84
3,720
spaCy
spacy/tests/lang/fi/test_tokenizer.py
.py
import pytest ABBREVIATION_TESTS = [ ( "Hyvää uutta vuotta t. siht. Niemelä!", ["Hyvää", "uutta", "vuotta", "t.", "siht.", "Niemelä", "!"], ), ("Paino on n. 2.2 kg", ["Paino", "on", "n.", "2.2", "kg"]), ( "Vuonna 1 eaa. tapahtui kauheita.", ["Vuonna", "1", "eaa.", "tapah...
85
2,899
spaCy
spacy/tests/lang/fi/test_noun_chunks.py
.py
import pytest from spacy.tokens import Doc FI_NP_TEST_EXAMPLES = [ ( "Kaksi tyttöä potkii punaista palloa", ["NUM", "NOUN", "VERB", "ADJ", "NOUN"], ["nummod", "nsubj", "ROOT", "amod", "obj"], [1, 1, 0, 1, -2], ["Kaksi tyttöä", "punaista palloa"], ), ( "Eritt...
190
7,258
spaCy
spacy/tests/lang/fi/test_text.py
.py
import pytest @pytest.mark.parametrize( "text,match", [ ("10", True), ("1", True), ("10000", True), ("10,00", True), ("-999,0", True), ("yksi", True), ("kolmetoista", True), ("viisikymmentä", True), ("tuhat", True), ("1/2", True),...
25
542
spaCy
spacy/tests/lang/ta/test_tokenizer.py
.py
import pytest from spacy.lang.ta import Tamil from spacy.symbols import ORTH TA_BASIC_TOKENIZATION_TESTS = [ ( "கிறிஸ்துமஸ் மற்றும் இனிய புத்தாண்டு வாழ்த்துக்கள்", ["கிறிஸ்துமஸ்", "மற்றும்", "இனிய", "புத்தாண்டு", "வாழ்த்துக்கள்"], ), ( "எனக்கு என் குழந்தைப் பருவம் நினைவிருக்கிறது",...
190
7,830
spaCy
spacy/tests/lang/ta/test_text.py
.py
import pytest from spacy.lang.ta import Tamil # Wikipedia excerpt: https://en.wikipedia.org/wiki/Chennai (Tamil Language) TAMIL_BASIC_TOKENIZER_SENTENCIZER_TEST_TEXT = """சென்னை (Chennai) தமிழ்நாட்டின் தலைநகரமும், இந்தியாவின் நான்காவது பெரிய நகரமும் ஆகும். 1996 ஆம் ஆண்டுக்கு முன்னர் இந்நகரம், மதராசு பட்டினம், மெட்ராஸ...
27
2,738
spaCy
spacy/tests/lang/ht/test_exceptions.py
.py
import pytest def test_ht_tokenizer_handles_basic_contraction(ht_tokenizer): text = "m'ap ri" tokens = ht_tokenizer(text) assert len(tokens) == 3 assert tokens[0].text == "m'" assert tokens[1].text == "ap" assert tokens[2].text == "ri" text = "mwen di'w non!" tokens = ht_tokenizer(tex...
45
1,063
spaCy
spacy/tests/lang/ht/test_prefix_suffix_infix.py
.py
import pytest @pytest.mark.parametrize("text", ["(ka)"]) def test_ht_tokenizer_splits_no_special(ht_tokenizer, text): tokens = ht_tokenizer(text) assert len(tokens) == 3 @pytest.mark.parametrize("text", ["m'ap"]) def test_ht_tokenizer_splits_no_punct(ht_tokenizer, text): tokens = ht_tokenizer(text) ...
133
3,987
spaCy
spacy/tests/lang/ht/test_noun_chunks.py
.py
import pytest from spacy.tokens import Doc @pytest.fixture def doc(ht_vocab): words = ["Pitit", "gen", "gwo", "pwoblèm", "ak", "kontwòl"] heads = [1, 1, 5, 5, 3, 3] deps = ["nsubj", "ROOT", "amod", "obj", "case", "nmod"] pos = ["NOUN", "VERB", "ADJ", "NOUN", "ADP", "NOUN"] return Doc(ht_vocab, wo...
46
1,513
spaCy
spacy/tests/lang/ht/test_text.py
.py
import pytest from spacy.lang.ht.lex_attrs import like_num, norm_custom def test_ht_tokenizer_handles_long_text(ht_tokenizer): text = """Onè ap fèt pou ansyen lidè Pati Travayè Britanik Moun atravè lemond ap voye onè pou ansyen lidè Pati Travayè a, John Smith, ki mouri pi bonè jodi a apre li te fè yon gwo kriz ...
79
2,082
spaCy
spacy/tests/lang/de/test_exceptions.py
.py
import pytest @pytest.mark.parametrize("text", ["auf'm", "du's", "über'm", "wir's"]) def test_de_tokenizer_splits_contractions(de_tokenizer, text): tokens = de_tokenizer(text) assert len(tokens) == 2 @pytest.mark.parametrize("text", ["z.B.", "d.h.", "Jan.", "Dez.", "Chr."]) def test_de_tokenizer_handles_abb...
21
598
spaCy
spacy/tests/lang/de/test_prefix_suffix_infix.py
.py
import pytest @pytest.mark.parametrize("text", ["(unter)"]) def test_de_tokenizer_splits_no_special(de_tokenizer, text): tokens = de_tokenizer(text) assert len(tokens) == 3 @pytest.mark.parametrize("text", ["unter'm"]) def test_de_tokenizer_splits_no_punct(de_tokenizer, text): tokens = de_tokenizer(text...
109
3,395
spaCy
spacy/tests/lang/de/test_parser.py
.py
from spacy.tokens import Doc def test_de_parser_noun_chunks_standard_de(de_vocab): words = ["Eine", "Tasse", "steht", "auf", "dem", "Tisch", "."] heads = [1, 2, 2, 2, 5, 3, 2] pos = ["DET", "NOUN", "VERB", "ADP", "DET", "NOUN", "PUNCT"] deps = ["nk", "sb", "ROOT", "mo", "nk", "nk", "punct"] doc = ...
29
1,188
spaCy
spacy/tests/lang/de/test_noun_chunks.py
.py
import pytest def test_noun_chunks_is_parsed_de(de_tokenizer): """Test that noun_chunks raises Value Error for 'de' language if Doc is not parsed.""" doc = de_tokenizer("Er lag auf seinem") with pytest.raises(ValueError): list(doc.noun_chunks)
9
266
spaCy
spacy/tests/lang/de/test_text.py
.py
import pytest def test_de_tokenizer_handles_long_text(de_tokenizer): text = """Die Verwandlung Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten Rücken und sah, wenn er den Kopf ein wenig ho...
46
1,505
spaCy
spacy/tests/lang/sr/test_exceptions.py
.py
import pytest @pytest.mark.parametrize( "text,norms,lemmas", [ ("о.г.", ["ове године"], ["ова година"]), ("чет.", ["четвртак"], ["четвртак"]), ("гђа", ["госпођа"], ["госпођа"]), ("ил'", ["или"], ["или"]), ], ) def test_sr_tokenizer_abbrev_exceptions(sr_tokenizer, text, norm...
17
510
spaCy
spacy/tests/lang/sr/test_tokenizer.py
.py
import pytest PUNCT_OPEN = ["(", "[", "{", "*"] PUNCT_CLOSE = [")", "]", "}", "*"] PUNCT_PAIRED = [("(", ")"), ("[", "]"), ("{", "}"), ("*", "*")] @pytest.mark.parametrize("text", ["(", "((", "<"]) def test_sr_tokenizer_handles_only_punct(sr_tokenizer, text): tokens = sr_tokenizer(text) assert len(tokens) ==...
124
4,301
spaCy
spacy/tests/lang/bo/test_text.py
.py
import pytest @pytest.mark.parametrize( "text,match", [ ("10", True), ("1", True), ("999.0", True), ("གཅིག་", True), ("གཉིས་", True), ("ཀླད་ཀོར་", True), ("བཅུ་གཅིག་", True), ("ཁྱི་", False), (",", False), ], ) def test_lex_attrs_like...
22
517
spaCy
spacy/tests/lang/nn/test_tokenizer.py
.py
import pytest # examples taken from Omsetjingsminne frå Nynorsk pressekontor 2022 (https://www.nb.no/sprakbanken/en/resource-catalogue/oai-nb-no-sbr-80/) # fmt: off NN_TOKEN_EXCEPTION_TESTS = [ ( "Målet til direktoratet er at alle skal bli tilbydd jobb i politiet så raskt som mogleg i 2014.", [ ...
39
1,796
spaCy
spacy/tests/lang/dsb/test_tokenizer.py
.py
import pytest DSB_BASIC_TOKENIZATION_TESTS = [ ( "Ale eksistěrujo mimo togo ceła kopica narěcow, ako na pśikład slěpjańska.", [ "Ale", "eksistěrujo", "mimo", "togo", "ceła", "kopica", "narěcow", ",", ...
30
749
spaCy
spacy/tests/lang/dsb/test_text.py
.py
import pytest @pytest.mark.parametrize( "text,match", [ ("10", True), ("1", True), ("10,000", True), ("10,00", True), ("jadno", True), ("dwanassćo", True), ("milion", True), ("sto", True), ("ceła", False), ("kopica", False), ...
26
560
spaCy
spacy/tests/lang/hr/test_tokenizer.py
.py
import pytest HR_BASIC_TOKENIZATION_TESTS = [ ( "Nitko se ne smije podvrgnuti mučenju ni nečovječnom ili " "ponižavajućem postupanju ili kazni.", [ "Nitko", "se", "ne", "smije", "podvrgnuti", "mučenju", "ni"...
32
801
spaCy
spacy/tests/lang/hr/test_text.py
.py
import pytest def test_long_text(hr_tokenizer): # Excerpt: European Convention on Human Rights text = """ uzimajući u obzir da ta deklaracija nastoji osigurati opće i djelotvorno priznanje i poštovanje u njoj proglašenih prava; uzimajući u obzir da je cilj Vijeća Europe postizanje većeg jedinstva njegovih čla...
27
954
spaCy
spacy/tests/lang/es/test_exception.py
.py
import pytest @pytest.mark.parametrize( "text,lemma", [ ("aprox.", "aproximadamente"), ("esq.", "esquina"), ("pág.", "página"), ("p.ej.", "por ejemplo"), ], ) def test_es_tokenizer_handles_abbr(es_tokenizer, text, lemma): tokens = es_tokenizer(text) assert len(token...
23
549
spaCy
spacy/tests/lang/es/test_noun_chunks.py
.py
import pytest from spacy.tokens import Doc # fmt: off @pytest.mark.parametrize( "words,heads,deps,pos,chunk_offsets", [ # un gato -> "un gato" ( ["un", "gato"], [1, 1], ["det", "ROOT"], ["DET", "NOUN"], [(0, 2)], ), #...
160
9,946
spaCy
spacy/tests/lang/es/test_text.py
.py
import pytest from spacy.lang.es import Spanish from spacy.lang.es.lex_attrs import like_num @pytest.mark.issue(3803) def test_issue3803(): """Test that spanish num-like tokens have True for like_num attribute.""" nlp = Spanish() text = "2 dos 1000 mil 12 doce" doc = nlp(text) assert [t.like_num...
75
2,026
spaCy
spacy/tests/lang/fo/test_tokenizer.py
.py
import pytest # examples taken from Basic LAnguage Resource Kit 1.0 for Faroese (https://maltokni.fo/en/resources) licensed with CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) # fmt: off FO_TOKEN_EXCEPTION_TESTS = [ ( "Eftir løgtingslóg um samsýning og eftirløn landsstýrismanna v.m., skulu løgmað...
27
1,515
spaCy
spacy/tests/lang/grc/test_tokenizer.py
.py
import pytest # fmt: off GRC_TOKEN_EXCEPTION_TESTS = [ ("τὸ 〈τῆς〉 φιλοσοφίας ἔργον ἔνιοί φασιν ἀπὸ ⟦βαρβάρων⟧ ἄρξαι.", ["τὸ", "〈", "τῆς", "〉", "φιλοσοφίας", "ἔργον", "ἔνιοί", "φασιν", "ἀπὸ", "⟦", "βαρβάρων", "⟧", "ἄρξαι", "."]), ("τὴν δὲ τῶν Αἰγυπτίων φιλοσοφίαν εἶναι τοιαύτην περί τε †θεῶν† καὶ ὑπὲρ δικαιοσύν...
18
1,326
spaCy
spacy/tests/lang/grc/test_text.py
.py
import pytest @pytest.mark.parametrize( "text,match", [ ("ι", True), ("α", True), ("ϟα", True), ("ἑκατόν", True), ("ἐνακόσια", True), ("δισχίλια", True), ("μύρια", True), ("εἷς", True), ("λόγος", False), (",", False), ("λβ...
24
543
spaCy
spacy/tests/lang/nl/test_noun_chunks.py
.py
import pytest from spacy.tokens import Doc from spacy.util import filter_spans @pytest.fixture def nl_sample(nl_vocab): # TEXT : # Haar vriend lacht luid. We kregen alweer ruzie toen we de supermarkt ingingen. # Aan het begin van de supermarkt is al het fruit en de groentes. Uiteindelijk hebben we dan oo...
227
4,304
spaCy
spacy/tests/lang/nl/test_text.py
.py
import pytest from spacy.lang.nl.lex_attrs import like_num @pytest.mark.parametrize("word", ["elf", "elfde"]) def test_nl_lex_attrs_capitals(word): assert like_num(word) assert like_num(word.upper()) @pytest.mark.parametrize( "text,num_tokens", [ ( "De aftredende minister-presid...
26
694
spaCy
spacy/tests/lang/kmr/test_text.py
.py
import pytest from spacy.lang.kmr.lex_attrs import like_num @pytest.mark.parametrize( "word", [ "yekem", "duyemîn", "100em", "dehem", "sedemîn", "34em", "30yem", "20emîn", "50yemîn", ], ) def test_kmr_lex_attrs_like_number_for_ordina...
28
502
spaCy
spacy/tests/lang/ar/test_exceptions.py
.py
import pytest @pytest.mark.parametrize("text", ["ق.م", "إلخ", "ص.ب", "ت."]) def test_ar_tokenizer_handles_abbr(ar_tokenizer, text): tokens = ar_tokenizer(text) assert len(tokens) == 1 def test_ar_tokenizer_handles_exc_in_text(ar_tokenizer): text = "تعود الكتابة الهيروغليفية إلى سنة 3200 ق.م" tokens ...
21
621
spaCy
spacy/tests/lang/ar/test_text.py
.py
def test_ar_tokenizer_handles_long_text(ar_tokenizer): text = """نجيب محفوظ مؤلف و كاتب روائي عربي، يعد من أهم الأدباء العرب خلال القرن العشرين. ولد نجيب محفوظ في مدينة القاهرة، حيث ترعرع و تلقى تعليمه الجامعي في جامعتها، فتمكن من نيل شهادة في الفلسفة. ألف محفوظ على مدار حياته الكثير من الأعمال الأدبية، ...
10
821
spaCy
spacy/tests/lang/bn/test_tokenizer.py
.py
import pytest # fmt: off TESTCASES = [ # Punctuation tests ("আমি বাংলায় গান গাই!", ["আমি", "বাংলায়", "গান", "গাই", "!"]), ("আমি বাংলায় কথা কই।", ["আমি", "বাংলায়", "কথা", "কই", "।"]), ("বসুন্ধরা জনসম্মুখে দোষ স্বীকার করলো না?", ["বসুন্ধরা", "জনসম্মুখে", "দোষ", "স্বীকার", "করলো", "না", "?"]), ("ট...
37
3,622
spaCy
spacy/tests/lang/fa/test_noun_chunks.py
.py
import pytest def test_noun_chunks_is_parsed_fa(fa_tokenizer): """Test that noun_chunks raises Value Error for 'fa' language if Doc is not parsed.""" doc = fa_tokenizer("این یک جمله نمونه می باشد.") with pytest.raises(ValueError): list(doc.noun_chunks)
10
296
spaCy
spacy/tests/lang/ca/test_exception.py
.py
import pytest @pytest.mark.parametrize( "text,lemma", [("aprox.", "aproximadament"), ("pàg.", "pàgina"), ("p.ex.", "per exemple")], ) def test_ca_tokenizer_handles_abbr(ca_tokenizer, text, lemma): tokens = ca_tokenizer(text) assert len(tokens) == 1 def test_ca_tokenizer_handles_exc_in_text(ca_tokeni...
29
621
spaCy
spacy/tests/lang/ca/test_prefix_suffix_infix.py
.py
import pytest @pytest.mark.parametrize( "text,expected_tokens", [ ("d'un", ["d'", "un"]), ("s'ha", ["s'", "ha"]), ("del", ["d", "el"]), ("cantar-te", ["cantar", "-te"]), ("-hola", ["-", "hola"]), ], ) def test_contractions(ca_tokenizer, text, expected_tokens): "...
19
493
spaCy
spacy/tests/lang/ca/test_text.py
.py
"""Test that longer and mixed texts are tokenized correctly.""" import pytest def test_ca_tokenizer_handles_long_text(ca_tokenizer): text = """Una taula amb grans gerres de begudes i palles de coloraines com a reclam. Una carta cridanera amb ofertes de tapes, paelles i sangria. Un cambrer amb un somriure que...
57
1,901
spaCy
spacy/tests/lang/eu/test_text.py
.py
import pytest def test_eu_tokenizer_handles_long_text(eu_tokenizer): text = """ta nere guitarra estrenatu ondoren""" tokens = eu_tokenizer(text) assert len(tokens) == 5 @pytest.mark.parametrize( "text,length", [ ("milesker ederra joan zen hitzaldia plazer hutsa", 7), ("astelehen ...
20
488
spaCy
spacy/tests/lang/cs/test_text.py
.py
import pytest @pytest.mark.parametrize( "text,match", [ ("10", True), ("1", True), ("10.000", True), ("1000", True), ("999,0", True), ("devatenáct", True), ("osmdesát", True), ("kvadrilion", True), ("Pes", False), (",", False), ...
24
510
spaCy
spacy/tests/lang/ne/test_text.py
.py
import pytest def test_ne_tokenizer_handlers_long_text(ne_tokenizer): text = """मैले पाएको सर्टिफिकेटलाई म त बोक्रो सम्झन्छु र अभ्यास तब सुरु भयो, जब मैले कलेज पार गरेँ र जीवनको पढाइ सुरु गरेँ ।""" tokens = ne_tokenizer(text) assert len(tokens) == 24 @pytest.mark.parametrize( "text,length", [("समय ज...
16
783
spaCy
spacy/tests/lang/ur/test_prefix_suffix_infix.py
.py
import pytest @pytest.mark.parametrize("text", ["ہےں۔", "کیا۔"]) def test_contractions(ur_tokenizer, text): """Test specific Urdu punctuation character""" tokens = ur_tokenizer(text) assert len(tokens) == 2
9
229
spaCy
spacy/tests/lang/ur/test_text.py
.py
import pytest def test_ur_tokenizer_handles_long_text(ur_tokenizer): text = """اصل میں، رسوا ہونے کی ہمیں کچھ عادت سی ہو گئی ہے۔""" tokens = ur_tokenizer(text) assert len(tokens) == 14 @pytest.mark.parametrize("text,length", [("تحریر باسط حبیب", 3), ("میرا پاکستان", 2)]) def test_ur_tokenizer_handles_cn...
14
479
spaCy
spacy/tests/lang/ti/test_text.py
.py
import pytest def test_ti_tokenizer_handles_long_text(ti_tokenizer): text = """ቻንስለር ጀርመን ኣንገላ መርከል ኣብታ ሃገር ቁጽሪ መትሓዝቲ ኮቪድ መዓልታዊ ክብረ መዝገብ ድሕሪ ምህራሙ- ጽኑዕ እገዳ ክግበር ጸዊዓ። መርከል ሎሚ ንታሕታዋይ ባይቶ ሃገራ ክትገልጽ ከላ፡ ኣብ ወሳኒ ምዕራፍ ቃልሲ ኢና ዘለና-ዳሕራዋይ ማዕበል ካብቲ ቀዳማይ ክገድድ ይኽእል`ዩ ኢላ። ትካል ምክልኻል ተላገብቲ ሕማማት ጀርመን፡ ኣብ ዝሓለፈ 24 ሰዓታት ኣብ ምልእቲ ጀርመር...
52
2,120
spaCy
spacy/tests/lang/mk/test_text.py
.py
import pytest from spacy.lang.mk.lex_attrs import like_num def test_tokenizer_handles_long_text(mk_tokenizer): text = """ Во организациските работи или на нашите собранија со членството, никој од нас не зборуваше за организацијата и идеологијата. Работна беше нашата работа, а не идеолошка. Што се однесув...
79
4,353
spaCy
spacy/tests/lang/hy/test_tokenizer.py
.py
import pytest # TODO add test cases with valid punctuation signs. hy_tokenize_text_test = [ ( "Մետաղագիտությունը պայմանականորեն բաժանվում է տեսականի և կիրառականի (տեխնիկական)", [ "Մետաղագիտությունը", "պայմանականորեն", "բաժանվում", "է", "տ...
45
1,350
spaCy
spacy/tests/lang/hy/test_text.py
.py
import pytest from spacy.lang.hy.lex_attrs import like_num @pytest.mark.parametrize("word", ["հիսուն"]) def test_hy_lex_attrs_capitals(word): assert like_num(word) assert like_num(word.upper())
10
211
spaCy
spacy/tests/lang/sk/test_tokenizer.py
.py
import pytest SK_BASIC_TOKENIZATION_TESTS = [ ( "Kedy sa narodil Andrej Kiska?", ["Kedy", "sa", "narodil", "Andrej", "Kiska", "?"], ), ] @pytest.mark.parametrize("text,expected_tokens", SK_BASIC_TOKENIZATION_TESTS) def test_sk_tokenizer_basic(sk_tokenizer, text, expected_tokens): tokens =...
16
453
spaCy
spacy/tests/lang/sk/test_text.py
.py
import pytest def test_long_text(sk_tokenizer): # Excerpt: European Convention on Human Rights text = """ majúc na zreteli, že cieľom tejto deklarácie je zabezpečiť všeobecné a účinné uznávanie a dodržiavanie práv v nej vyhlásených; majúc na zreteli, že cieľom Rady Európy je dosiahnutie väčšej jednoty medzi j...
49
1,485
spaCy
spacy/tests/lang/sl/test_tokenizer.py
.py
import pytest SL_BASIC_TOKENIZATION_TESTS = [ ( "Vsakdo ima pravico do spoštovanja njegovega zasebnega in " "družinskega življenja, doma in dopisovanja.", [ "Vsakdo", "ima", "pravico", "do", "spoštovanja", "njegovega", ...
33
831
spaCy
spacy/tests/lang/sl/test_text.py
.py
def test_long_text(sl_tokenizer): # Excerpt: European Convention on Human Rights text = """ upoštevajoč, da si ta deklaracija prizadeva zagotoviti splošno in učinkovito priznavanje in spoštovanje v njej razglašenih pravic, upoštevajoč, da je cilj Sveta Evrope doseči večjo enotnost med njegovimi članicami, in da...
24
977
spaCy
spacy/tests/lang/ko/test_serialize.py
.py
import pickle from spacy.lang.ko import Korean from ...util import make_tempdir def test_ko_tokenizer_serialize(ko_tokenizer): tokenizer_bytes = ko_tokenizer.to_bytes() nlp = Korean() nlp.tokenizer.from_bytes(tokenizer_bytes) assert tokenizer_bytes == nlp.tokenizer.to_bytes() with make_tempdir(...
26
713
spaCy
spacy/tests/lang/ko/test_tokenizer.py
.py
import pytest # fmt: off TOKENIZER_TESTS = [("서울 타워 근처에 살고 있습니다.", "서울 타워 근처 에 살 고 있 습니다 ."), ("영등포구에 있는 맛집 좀 알려주세요.", "영등포구 에 있 는 맛집 좀 알려 주 세요 ."), ("10$ 할인코드를 적용할까요?", "10 $ 할인 코드 를 적용 할까요 ?")] TAG_TESTS = [("서울 타워 근처에 살고 있습니다.", "NNP NNG NNG JKB VV EC VX EF SF"),...
76
2,893
spaCy
spacy/tests/lang/ko/test_lemmatization.py
.py
import pytest @pytest.mark.parametrize( "word,lemma", [ ("새로운", "새롭"), ("빨간", "빨갛"), ("클수록", "크"), ("뭡니까", "뭣"), ("됐다", "되"), ], ) def test_ko_lemmatizer_assigns(ko_tokenizer, word, lemma): test_lemma = ko_tokenizer(word)[0].lemma_ assert test_lemma == lemma...
17
361
spaCy
spacy/tests/lang/sq/test_tokenizer.py
.py
import pytest SQ_BASIC_TOKENIZATION_TESTS = [ ( "Askush nuk mund t’i nënshtrohet torturës ose dënimeve ose " "trajtimeve çnjerëzore ose poshtëruese.", [ "Askush", "nuk", "mund", "t’i", "nënshtrohet", "torturës", ...
32
817
spaCy
spacy/tests/lang/sq/test_text.py
.py
def test_long_text(sq_tokenizer): # Excerpt: European Convention on Human Rights text = """ Qeveritë nënshkruese, anëtare të Këshillit të Evropës, Duke pasur parasysh Deklaratën Universale të të Drejtave të Njeriut, të shpallur nga Asambleja e Përgjithshme e Kombeve të Bashkuara më 10 dhjetor 1948; Duke pasur p...
23
1,162
spaCy
spacy/tests/lang/ro/test_tokenizer.py
.py
import pytest TEST_CASES = [ ( "Adresa este str. Principală nr. 5.", ["Adresa", "este", "str.", "Principală", "nr.", "5", "."], ), ("Teste, etc.", ["Teste", ",", "etc."]), ("Lista, ș.a.m.d.", ["Lista", ",", "ș.a.m.d."]), ("Și d.p.d.v. al...", ["Și", "d.p.d.v.", "al", "..."]), # ...
22
733
spaCy
spacy/tests/lang/gu/test_text.py
.py
import pytest def test_gu_tokenizer_handlers_long_text(gu_tokenizer): text = """પશ્ચિમ ભારતમાં આવેલું ગુજરાત રાજ્ય જે વ્યક્તિઓની માતૃભૂમિ છે""" tokens = gu_tokenizer(text) assert len(tokens) == 9 @pytest.mark.parametrize( "text,length", [("ગુજરાતીઓ ખાવાના શોખીન માનવામાં આવે છે", 6), ("ખેતરની ખેડ...
17
685
spaCy
spacy/tests/lang/lb/test_exceptions.py
.py
import pytest @pytest.mark.parametrize("text", ["z.B.", "Jan."]) def test_lb_tokenizer_handles_abbr(lb_tokenizer, text): tokens = lb_tokenizer(text) assert len(tokens) == 1 @pytest.mark.parametrize("text", ["d'Saach", "d'Kanner", "d’Welt", "d’Suen"]) def test_lb_tokenizer_splits_contractions(lb_tokenizer, t...
21
590
spaCy
spacy/tests/lang/lb/test_prefix_suffix_infix.py
.py
import pytest @pytest.mark.parametrize("text,length", [("z.B.", 1), ("zb.", 2), ("(z.B.", 2)]) def test_lb_tokenizer_splits_prefix_interact(lb_tokenizer, text, length): tokens = lb_tokenizer(text) assert len(tokens) == length @pytest.mark.parametrize("text", ["z.B.)"]) def test_lb_tokenizer_splits_suffix_in...
20
584
spaCy
spacy/tests/lang/lb/test_text.py
.py
import pytest def test_lb_tokenizer_handles_long_text(lb_tokenizer): text = """Den Nordwand an d'Sonn An der Zäit hunn sech den Nordwand an d'Sonn gestridden, wie vun hinnen zwee wuel méi staark wier, wéi e Wanderer, deen an ee waarme Mantel agepak war, iwwert de Wee koum. Si goufen sech eens, dass deejéinege fir...
22
1,302
spaCy
spacy/tests/lang/th/test_serialize.py
.py
import pickle from spacy.lang.th import Thai from ...util import make_tempdir def test_th_tokenizer_serialize(th_tokenizer): tokenizer_bytes = th_tokenizer.to_bytes() nlp = Thai() nlp.tokenizer.from_bytes(tokenizer_bytes) assert tokenizer_bytes == nlp.tokenizer.to_bytes() with make_tempdir() as...
26
707
spaCy
spacy/tests/lang/th/test_tokenizer.py
.py
import pytest @pytest.mark.parametrize( "text,expected_tokens", [("คุณรักผมไหม", ["คุณ", "รัก", "ผม", "ไหม"])] ) def test_th_tokenizer(th_tokenizer, text, expected_tokens): tokens = [token.text for token in th_tokenizer(text)] assert tokens == expected_tokens
10
318
spaCy
spacy/tests/lang/ms/test_prefix_suffix_infix.py
.py
import pytest @pytest.mark.parametrize("text", ["(Ma'arif)"]) def test_ms_tokenizer_splits_no_special(id_tokenizer, text): tokens = id_tokenizer(text) assert len(tokens) == 3 @pytest.mark.parametrize("text", ["Ma'arif"]) def test_ms_tokenizer_splits_no_punct(id_tokenizer, text): tokens = id_tokenizer(te...
113
3,512
spaCy
spacy/tests/lang/ms/test_noun_chunks.py
.py
import pytest def test_noun_chunks_is_parsed_ms(ms_tokenizer): """Test that noun_chunks raises Value Error for 'ms' language if Doc is not parsed.""" doc = ms_tokenizer("sebelas") with pytest.raises(ValueError): list(doc.noun_chunks)
9
256
spaCy
spacy/tests/lang/ms/test_text.py
.py
import pytest from spacy.lang.ms.lex_attrs import like_num @pytest.mark.parametrize("word", ["sebelas"]) def test_ms_lex_attrs_capitals(word): assert like_num(word) assert like_num(word.upper())
10
206
spaCy
spacy/tests/lang/en/test_customized_tokenizer.py
.py
import re import pytest from spacy.lang.en import English from spacy.tokenizer import Tokenizer from spacy.util import compile_infix_regex, compile_prefix_regex, compile_suffix_regex @pytest.fixture def custom_en_tokenizer(en_vocab): prefix_re = compile_prefix_regex(English.Defaults.prefixes) suffix_re = co...
155
3,778
spaCy
spacy/tests/lang/en/test_sbd.py
.py
import pytest from spacy.tokens import Doc from ...util import apply_transition_sequence @pytest.mark.issue(309) def test_issue309(en_vocab): """Test Issue #309: SBD fails on empty string""" doc = Doc(en_vocab, words=[" "], heads=[0], deps=["ROOT"]) assert len(doc) == 1 sents = list(doc.sents) a...
47
1,708
spaCy
spacy/tests/lang/en/test_exceptions.py
.py
import pytest def test_en_tokenizer_handles_basic_contraction(en_tokenizer): text = "don't giggle" tokens = en_tokenizer(text) assert len(tokens) == 3 assert tokens[1].text == "n't" text = "i said don't!" tokens = en_tokenizer(text) assert len(tokens) == 5 assert tokens[4].text == "!" ...
128
4,158
spaCy
spacy/tests/lang/en/test_prefix_suffix_infix.py
.py
import pytest @pytest.mark.parametrize("text", ["(can)"]) def test_en_tokenizer_splits_no_special(en_tokenizer, text): tokens = en_tokenizer(text) assert len(tokens) == 3 @pytest.mark.parametrize("text", ["can't"]) def test_en_tokenizer_splits_no_punct(en_tokenizer, text): tokens = en_tokenizer(text) ...
138
4,254
spaCy
spacy/tests/lang/en/test_punct.py
.py
import pytest from spacy.lang.punctuation import TOKENIZER_PREFIXES from spacy.util import compile_prefix_regex PUNCT_OPEN = ["(", "[", "{", "*"] PUNCT_CLOSE = [")", "]", "}", "*"] PUNCT_PAIRED = [("(", ")"), ("[", "]"), ("{", "}"), ("*", "*")] @pytest.mark.parametrize("text", ["(", "((", "<"]) def test_en_tokenize...
128
4,422
spaCy
spacy/tests/lang/en/test_parser.py
.py
from spacy.tokens import Doc def test_en_parser_noun_chunks_standard(en_vocab): words = ["A", "base", "phrase", "should", "be", "recognized", "."] heads = [2, 2, 5, 5, 5, 5, 5] pos = ["DET", "ADJ", "NOUN", "AUX", "VERB", "VERB", "PUNCT"] deps = ["det", "amod", "nsubjpass", "aux", "auxpass", "ROOT", "p...
67
2,954