From 932727a9cf342b72dba748880aa481b24147d164 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 08:08:02 +0100 Subject: [PATCH 01/32] Update dependency pins: thinc 8.3.12, confection 1.1, weasel 1.0 --- pyproject.toml | 2 +- requirements.txt | 6 +++--- setup.cfg | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 64b71429e6e..24d21dc342d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ requires = [ "cymem>=2.0.2,<2.1.0", "preshed>=3.0.2,<3.1.0", "murmurhash>=0.28.0,<1.1.0", - "thinc>=8.3.4,<8.4.0", + "thinc>=8.3.12,<8.4.0", "numpy>=2.0.0,<3.0.0" ] build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt index 895bc3f7c07..4fcf639ad4a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,14 +3,14 @@ spacy-legacy>=3.0.11,<3.1.0 spacy-loggers>=1.0.0,<2.0.0 cymem>=2.0.2,<2.1.0 preshed>=3.0.2,<3.1.0 -thinc>=8.3.4,<8.4.0 +thinc>=8.3.12,<8.4.0 ml_datasets>=0.2.0,<0.3.0 murmurhash>=0.28.0,<1.1.0 wasabi>=0.9.1,<1.2.0 srsly>=2.4.3,<3.0.0 catalogue>=2.0.6,<2.1.0 typer>=0.3.0,<1.0.0 -weasel>=0.4.2,<0.5.0 +weasel>=1.0.0,<2.0.0 # Third party dependencies numpy>=2.0.0,<3.0.0 requests>=2.13.0,<3.0.0 @@ -36,4 +36,4 @@ types-setuptools>=57.0.0 black>=25.0.0 cython-lint>=0.15.0 isort>=5.0,<6.0 -confection>=0.0.4,<1.0.0 +confection>=1.1.0,<2.0.0 diff --git a/setup.cfg b/setup.cfg index 585c2694fe2..7fdd3979868 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,7 +41,7 @@ setup_requires = cymem>=2.0.2,<2.1.0 preshed>=3.0.2,<3.1.0 murmurhash>=0.28.0,<1.1.0 - thinc>=8.3.4,<8.4.0 + thinc>=8.3.12,<8.4.0 install_requires = # Our libraries spacy-legacy>=3.0.11,<3.1.0 @@ -49,12 +49,12 @@ install_requires = murmurhash>=0.28.0,<1.1.0 cymem>=2.0.2,<2.1.0 preshed>=3.0.2,<3.1.0 - thinc>=8.3.4,<8.4.0 + thinc>=8.3.12,<8.4.0 wasabi>=0.9.1,<1.2.0 srsly>=2.4.3,<3.0.0 catalogue>=2.0.6,<2.1.0 - weasel>=0.4.2,<0.5.0 - confection>=0.0.4,<1.0.0 + weasel>=1.0.0,<2.0.0 + confection>=1.1.0,<2.0.0 # Third-party dependencies typer>=0.3.0,<1.0.0 tqdm>=4.38.0,<5.0.0 From e5fc4d670676e87e15ac2d6e6f81a7d8c7b8c093 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 08:31:48 +0100 Subject: [PATCH 02/32] Format --- spacy/lang/af/stop_words.py | 6 +++-- spacy/lang/am/stop_words.py | 6 +++-- spacy/lang/ar/lex_attrs.py | 12 ++++++---- spacy/lang/ar/stop_words.py | 6 +++-- spacy/lang/az/stop_words.py | 6 +++-- spacy/lang/bg/stop_words.py | 6 +++-- spacy/lang/bn/stop_words.py | 6 +++-- spacy/lang/bo/stop_words.py | 6 +++-- spacy/lang/ca/stop_words.py | 6 +++-- spacy/lang/cs/stop_words.py | 6 +++-- spacy/lang/da/stop_words.py | 6 +++-- spacy/lang/de/stop_words.py | 6 +++-- spacy/lang/dsb/stop_words.py | 6 +++-- spacy/lang/el/stop_words.py | 6 +++-- spacy/lang/en/stop_words.py | 6 +++-- spacy/lang/es/stop_words.py | 6 +++-- spacy/lang/et/stop_words.py | 6 +++-- spacy/lang/eu/stop_words.py | 6 +++-- spacy/lang/fa/lex_attrs.py | 12 ++++++---- spacy/lang/fa/stop_words.py | 6 +++-- spacy/lang/fi/stop_words.py | 6 +++-- spacy/lang/fr/lex_attrs.py | 12 ++++++---- spacy/lang/fr/stop_words.py | 6 +++-- spacy/lang/ga/stop_words.py | 6 +++-- spacy/lang/gd/stop_words.py | 8 +++++-- spacy/lang/gd/tokenizer_exceptions.py | 4 +++- spacy/lang/grc/stop_words.py | 6 +++-- spacy/lang/gu/stop_words.py | 6 +++-- spacy/lang/he/stop_words.py | 6 +++-- spacy/lang/hi/stop_words.py | 6 +++-- spacy/lang/hr/stop_words.py | 6 +++-- spacy/lang/hsb/stop_words.py | 6 +++-- spacy/lang/ht/lex_attrs.py | 12 ++++++---- spacy/lang/ht/stop_words.py | 6 +++-- spacy/lang/hu/stop_words.py | 6 +++-- spacy/lang/hy/stop_words.py | 6 +++-- spacy/lang/id/_tokenizer_exceptions_list.py | 6 +++-- spacy/lang/id/stop_words.py | 6 +++-- spacy/lang/is/stop_words.py | 6 +++-- spacy/lang/it/stop_words.py | 6 +++-- spacy/lang/ja/stop_words.py | 6 +++-- spacy/lang/kmr/stop_words.py | 6 +++-- spacy/lang/kn/stop_words.py | 6 +++-- spacy/lang/ko/stop_words.py | 6 +++-- spacy/lang/ky/stop_words.py | 6 +++-- spacy/lang/la/stop_words.py | 6 +++-- spacy/lang/lb/lex_attrs.py | 12 ++++++---- spacy/lang/lb/stop_words.py | 6 +++-- spacy/lang/lg/stop_words.py | 6 +++-- spacy/lang/lij/stop_words.py | 6 +++-- spacy/lang/lv/stop_words.py | 6 +++-- spacy/lang/mk/stop_words.py | 6 +++-- spacy/lang/ml/stop_words.py | 6 +++-- spacy/lang/mr/stop_words.py | 6 +++-- spacy/lang/ms/_tokenizer_exceptions_list.py | 6 +++-- spacy/lang/ms/stop_words.py | 6 +++-- spacy/lang/nb/stop_words.py | 6 +++-- spacy/lang/ne/stop_words.py | 6 +++-- spacy/lang/nl/lex_attrs.py | 12 ++++++---- spacy/lang/nl/stop_words.py | 6 +++-- spacy/lang/pl/stop_words.py | 6 +++-- spacy/lang/pt/stop_words.py | 6 +++-- spacy/lang/ro/lex_attrs.py | 12 ++++++---- spacy/lang/ro/stop_words.py | 6 +++-- spacy/lang/ru/lex_attrs.py | 8 +++++-- spacy/lang/ru/stop_words.py | 6 +++-- spacy/lang/sa/stop_words.py | 6 +++-- spacy/lang/si/stop_words.py | 6 +++-- spacy/lang/sk/stop_words.py | 6 +++-- spacy/lang/sl/lex_attrs.py | 18 +++++++++----- spacy/lang/sl/stop_words.py | 6 +++-- spacy/lang/sq/stop_words.py | 6 +++-- spacy/lang/sr/stop_words.py | 6 +++-- spacy/lang/sv/stop_words.py | 6 +++-- spacy/lang/ta/stop_words.py | 6 +++-- spacy/lang/te/stop_words.py | 6 +++-- spacy/lang/th/stop_words.py | 6 +++-- spacy/lang/ti/stop_words.py | 6 +++-- spacy/lang/tl/stop_words.py | 6 +++-- spacy/lang/tn/stop_words.py | 6 +++-- spacy/lang/tokenizer_exceptions.py | 6 +++-- spacy/lang/tr/stop_words.py | 6 +++-- spacy/lang/tt/stop_words.py | 6 +++-- spacy/lang/uk/stop_words.py | 6 +++-- spacy/lang/ur/lex_attrs.py | 4 +--- spacy/lang/ur/stop_words.py | 6 +++-- spacy/lang/vi/stop_words.py | 8 +++++-- spacy/lang/zh/stop_words.py | 6 +++-- .../pipeline/_edit_tree_internals/schemas.py | 11 ++++++++- spacy/pipeline/attributeruler.py | 4 +++- spacy/schemas.py | 6 ++++- .../tests/matcher/test_pattern_validation.py | 24 +++++++++++++++---- 92 files changed, 428 insertions(+), 201 deletions(-) diff --git a/spacy/lang/af/stop_words.py b/spacy/lang/af/stop_words.py index 337afb57f8c..4b5a04a5eca 100644 --- a/spacy/lang/af/stop_words.py +++ b/spacy/lang/af/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/stopwords-iso/stopwords-af -STOP_WORDS = set(""" +STOP_WORDS = set( + """ 'n aan af @@ -52,4 +53,5 @@ was wat ʼn -""".split()) +""".split() +) diff --git a/spacy/lang/am/stop_words.py b/spacy/lang/am/stop_words.py index 8a04c555f74..5487ada5aeb 100644 --- a/spacy/lang/am/stop_words.py +++ b/spacy/lang/am/stop_words.py @@ -1,7 +1,8 @@ # Stop words by Teshome Kassie http://etd.aau.edu.et/bitstream/handle/123456789/3315/Teshome%20Kassie.pdf?sequence=1&isAllowed=y # Stop words by Tihitina Petros http://etd.aau.edu.et/bitstream/handle/123456789/3384/Tihitina%20Petros.pdf?sequence=1&isAllowed=y -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ግን አንቺ አንተ እናንተ ያንተ ያንቺ የናንተ ራስህን ራስሽን ራሳችሁን ሁሉ ኋላ በሰሞኑ አሉ በኋላ ሁኔታ በኩል አስታውቀዋል ሆነ በውስጥ አስታውሰዋል ሆኑ ባጣም እስካሁን ሆኖም በተለይ አሳሰበ ሁል በተመለከተ @@ -28,4 +29,5 @@ በዚህም መሆን ምንጊዜም እነዚህም በዚህና ያለ ስም ሲኖር ከዚህም መሆኑን በሁኔታው የማያንስ እነዚህኑ ማንም ከነዚሁ ያላቸውን እጅግ ሲሆኑ ለሆኑ ሊሆን ለማናቸውም -""".split()) +""".split() +) diff --git a/spacy/lang/ar/lex_attrs.py b/spacy/lang/ar/lex_attrs.py index 6e943d064ee..54ad7a8c363 100644 --- a/spacy/lang/ar/lex_attrs.py +++ b/spacy/lang/ar/lex_attrs.py @@ -1,6 +1,7 @@ from ...attrs import LIKE_NUM -_num_words = set(""" +_num_words = set( + """ صفر واحد إثنان @@ -50,9 +51,11 @@ مليون مليار مليارات -""".split()) +""".split() +) -_ordinal_words = set(""" +_ordinal_words = set( + """ اول أول حاد @@ -67,7 +70,8 @@ ثامن تاسع عاشر -""".split()) +""".split() +) def like_num(text): diff --git a/spacy/lang/ar/stop_words.py b/spacy/lang/ar/stop_words.py index 65c8992cbd6..f4da54dda29 100644 --- a/spacy/lang/ar/stop_words.py +++ b/spacy/lang/ar/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ من نحو لعل @@ -385,4 +386,5 @@ وإن ولو يا -""".split()) +""".split() +) diff --git a/spacy/lang/az/stop_words.py b/spacy/lang/az/stop_words.py index 8beffa998da..2114939ba11 100644 --- a/spacy/lang/az/stop_words.py +++ b/spacy/lang/az/stop_words.py @@ -1,5 +1,6 @@ # Source: https://github.com/eliasdabbas/advertools/blob/master/advertools/stopwords.py -STOP_WORDS = set(""" +STOP_WORDS = set( + """ amma arasında artıq @@ -140,4 +141,5 @@ əlbəttə ən əslində -""".split()) +""".split() +) diff --git a/spacy/lang/bg/stop_words.py b/spacy/lang/bg/stop_words.py index 7d3e756054d..061850da594 100644 --- a/spacy/lang/bg/stop_words.py +++ b/spacy/lang/bg/stop_words.py @@ -4,7 +4,8 @@ https://postvai.com/books/stop-dumi.pdf - Additions to the original list in order to improve it. """ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ а автентичен аз ако ала бе без беше би бивш бивша бившо бивши бил била били било благодаря близо бъдат @@ -75,4 +76,5 @@ юмрук я як -""".split()) +""".split() +) diff --git a/spacy/lang/bn/stop_words.py b/spacy/lang/bn/stop_words.py index 5aec18b7f5b..bf38e32545e 100644 --- a/spacy/lang/bn/stop_words.py +++ b/spacy/lang/bn/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ অতএব অথচ অথবা অনুযায়ী অনেক অনেকে অনেকেই অন্তত অবধি অবশ্য অর্থাৎ অন্য অনুযায়ী অর্ধভাগে আগামী আগে আগেই আছে আজ আদ্যভাগে আপনার আপনি আবার আমরা আমাকে আমাদের আমার আমি আর আরও ইত্যাদি ইহা @@ -37,4 +38,5 @@ সাধারণ সামনে সঙ্গে সঙ্গেও সব সবার সমস্ত সম্প্রতি সময় সহ সহিত সাথে সুতরাং সে সেই সেখান সেখানে সেটা সেটাই সেটাও সেটি স্পষ্ট স্বয়ং হইতে হইবে হইয়া হওয়া হওয়ায় হওয়ার হচ্ছে হত হতে হতেই হন হবে হবেন হয় হয়তো হয়নি হয়ে হয়েই হয়েছিল হয়েছে হাজার হয়েছেন হল হলে হলেই হলেও হলো হিসাবে হিসেবে হৈলে হোক হয় হয়ে হয়েছে হৈতে হইয়া হয়েছিল হয়েছেন হয়নি হয়েই হয়তো হওয়া হওয়ার হওয়ায় -""".split()) +""".split() +) diff --git a/spacy/lang/bo/stop_words.py b/spacy/lang/bo/stop_words.py index 158e148b00b..407242c849b 100644 --- a/spacy/lang/bo/stop_words.py +++ b/spacy/lang/bo/stop_words.py @@ -1,6 +1,7 @@ # Source: https://zenodo.org/records/10148636 -STOP_WORDS = set(""" +STOP_WORDS = set( + """ འི་ ། དུ་ @@ -193,4 +194,5 @@ གིང་ ཚ་ ཀྱང -""".split()) +""".split() +) diff --git a/spacy/lang/ca/stop_words.py b/spacy/lang/ca/stop_words.py index 90cce5de885..1a87b2f9dbe 100644 --- a/spacy/lang/ca/stop_words.py +++ b/spacy/lang/ca/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a abans ací ah així això al aleshores algun alguna algunes alguns alhora allà allí allò als altra altre altres amb ambdues ambdós anar ans apa aquell aquella aquelles aquells aquest aquesta aquestes aquests aquí @@ -47,4 +48,5 @@ va vaig vam van vas veu vosaltres vostra vostre vostres -""".split()) +""".split() +) diff --git a/spacy/lang/cs/stop_words.py b/spacy/lang/cs/stop_words.py index 35db9fedc86..f61f424f6f4 100644 --- a/spacy/lang/cs/stop_words.py +++ b/spacy/lang/cs/stop_words.py @@ -1,7 +1,8 @@ # Source: https://github.com/Alir3z4/stop-words # Source: https://github.com/stopwords-iso/stopwords-cs/blob/master/stopwords-cs.txt -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a aby ahoj @@ -360,4 +361,5 @@ zatímco ze že -""".split()) +""".split() +) diff --git a/spacy/lang/da/stop_words.py b/spacy/lang/da/stop_words.py index 0e71dfde739..05b2084dde3 100644 --- a/spacy/lang/da/stop_words.py +++ b/spacy/lang/da/stop_words.py @@ -1,6 +1,7 @@ # Source: Handpicked by Jens Dahl Møllerhøj. -STOP_WORDS = set(""" +STOP_WORDS = set( + """ af aldrig alene alle allerede alligevel alt altid anden andet andre at bag begge blandt blev blive bliver burde bør @@ -40,4 +41,5 @@ var ved vi via vil ville vore vores vær være været øvrigt -""".split()) +""".split() +) diff --git a/spacy/lang/de/stop_words.py b/spacy/lang/de/stop_words.py index 5fbd7428757..f52687eb9b3 100644 --- a/spacy/lang/de/stop_words.py +++ b/spacy/lang/de/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ á a ab aber ach acht achte achten achter achtes ag alle allein allem allen aller allerdings alles allgemeinen als also am an andere anderen anderem andern anders auch auf aus ausser außer ausserdem außerdem @@ -73,4 +74,5 @@ zehn zehnte zehnten zehnter zehntes zeit zu zuerst zugleich zum zunächst zur zurück zusammen zwanzig zwar zwei zweite zweiten zweiter zweites zwischen -""".split()) +""".split() +) diff --git a/spacy/lang/dsb/stop_words.py b/spacy/lang/dsb/stop_words.py index 90735a6236a..376e04aa6e5 100644 --- a/spacy/lang/dsb/stop_words.py +++ b/spacy/lang/dsb/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a abo aby ako ale až daniž dokulaž @@ -10,4 +11,5 @@ pak pótom teke togodla -""".split()) +""".split() +) diff --git a/spacy/lang/el/stop_words.py b/spacy/lang/el/stop_words.py index b5c1c36c41f..7c436219fa9 100644 --- a/spacy/lang/el/stop_words.py +++ b/spacy/lang/el/stop_words.py @@ -1,6 +1,7 @@ # Stop words # Link to greek stop words: https://www.translatum.gr/forum/index.php?topic=3550.0?topic=3550.0 -STOP_WORDS = set(""" +STOP_WORDS = set( + """ αδιάκοπα αι ακόμα ακόμη ακριβώς άλλα αλλά αλλαχού άλλες άλλη άλλην άλλης αλλιώς αλλιώτικα άλλο άλλοι αλλοιώς αλλοιώτικα άλλον άλλος άλλοτε αλλού άλλους άλλων άμα άμεσα αμέσως αν ανά ανάμεσα αναμεταξύ άνευ αντί αντίπερα αντίς @@ -82,4 +83,5 @@ χωρίς χωριστά ω ως ωσάν ωσότου ώσπου ώστε ωστόσο ωχ -""".split()) +""".split() +) diff --git a/spacy/lang/en/stop_words.py b/spacy/lang/en/stop_words.py index cbce281b491..1ca5cbc1670 100644 --- a/spacy/lang/en/stop_words.py +++ b/spacy/lang/en/stop_words.py @@ -1,5 +1,6 @@ # Stop words -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a about above across after afterwards again against all almost alone along already also although always am among amongst amount an and another any anyhow anyone anything anyway anywhere are around as at @@ -61,7 +62,8 @@ whither who whoever whole whom whose why will with within without would yet you your yours yourself yourselves -""".split()) +""".split() +) contractions = ["n't", "'d", "'ll", "'m", "'re", "'s", "'ve"] STOP_WORDS.update(contractions) diff --git a/spacy/lang/es/stop_words.py b/spacy/lang/es/stop_words.py index 5099359e843..6d28854810a 100644 --- a/spacy/lang/es/stop_words.py +++ b/spacy/lang/es/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a acuerdo adelante ademas además afirmó agregó ahi ahora ahí al algo alguna algunas alguno algunos algún alli allí alrededor ambos ante anterior antes apenas aproximadamente aquel aquella aquellas aquello aquellos aqui aquél @@ -75,4 +76,5 @@ vosotras vosotros voy vuestra vuestras vuestro vuestros y ya yo -""".split()) +""".split() +) diff --git a/spacy/lang/et/stop_words.py b/spacy/lang/et/stop_words.py index 248bcb61f08..e1da1f14d5e 100644 --- a/spacy/lang/et/stop_words.py +++ b/spacy/lang/et/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/stopwords-iso/stopwords-et -STOP_WORDS = set(""" +STOP_WORDS = set( + """ aga ei et @@ -36,4 +37,5 @@ ta te ära -""".split()) +""".split() +) diff --git a/spacy/lang/eu/stop_words.py b/spacy/lang/eu/stop_words.py index 4a6661e7d20..d213b5b81a5 100644 --- a/spacy/lang/eu/stop_words.py +++ b/spacy/lang/eu/stop_words.py @@ -1,7 +1,8 @@ # Source: https://github.com/stopwords-iso/stopwords-eu # https://www.ranks.nl/stopwords/basque # https://www.mustgo.com/worldlanguages/basque/ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ al anitz arabera @@ -100,4 +101,5 @@ zuek zuen zuten -""".split()) +""".split() +) diff --git a/spacy/lang/fa/lex_attrs.py b/spacy/lang/fa/lex_attrs.py index 9b0ff546e0d..065e81bd6af 100644 --- a/spacy/lang/fa/lex_attrs.py +++ b/spacy/lang/fa/lex_attrs.py @@ -5,7 +5,8 @@ YE_NUN = "ین" -_num_words = set(""" +_num_words = set( + """ صفر یک دو @@ -62,12 +63,15 @@ کوادریلیون کادریلیارد کوینتیلیون -""".split()) +""".split() +) -_ordinal_words = set(""" +_ordinal_words = set( + """ اول سوم -سی‌ام""".split()) +سی‌ام""".split() +) _ordinal_words.update({num + MIM for num in _num_words}) _ordinal_words.update({num + ZWNJ_O_MIM for num in _num_words}) diff --git a/spacy/lang/fa/stop_words.py b/spacy/lang/fa/stop_words.py index 93738c89263..f462f2e7a5d 100644 --- a/spacy/lang/fa/stop_words.py +++ b/spacy/lang/fa/stop_words.py @@ -1,5 +1,6 @@ # Stop words from HAZM package -STOP_WORDS = set(""" +STOP_WORDS = set( + """ و در به @@ -388,4 +389,5 @@ لذا زاده گردد -اینجا""".split()) +اینجا""".split() +) diff --git a/spacy/lang/fi/stop_words.py b/spacy/lang/fi/stop_words.py index 742cacc2689..8e8dcfa565d 100644 --- a/spacy/lang/fi/stop_words.py +++ b/spacy/lang/fi/stop_words.py @@ -1,6 +1,7 @@ # Source https://github.com/stopwords-iso/stopwords-fi/blob/master/stopwords-fi.txt # Reformatted with some minor corrections -STOP_WORDS = set(""" +STOP_WORDS = set( + """ aiemmin aika aikaa aikaan aikaisemmin aikaisin aikana aikoina aikoo aikovat aina ainakaan ainakin ainoa ainoat aiomme aion aiotte aivan ajan alas alemmas alkuisin alkuun alla alle aloitamme aloitan aloitat aloitatte aloitattivat @@ -105,4 +106,5 @@ ympäri älköön älä -""".split()) +""".split() +) diff --git a/spacy/lang/fr/lex_attrs.py b/spacy/lang/fr/lex_attrs.py index 8a9dfb82a8b..9cf508a07b9 100644 --- a/spacy/lang/fr/lex_attrs.py +++ b/spacy/lang/fr/lex_attrs.py @@ -1,20 +1,24 @@ from ...attrs import LIKE_NUM -_num_words = set(""" +_num_words = set( + """ zero un une deux trois quatre cinq six sept huit neuf dix onze douze treize quatorze quinze seize dix-sept dix-huit dix-neuf vingt trente quarante cinquante soixante soixante-dix septante quatre-vingt huitante quatre-vingt-dix nonante cent mille mil million milliard billion quadrillion quintillion sextillion septillion octillion nonillion decillion -""".split()) +""".split() +) -_ordinal_words = set(""" +_ordinal_words = set( + """ premier première deuxième second seconde troisième quatrième cinquième sixième septième huitième neuvième dixième onzième douzième treizième quatorzième quinzième seizième dix-septième dix-huitième dix-neuvième vingtième trentième quarantième cinquantième soixantième soixante-dixième septantième quatre-vingtième huitantième quatre-vingt-dixième nonantième centième millième millionnième milliardième billionnième quadrillionnième quintillionnième sextillionnième septillionnième octillionnième nonillionnième decillionnième -""".split()) +""".split() +) def like_num(text): diff --git a/spacy/lang/fr/stop_words.py b/spacy/lang/fr/stop_words.py index 85ffe47baef..b32ee3d7173 100644 --- a/spacy/lang/fr/stop_words.py +++ b/spacy/lang/fr/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a à â abord afin ah ai aie ainsi ait allaient allons alors anterieur anterieure anterieures antérieur antérieure antérieures apres après as assez attendu au @@ -79,4 +80,5 @@ y -""".split()) +""".split() +) diff --git a/spacy/lang/ga/stop_words.py b/spacy/lang/ga/stop_words.py index e32ad6431f6..4ef052ca58a 100644 --- a/spacy/lang/ga/stop_words.py +++ b/spacy/lang/ga/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a ach ag agus an aon ar arna as ba beirt bhúr @@ -38,4 +39,5 @@ í ó ón óna ónár -""".split()) +""".split() +) diff --git a/spacy/lang/gd/stop_words.py b/spacy/lang/gd/stop_words.py index 6f2c2856bec..9f5a66cbc24 100644 --- a/spacy/lang/gd/stop_words.py +++ b/spacy/lang/gd/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ 'ad 'ar 'd # iad @@ -381,4 +382,7 @@ ì ò ó -""".split("\n")) +""".split( + "\n" + ) +) diff --git a/spacy/lang/gd/tokenizer_exceptions.py b/spacy/lang/gd/tokenizer_exceptions.py index b65584154cc..76e169d904d 100644 --- a/spacy/lang/gd/tokenizer_exceptions.py +++ b/spacy/lang/gd/tokenizer_exceptions.py @@ -1974,7 +1974,9 @@ tuilleadh 's a chòir Tuilleadh 's a chòir tuilleadh sa chòir -Tuilleadh sa chòir""".split("\n"): +Tuilleadh sa chòir""".split( + "\n" +): _exc[orth] = [{ORTH: orth}] diff --git a/spacy/lang/grc/stop_words.py b/spacy/lang/grc/stop_words.py index 51f5e9d9dac..cbb766a8ce1 100644 --- a/spacy/lang/grc/stop_words.py +++ b/spacy/lang/grc/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ αὐτῷ αὐτοῦ αὐτῆς αὐτόν αὐτὸν αὐτῶν αὐτὸς αὐτὸ αὐτό αὐτός αὐτὴν αὐτοῖς αὐτοὺς αὔτ' αὐτὰ αὐτῇ αὐτὴ αὐτὼ αὑταὶ καὐτὸς αὐτά αὑτός αὐτοῖσι αὐτοῖσιν αὑτὸς αὐτήν αὐτοῖσί αὐτοί αὐτοὶ αὐτοῖο αὐτάων αὐτὰς αὐτέων αὐτώ αὐτάς αὐτούς αὐτή αὐταί αὐταὶ αὐτῇσιν τὠυτῷ τὠυτὸ ταὐτὰ ταύτῃ αὐτῇσι αὐτῇς αὐταῖς αὐτᾶς αὐτὰν ταὐτὸν @@ -56,4 +57,5 @@ ὣς ὡς ὥς ὧς ὥστ' ὥστε ὥσθ' ὤ ὢ - """.split()) + """.split() +) diff --git a/spacy/lang/gu/stop_words.py b/spacy/lang/gu/stop_words.py index 1d11a3ebd96..2c859681b05 100644 --- a/spacy/lang/gu/stop_words.py +++ b/spacy/lang/gu/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ એમ આ એ @@ -83,4 +84,5 @@ દર એટલો પરંતુ -""".split()) +""".split() +) diff --git a/spacy/lang/he/stop_words.py b/spacy/lang/he/stop_words.py index ea486722475..23bb5176de9 100644 --- a/spacy/lang/he/stop_words.py +++ b/spacy/lang/he/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ אני את אתה @@ -217,4 +218,5 @@ אחרות אשר או -""".split()) +""".split() +) diff --git a/spacy/lang/hi/stop_words.py b/spacy/lang/hi/stop_words.py index 9bc57bd3136..475b07da152 100644 --- a/spacy/lang/hi/stop_words.py +++ b/spacy/lang/hi/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/taranjeet/hindi-tokenizer/blob/master/stopwords.txt, https://data.mendeley.com/datasets/bsr3frvvjc/1#file-a21d5092-99d7-45d8-b044-3ae9edd391c6 -STOP_WORDS = set(""" +STOP_WORDS = set( + """ अंदर अत अदि @@ -234,4 +235,5 @@ होते होना होने -""".split()) +""".split() +) diff --git a/spacy/lang/hr/stop_words.py b/spacy/lang/hr/stop_words.py index 769ebe4db53..dd10f792d01 100644 --- a/spacy/lang/hr/stop_words.py +++ b/spacy/lang/hr/stop_words.py @@ -1,5 +1,6 @@ # Source: https://github.com/stopwords-iso/stopwords-hr -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a ah aha @@ -339,4 +340,5 @@ željeo zimus zum -""".split()) +""".split() +) diff --git a/spacy/lang/hsb/stop_words.py b/spacy/lang/hsb/stop_words.py index 86021f555c1..e6fedaf4c92 100644 --- a/spacy/lang/hsb/stop_words.py +++ b/spacy/lang/hsb/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a abo ale ani dokelž @@ -14,4 +15,5 @@ tež tohodla zo zoby -""".split()) +""".split() +) diff --git a/spacy/lang/ht/lex_attrs.py b/spacy/lang/ht/lex_attrs.py index 27a535dd746..ab1a39a8234 100644 --- a/spacy/lang/ht/lex_attrs.py +++ b/spacy/lang/ht/lex_attrs.py @@ -1,20 +1,24 @@ from ...attrs import LIKE_NUM, NORM # Cardinal numbers in Creole -_num_words = set(""" +_num_words = set( + """ zewo youn en de twa kat senk sis sèt uit nèf dis onz douz trèz katoz kenz sèz disèt dizwit diznèf vent trant karant sinkant swasant swasann-dis san mil milyon milya -""".split()) +""".split() +) # Ordinal numbers in Creole (some are French-influenced, some simplified) -_ordinal_words = set(""" +_ordinal_words = set( + """ premye dezyèm twazyèm katryèm senkyèm sizyèm sètvyèm uitvyèm nèvyèm dizyèm onzèm douzyèm trèzyèm katozyèm kenzèm sèzyèm disetyèm dizwityèm diznèvyèm ventyèm trantyèm karantyèm sinkantyèm swasantyèm swasann-disyèm santyèm milyèm milyonnyèm milyadyèm -""".split()) +""".split() +) NORM_MAP = { "'m": "mwen", diff --git a/spacy/lang/ht/stop_words.py b/spacy/lang/ht/stop_words.py index fd85c2a197f..50998e0e5ff 100644 --- a/spacy/lang/ht/stop_words.py +++ b/spacy/lang/ht/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a ak an ankò ant apre ap atò avan avanlè byen bò byenke @@ -38,7 +39,8 @@ men mèsi oswa osinon -""".split()) +""".split() +) # Add common contractions, with and without apostrophe variants contractions = ["m'", "n'", "w'", "y'", "l'", "t'", "k'"] diff --git a/spacy/lang/hu/stop_words.py b/spacy/lang/hu/stop_words.py index 1841557073a..e39a26d35ae 100644 --- a/spacy/lang/hu/stop_words.py +++ b/spacy/lang/hu/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a abban ahhoz ahogy ahol aki akik akkor akár alatt amely amelyek amelyekben amelyeket amelyet amelynek ami amikor amit amolyan amíg annak arra arról az azok azon azonban azt aztán azután azzal azért @@ -57,4 +58,5 @@ úgy új újabb újra ő őket -""".split()) +""".split() +) diff --git a/spacy/lang/hy/stop_words.py b/spacy/lang/hy/stop_words.py index 1bfd09a4b29..46d0f6b511c 100644 --- a/spacy/lang/hy/stop_words.py +++ b/spacy/lang/hy/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ նա ողջը այստեղ @@ -102,4 +103,5 @@ այս մեջ թ -""".split()) +""".split() +) diff --git a/spacy/lang/id/_tokenizer_exceptions_list.py b/spacy/lang/id/_tokenizer_exceptions_list.py index 11220a61e5b..a0b35fa1a2b 100644 --- a/spacy/lang/id/_tokenizer_exceptions_list.py +++ b/spacy/lang/id/_tokenizer_exceptions_list.py @@ -1,4 +1,5 @@ -ID_BASE_EXCEPTIONS = set(""" +ID_BASE_EXCEPTIONS = set( + """ aba-aba abah-abah abal-abal @@ -3897,4 +3898,5 @@ yo-yo zam-zam zig-zag -""".split()) +""".split() +) diff --git a/spacy/lang/id/stop_words.py b/spacy/lang/id/stop_words.py index fc85f83679a..b1bfaea796e 100644 --- a/spacy/lang/id/stop_words.py +++ b/spacy/lang/id/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ada adalah adanya adapun agak agaknya agar akan akankah akhir akhiri akhirnya aku akulah amat amatlah anda andalah antar antara antaranya apa apaan apabila apakah apalagi apatah artinya asal asalkan atas atau ataukah ataupun awal @@ -113,4 +114,5 @@ waduh wah wahai waktu waktunya walau walaupun wong yaitu yakin yakni yang -""".split()) +""".split() +) diff --git a/spacy/lang/is/stop_words.py b/spacy/lang/is/stop_words.py index 79f84ee6000..917fb6df444 100644 --- a/spacy/lang/is/stop_words.py +++ b/spacy/lang/is/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/Xangis/extra-stopwords -STOP_WORDS = set(""" +STOP_WORDS = set( + """ afhverju aftan aftur @@ -153,4 +154,5 @@ því þær ætti -""".split()) +""".split() +) diff --git a/spacy/lang/it/stop_words.py b/spacy/lang/it/stop_words.py index 2a37236a9b9..42adc7904c8 100644 --- a/spacy/lang/it/stop_words.py +++ b/spacy/lang/it/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a abbastanza abbia abbiamo abbiano abbiate accidenti ad adesso affinche agl agli ahime ahimè ai al alcuna alcuni alcuno all alla alle allo allora altri altrimenti altro altrove altrui anche ancora anni anno ansa anticipo assai @@ -78,4 +79,5 @@ v' va vale vari varia varie vario verso vi via vicino visto vita voi volta volte vostra vostre vostri vostro -""".split()) +""".split() +) diff --git a/spacy/lang/ja/stop_words.py b/spacy/lang/ja/stop_words.py index 661b5183594..98560d7e28b 100644 --- a/spacy/lang/ja/stop_words.py +++ b/spacy/lang/ja/stop_words.py @@ -2,7 +2,8 @@ # filtering out everything that wasn't hiragana. ー (one) was also added. # Considered keeping some non-hiragana words but too many place names were # present. -STOP_WORDS = set(""" +STOP_WORDS = set( + """ あ あっ あまり あり ある あるいは あれ い いい いう いく いずれ いっ いつ いる いわ うち @@ -43,4 +44,5 @@ を ん 一 -""".split()) +""".split() +) diff --git a/spacy/lang/kmr/stop_words.py b/spacy/lang/kmr/stop_words.py index 93e6ea27f0c..aee33c2b748 100644 --- a/spacy/lang/kmr/stop_words.py +++ b/spacy/lang/kmr/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ û li bi @@ -39,4 +40,5 @@ hemû kes tişt -""".split()) +""".split() +) diff --git a/spacy/lang/kn/stop_words.py b/spacy/lang/kn/stop_words.py index 528e5e3a8a8..dba9740af91 100644 --- a/spacy/lang/kn/stop_words.py +++ b/spacy/lang/kn/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ಹಲವು ಮೂಲಕ ಹಾಗೂ @@ -81,4 +82,5 @@ ಎಂದು ನನ್ನ ಮೇಲೆ -""".split()) +""".split() +) diff --git a/spacy/lang/ko/stop_words.py b/spacy/lang/ko/stop_words.py index d4cdbc7a112..3eba9fc8299 100644 --- a/spacy/lang/ko/stop_words.py +++ b/spacy/lang/ko/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ 이 있 하 @@ -62,4 +63,5 @@ 원 잘 놓 -""".split()) +""".split() +) diff --git a/spacy/lang/ky/stop_words.py b/spacy/lang/ky/stop_words.py index fb8e2c84b95..ea40bdfa222 100644 --- a/spacy/lang/ky/stop_words.py +++ b/spacy/lang/ky/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ага адам айтты айтымында айтып ал алар алардын алган алуу алып анда андан аны анын ар @@ -37,4 +38,5 @@ үч үчүн өз -""".split()) +""".split() +) diff --git a/spacy/lang/la/stop_words.py b/spacy/lang/la/stop_words.py index 47abf7384f4..8b590bb67b3 100644 --- a/spacy/lang/la/stop_words.py +++ b/spacy/lang/la/stop_words.py @@ -1,6 +1,7 @@ # Corrected Perseus list, cf. https://wiki.digitalclassicist.org/Stopwords_for_Greek_and_Latin -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ab ac ad adhuc aliqui aliquis an ante apud at atque aut autem cum cur @@ -32,4 +33,5 @@ ubi uel uero vel vero -""".split()) +""".split() +) diff --git a/spacy/lang/lb/lex_attrs.py b/spacy/lang/lb/lex_attrs.py index bbef72b9bb3..11923137418 100644 --- a/spacy/lang/lb/lex_attrs.py +++ b/spacy/lang/lb/lex_attrs.py @@ -1,18 +1,22 @@ from ...attrs import LIKE_NUM -_num_words = set(""" +_num_words = set( + """ null eent zwee dräi véier fënnef sechs ziwen aacht néng zéng eelef zwielef dräizéng véierzéng foffzéng siechzéng siwwenzéng uechtzeng uechzeng nonnzéng nongzéng zwanzeg drësseg véierzeg foffzeg sechzeg siechzeg siwenzeg achtzeg achzeg uechtzeg uechzeg nonnzeg honnert dausend millioun milliard billioun billiard trillioun triliard -""".split()) +""".split() +) -_ordinal_words = set(""" +_ordinal_words = set( + """ éischten zweeten drëtten véierten fënneften sechsten siwenten aachten néngten zéngten eeleften zwieleften dräizéngten véierzéngten foffzéngten siechzéngten uechtzéngen uechzéngten nonnzéngten nongzéngten zwanzegsten drëssegsten véierzegsten foffzegsten siechzegsten siwenzegsten uechzegsten nonnzegsten honnertsten dausendsten milliounsten milliardsten billiounsten billiardsten trilliounsten trilliardsten -""".split()) +""".split() +) def like_num(text): diff --git a/spacy/lang/lb/stop_words.py b/spacy/lang/lb/stop_words.py index 386ce1222af..8f22ea6e694 100644 --- a/spacy/lang/lb/stop_words.py +++ b/spacy/lang/lb/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a à äis @@ -206,4 +207,5 @@ zu zum zwar -""".split()) +""".split() +) diff --git a/spacy/lang/lg/stop_words.py b/spacy/lang/lg/stop_words.py index a9f99cbf40f..7bad59344fb 100644 --- a/spacy/lang/lg/stop_words.py +++ b/spacy/lang/lg/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ abadde abalala abamu abangi abava ajja ali alina ani anti ateekeddwa atewamu atya awamu aweebwa ayinza ba baali babadde babalina bajja bajjanewankubade bali balina bandi bangi bano bateekeddwa baweebwa bayina bebombi beera bibye @@ -14,4 +15,5 @@ tetuteekeddwa tewali teyalina teyayina tolina tu tuyina tulina tuyina twafuna twetaaga wa wabula wabweru wadde waggulunnina wakati waliwobangi waliyo wandi wange wano wansi weebwa yabadde yaffe ye yenna yennyini yina yonna ziba zijja zonna -""".split()) +""".split() +) diff --git a/spacy/lang/lij/stop_words.py b/spacy/lang/lij/stop_words.py index 37eb163ffe7..1d6f09d27ca 100644 --- a/spacy/lang/lij/stop_words.py +++ b/spacy/lang/lij/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a à â a-a a-e a-i a-o aiva aloa an ancheu ancon apreuvo ascì atra atre atri atro avanti avei bella belle belli bello ben @@ -34,4 +35,5 @@ un uña unn' unna za zu -""".split()) +""".split() +) diff --git a/spacy/lang/lv/stop_words.py b/spacy/lang/lv/stop_words.py index 4ed61996ac1..2685c243083 100644 --- a/spacy/lang/lv/stop_words.py +++ b/spacy/lang/lv/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/stopwords-iso/stopwords-lv -STOP_WORDS = set(""" +STOP_WORDS = set( + """ aiz ap apakš @@ -162,4 +163,5 @@ zem ārpus šaipus -""".split()) +""".split() +) diff --git a/spacy/lang/mk/stop_words.py b/spacy/lang/mk/stop_words.py index 90a27179852..312a456c5db 100644 --- a/spacy/lang/mk/stop_words.py +++ b/spacy/lang/mk/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ а абре aв @@ -810,4 +811,5 @@ џагара-магара џанам џив-џив - """.split()) + """.split() +) diff --git a/spacy/lang/ml/stop_words.py b/spacy/lang/ml/stop_words.py index 64b9acc1025..441e9358699 100644 --- a/spacy/lang/ml/stop_words.py +++ b/spacy/lang/ml/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ അത് ഇത് ആയിരുന്നു @@ -8,4 +9,5 @@ അന്ന് ഇന്ന് ആണ് -""".split()) +""".split() +) diff --git a/spacy/lang/mr/stop_words.py b/spacy/lang/mr/stop_words.py index 3c9c6208916..9b0cee951ab 100644 --- a/spacy/lang/mr/stop_words.py +++ b/spacy/lang/mr/stop_words.py @@ -1,5 +1,6 @@ # Source: https://github.com/stopwords-iso/stopwords-mr/blob/master/stopwords-mr.txt, https://github.com/6/stopwords-json/edit/master/dist/mr.json -STOP_WORDS = set(""" +STOP_WORDS = set( + """ न अतरी तो @@ -187,4 +188,5 @@ होता होती होते -""".split()) +""".split() +) diff --git a/spacy/lang/ms/_tokenizer_exceptions_list.py b/spacy/lang/ms/_tokenizer_exceptions_list.py index e579e316ae9..fba1dd70f94 100644 --- a/spacy/lang/ms/_tokenizer_exceptions_list.py +++ b/spacy/lang/ms/_tokenizer_exceptions_list.py @@ -1,6 +1,7 @@ # from https://prpm.dbp.gov.my/cari1?keyword= # dbp https://en.wikipedia.org/wiki/Dewan_Bahasa_dan_Pustaka -MS_BASE_EXCEPTIONS = set(""" +MS_BASE_EXCEPTIONS = set( + """ aba-aba abah-abah abar-abar @@ -1938,4 +1939,5 @@ water-cooled world-class yang-yang -""".split()) +""".split() +) diff --git a/spacy/lang/ms/stop_words.py b/spacy/lang/ms/stop_words.py index fc85f83679a..b1bfaea796e 100644 --- a/spacy/lang/ms/stop_words.py +++ b/spacy/lang/ms/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ada adalah adanya adapun agak agaknya agar akan akankah akhir akhiri akhirnya aku akulah amat amatlah anda andalah antar antara antaranya apa apaan apabila apakah apalagi apatah artinya asal asalkan atas atau ataukah ataupun awal @@ -113,4 +114,5 @@ waduh wah wahai waktu waktunya walau walaupun wong yaitu yakin yakni yang -""".split()) +""".split() +) diff --git a/spacy/lang/nb/stop_words.py b/spacy/lang/nb/stop_words.py index bc1c54a4af3..d9ed414efdf 100644 --- a/spacy/lang/nb/stop_words.py +++ b/spacy/lang/nb/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ alle allerede alt and andre annen annet at av bak bare bedre beste blant ble bli blir blitt bris by både @@ -45,4 +46,5 @@ å år ønsker -""".split()) +""".split() +) diff --git a/spacy/lang/ne/stop_words.py b/spacy/lang/ne/stop_words.py index 95d7a375821..8470297b9f0 100644 --- a/spacy/lang/ne/stop_words.py +++ b/spacy/lang/ne/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/sanjaalcorps/NepaliStopWords/blob/master/NepaliStopWords.txt -STOP_WORDS = set(""" +STOP_WORDS = set( + """ अक्सर अगाडि अगाडी @@ -489,4 +490,5 @@ होइन होकि होला -""".split()) +""".split() +) diff --git a/spacy/lang/nl/lex_attrs.py b/spacy/lang/nl/lex_attrs.py index 1b8602831ae..488224c2f20 100644 --- a/spacy/lang/nl/lex_attrs.py +++ b/spacy/lang/nl/lex_attrs.py @@ -1,17 +1,21 @@ from ...attrs import LIKE_NUM -_num_words = set(""" +_num_words = set( + """ nul een één twee drie vier vijf zes zeven acht negen tien elf twaalf dertien veertien twintig dertig veertig vijftig zestig zeventig tachtig negentig honderd duizend miljoen miljard biljoen biljard triljoen triljard -""".split()) +""".split() +) -_ordinal_words = set(""" +_ordinal_words = set( + """ eerste tweede derde vierde vijfde zesde zevende achtste negende tiende elfde twaalfde dertiende veertiende twintigste dertigste veertigste vijftigste zestigste zeventigste tachtigste negentigste honderdste duizendste miljoenste miljardste biljoenste biljardste triljoenste triljardste -""".split()) +""".split() +) def like_num(text): diff --git a/spacy/lang/nl/stop_words.py b/spacy/lang/nl/stop_words.py index a88c2905199..cd4fdefdf58 100644 --- a/spacy/lang/nl/stop_words.py +++ b/spacy/lang/nl/stop_words.py @@ -13,7 +13,8 @@ # should have a Dutch counterpart here. -STOP_WORDS = set(""" +STOP_WORDS = set( + """ aan af al alle alles allebei alleen allen als altijd ander anders andere anderen aangaande aangezien achter achterna afgelopen aldus alhoewel anderzijds @@ -67,4 +68,5 @@ zal ze zei zelf zich zij zijn zo zonder zou zeer zeker zekere zelfde zelfs zichzelf zijnde zijne zo’n zoals zodra zouden zoveel zowat zulk zulke zulks zullen zult -""".split()) +""".split() +) diff --git a/spacy/lang/pl/stop_words.py b/spacy/lang/pl/stop_words.py index 4418deedc0b..075aec39167 100644 --- a/spacy/lang/pl/stop_words.py +++ b/spacy/lang/pl/stop_words.py @@ -1,6 +1,7 @@ # sources: https://github.com/bieli/stopwords/blob/master/polish.stopwords.txt and https://github.com/stopwords-iso/stopwords-pl -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a aby ach acz aczkolwiek aj albo ale alez ależ ani az aż @@ -73,4 +74,5 @@ z za zaden zadna zadne zadnych zapewne zawsze zaś ze zeby znow znowu znów zostal został -żaden żadna żadne żadnych że żeby""".split()) +żaden żadna żadne żadnych że żeby""".split() +) diff --git a/spacy/lang/pt/stop_words.py b/spacy/lang/pt/stop_words.py index 722aef80236..ce3c86ff570 100644 --- a/spacy/lang/pt/stop_words.py +++ b/spacy/lang/pt/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a à às área acerca ademais adeus agora ainda algo algumas alguns ali além ambas ambos antes ao aos apenas apoia apoio apontar após aquela aquelas aquele aqueles aqui aquilo as assim através atrás até aí @@ -61,4 +62,5 @@ vossas vosso vossos vários vão vêm vós zero -""".split()) +""".split() +) diff --git a/spacy/lang/ro/lex_attrs.py b/spacy/lang/ro/lex_attrs.py index a5880fc2fac..736aa911ac6 100644 --- a/spacy/lang/ro/lex_attrs.py +++ b/spacy/lang/ro/lex_attrs.py @@ -1,13 +1,16 @@ from ...attrs import LIKE_NUM -_num_words = set(""" +_num_words = set( + """ zero unu doi două trei patru cinci șase șapte opt nouă zece unsprezece doisprezece douăsprezece treisprezece patrusprezece cincisprezece șaisprezece șaptesprezece optsprezece nouăsprezece douăzeci treizeci patruzeci cincizeci șaizeci șaptezeci optzeci nouăzeci sută mie milion miliard bilion trilion cvadrilion catralion cvintilion sextilion septilion enșpemii -""".split()) +""".split() +) -_ordinal_words = set(""" +_ordinal_words = set( + """ primul doilea treilea patrulea cincilea șaselea șaptelea optulea nouălea zecelea prima doua treia patra cincia șasea șaptea opta noua zecea unsprezecelea doisprezecelea treisprezecelea patrusprezecelea cincisprezecelea șaisprezecelea șaptesprezecelea optsprezecelea nouăsprezecelea @@ -15,7 +18,8 @@ douăzecilea treizecilea patruzecilea cincizecilea șaizecilea șaptezecilea optzecilea nouăzecilea sutălea douăzecea treizecea patruzecea cincizecea șaizecea șaptezecea optzecea nouăzecea suta miilea mielea mia milionulea milioana miliardulea miliardelea miliarda enșpemia -""".split()) +""".split() +) def like_num(text): diff --git a/spacy/lang/ro/stop_words.py b/spacy/lang/ro/stop_words.py index c7c0801f171..d68a81c4569 100644 --- a/spacy/lang/ro/stop_words.py +++ b/spacy/lang/ro/stop_words.py @@ -1,5 +1,6 @@ # Source: https://github.com/stopwords-iso/stopwords-ro -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a abia acea @@ -494,4 +495,5 @@ știu ți ție -""".split()) +""".split() +) diff --git a/spacy/lang/ru/lex_attrs.py b/spacy/lang/ru/lex_attrs.py index 63b1cead810..e0b35bdc07f 100644 --- a/spacy/lang/ru/lex_attrs.py +++ b/spacy/lang/ru/lex_attrs.py @@ -1,6 +1,8 @@ from ...attrs import LIKE_NUM -_num_words = list(set(""" +_num_words = list( + set( + """ ноль ноля нолю нолём ноле нулевой нулевого нулевому нулевым нулевом нулевая нулевую нулевое нулевые нулевых нулевыми четверть четверти четвертью четвертей четвертям четвертями четвертях @@ -201,7 +203,9 @@ квинтиллиону квинтиллионов квинтлн i ii iii iv v vi vii viii ix x xi xii xiii xiv xv xvi xvii xviii xix xx xxi xxii xxiii xxiv xxv xxvi xxvii xxvii xxix -""".split())) +""".split() + ) +) def like_num(text): diff --git a/spacy/lang/ru/stop_words.py b/spacy/lang/ru/stop_words.py index 3040adb52b1..d6ea6b42af9 100644 --- a/spacy/lang/ru/stop_words.py +++ b/spacy/lang/ru/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ а авось ага агу аж ай али алло ау ах ая б будем будет будете будешь буду будут будучи будь будьте бы был была были было @@ -106,4 +107,5 @@ ю я явно явных яко якобы якоже -""".split()) +""".split() +) diff --git a/spacy/lang/sa/stop_words.py b/spacy/lang/sa/stop_words.py index eaf0ffaa2c9..30302a14dcb 100644 --- a/spacy/lang/sa/stop_words.py +++ b/spacy/lang/sa/stop_words.py @@ -1,6 +1,7 @@ # Source: https://gist.github.com/Akhilesh28/fe8b8e180f64b72e64751bc31cb6d323 -STOP_WORDS = set(""" +STOP_WORDS = set( + """ अहम् आवाम् वयम् @@ -510,4 +511,5 @@ ह हन्त हि -""".split()) +""".split() +) diff --git a/spacy/lang/si/stop_words.py b/spacy/lang/si/stop_words.py index acae5763b52..7d29bc1b4d8 100644 --- a/spacy/lang/si/stop_words.py +++ b/spacy/lang/si/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ සහ සමග සමඟ @@ -190,4 +191,5 @@ ලෙස පරිදි එහෙත් -""".split()) +""".split() +) diff --git a/spacy/lang/sk/stop_words.py b/spacy/lang/sk/stop_words.py index 6ef4818c3a2..017e7beef39 100644 --- a/spacy/lang/sk/stop_words.py +++ b/spacy/lang/sk/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/Ardevop-sk/stopwords-sk -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a aby aj @@ -419,4 +420,5 @@ ňou ňu že -""".split()) +""".split() +) diff --git a/spacy/lang/sl/lex_attrs.py b/spacy/lang/sl/lex_attrs.py index 6d6b40b4546..3c1493050a1 100644 --- a/spacy/lang/sl/lex_attrs.py +++ b/spacy/lang/sl/lex_attrs.py @@ -2,7 +2,8 @@ from ...attrs import IS_CURRENCY, LIKE_NUM -_num_words = set(""" +_num_words = set( + """ nula ničla nič ena dva tri štiri pet šest sedem osem devet deset enajst dvanajst trinajst štirinajst petnajst šestnajst sedemnajst osemnajst devetnajst dvajset trideset štirideset @@ -17,9 +18,11 @@ šestnajstih šestnajstim šestnajstimi petnajstih petnajstim petnajstimi sedemnajstih sedemnajstim sedemnajstimi osemnajstih osemnajstim osemnajstimi devetnajstih devetnajstim devetnajstimi dvajsetih dvajsetim dvajsetimi - """.split()) + """.split() +) -_ordinal_words = set(""" +_ordinal_words = set( + """ prvi drugi tretji četrti peti šesti sedmi osmi deveti deseti enajsti dvanajsti trinajsti štirinajsti petnajsti šestnajsti sedemnajsti osemnajsti devetnajsti @@ -89,9 +92,11 @@ osemnajstimi devetnajstimi dvajsetimi tridesetimi štiridesetimi petdesetimi šestdesetimi sedemdesetimi osemdesetimi devetdesetimi stotimi tisočimi milijontimi bilijontimi trilijontimi kvadrilijontimi neštetimi - """.split()) + """.split() +) -_currency_words = set(""" +_currency_words = set( + """ evro evra evru evrom evrov evroma evrih evrom evre evri evr eur cent centa centu cenom centov centoma centih centom cente centi dolar dolarja dolarji dolarju dolarjem dolarjev dolarjema dolarjih dolarje usd @@ -104,7 +109,8 @@ jen jena jeni jenu jenom jenov jenoma jenih jene kuna kuni kune kuno kun kunama kunah kunam kunami marka marki marke markama markah markami - """.split()) + """.split() +) def like_num(text): diff --git a/spacy/lang/sl/stop_words.py b/spacy/lang/sl/stop_words.py index a81c00db269..8491efcb580 100644 --- a/spacy/lang/sl/stop_words.py +++ b/spacy/lang/sl/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/stopwords-iso/stopwords-sl -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a ali b bi bil bila bile bili bilo biti blizu bo bodo bojo bolj bom bomo @@ -79,4 +80,5 @@ z za zadaj zadnji zakaj zaprta zaprti zaprto zdaj zelo zunaj ž že -""".split()) +""".split() +) diff --git a/spacy/lang/sq/stop_words.py b/spacy/lang/sq/stop_words.py index bf1c7a7039c..f2b1a4f4a7b 100644 --- a/spacy/lang/sq/stop_words.py +++ b/spacy/lang/sq/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/andrixh/index-albanian -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a afert ai @@ -224,4 +225,5 @@ vjen yne zakonisht -""".split()) +""".split() +) diff --git a/spacy/lang/sr/stop_words.py b/spacy/lang/sr/stop_words.py index 758964a5853..5df5509d2c4 100644 --- a/spacy/lang/sr/stop_words.py +++ b/spacy/lang/sr/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ а авај ако @@ -388,4 +389,5 @@ ћете ћеш ћу -""".split()) +""".split() +) diff --git a/spacy/lang/sv/stop_words.py b/spacy/lang/sv/stop_words.py index 08251bcff32..2422b2a9e5a 100644 --- a/spacy/lang/sv/stop_words.py +++ b/spacy/lang/sv/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ aderton adertonde adjö aldrig alla allas allt alltid alltså än andra andras annan annat ännu artonde arton åtminstone att åtta åttio åttionde åttonde av även @@ -61,4 +62,5 @@ vad vänster vänstra var vår vara våra varför varifrån varit varken värre varsågod vart vårt vem vems verkligen vi vid vidare viktig viktigare viktigast viktigt vilka vilken vilket vill -""".split()) +""".split() +) diff --git a/spacy/lang/ta/stop_words.py b/spacy/lang/ta/stop_words.py index d6ef21f3b0a..abbff949d79 100644 --- a/spacy/lang/ta/stop_words.py +++ b/spacy/lang/ta/stop_words.py @@ -1,6 +1,7 @@ # Stop words -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ஒரு என்று மற்றும் @@ -126,4 +127,5 @@ வரையில் சற்று எனக் -""".split()) +""".split() +) diff --git a/spacy/lang/te/stop_words.py b/spacy/lang/te/stop_words.py index d2834260898..b18dab697da 100644 --- a/spacy/lang/te/stop_words.py +++ b/spacy/lang/te/stop_words.py @@ -1,6 +1,7 @@ # Source: https://github.com/Xangis/extra-stopwords (MIT License) -STOP_WORDS = set(""" +STOP_WORDS = set( + """ అందరూ అందుబాటులో అడగండి @@ -51,4 +52,5 @@ వేరుగా వ్యతిరేకంగా సంబంధం -""".split()) +""".split() +) diff --git a/spacy/lang/th/stop_words.py b/spacy/lang/th/stop_words.py index 3dd6e56525b..2823281ce95 100644 --- a/spacy/lang/th/stop_words.py +++ b/spacy/lang/th/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ทั้งนี้ ดัง ขอ รวม หลังจาก เป็น หลัง หรือ ๆ เกี่ยวกับ ซึ่งได้แก่ ด้วยเพราะ ด้วยว่า ด้วยเหตุเพราะ ด้วยเหตุว่า สุดๆ เสร็จแล้ว เช่น เข้า ถ้า ถูก ถึง ต่างๆ ใคร เปิดเผย ครา รือ ตาม ใน ได้แก่ ได้แต่ ได้ที่ ตลอดถึง นอกจากว่า นอกนั้น จริง อย่างดี ส่วน เพียงเพื่อ เดียว จัด ทั้งที ทั้งคน ทั้งตัว ไกลๆ @@ -70,4 +71,5 @@ แห่งนี้ แห่งโน้น แห่งไหน แหละ ให้แก่ ใหญ่ ใหญ่โต อย่างมาก อย่างยิ่ง อย่างไรก็ อย่างไรก็ได้ อย่างไรเสีย อย่างละ อย่างหนึ่ง อย่างๆ อัน อันจะ อันได้แก่ อันที่ อันที่จริง อันที่จะ อันเนื่องมาจาก อันละ อันๆ อาจจะ อาจเป็น อาจเป็นด้วย อื่น อื่นๆ เอ็ง เอา ฯ ฯล ฯลฯ 555 กำ ขอโทษ เยี่ยม นี่คือ -""".split()) +""".split() +) diff --git a/spacy/lang/ti/stop_words.py b/spacy/lang/ti/stop_words.py index e0aaf47d3fe..9bd7122007a 100644 --- a/spacy/lang/ti/stop_words.py +++ b/spacy/lang/ti/stop_words.py @@ -1,7 +1,8 @@ # Stop words from Tigrinya Wordcount: https://github.com/fgaim/Tigrinya-WordCount/blob/main/ti_stop_words.txt # Stop words -STOP_WORDS = set(""" +STOP_WORDS = set( + """ 'ምበር 'ሞ 'ቲ 'ታ 'ኳ 'ውን 'ዚ 'የ 'ዩ 'ያ 'ዮም 'ዮን ልዕሊ ሒዙ ሒዛ ሕጂ መበል መን መንጎ መጠን ማለት ምስ ምባል ምእንቲ ምኽንያቱ ምኽንያት ምዃኑ ምዃንና ምዃኖም @@ -22,4 +23,5 @@ ዝነበረ ዝነበረት ዝነበሩ ዝካየድ ዝኸውን ዝኽእል ዝኾነ ዝዀነ የለን ይቕረብ ይብል ይኸውን ይኹን ይኽእል ደኣ ድሕሪ ድማ ገለ ገሊጹ ገና ገይሩ ግና ግን ጥራይ -""".split()) +""".split() +) diff --git a/spacy/lang/tl/stop_words.py b/spacy/lang/tl/stop_words.py index a7bf541990a..2560cdaed6a 100644 --- a/spacy/lang/tl/stop_words.py +++ b/spacy/lang/tl/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set(""" +STOP_WORDS = set( + """ akin aking ako @@ -146,4 +147,5 @@ tungkol una walang -""".split()) +""".split() +) diff --git a/spacy/lang/tn/stop_words.py b/spacy/lang/tn/stop_words.py index a63a455f754..f614771dd11 100644 --- a/spacy/lang/tn/stop_words.py +++ b/spacy/lang/tn/stop_words.py @@ -1,5 +1,6 @@ # Stop words -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ke gareng ga selekanyo tlhwatlhwa yo mongwe se sengwe fa go le jalo gongwe ba na mo tikologong jaaka kwa morago nna gonne ka sa pele nako teng @@ -15,4 +16,5 @@ bonala e tshwanang bogolo tsenya tsweetswee karolo sepe tlhalosa dirwa robedi robongwe lesomenngwe gaisa tlhano lesometlhano botlalo lekgolo -""".split()) +""".split() +) diff --git a/spacy/lang/tokenizer_exceptions.py b/spacy/lang/tokenizer_exceptions.py index e80423e5150..dbf9aab4912 100644 --- a/spacy/lang/tokenizer_exceptions.py +++ b/spacy/lang/tokenizer_exceptions.py @@ -111,7 +111,8 @@ BASE_EXCEPTIONS[orth] = [{ORTH: orth}] -emoticons = set(r""" +emoticons = set( + r""" :) :-) :)) @@ -242,7 +243,8 @@ ¯\(ツ)/¯ (╯°□°)╯︵┻━┻ ><(((*> -""".split()) +""".split() +) for orth in emoticons: diff --git a/spacy/lang/tr/stop_words.py b/spacy/lang/tr/stop_words.py index 5323cf32d9c..85dcff6a53a 100644 --- a/spacy/lang/tr/stop_words.py +++ b/spacy/lang/tr/stop_words.py @@ -1,5 +1,6 @@ # Source: https://github.com/stopwords-iso/stopwords-tr -STOP_WORDS = set(""" +STOP_WORDS = set( + """ acaba acep adamakıllı @@ -552,4 +553,5 @@ zaten zati zira -""".split()) +""".split() +) diff --git a/spacy/lang/tt/stop_words.py b/spacy/lang/tt/stop_words.py index 8f146d9150a..44169b757e5 100644 --- a/spacy/lang/tt/stop_words.py +++ b/spacy/lang/tt/stop_words.py @@ -1,6 +1,7 @@ # Tatar stopwords are from https://github.com/aliiae/stopwords-tt -STOP_WORDS = set("""алай алайса алар аларга аларда алардан аларны аларның аларча +STOP_WORDS = set( + """алай алайса алар аларга аларда алардан аларны аларның аларча алары аларын аларынга аларында аларыннан аларының алтмыш алтмышынчы алтмышынчыга алтмышынчыда алтмышынчыдан алтмышынчылар алтмышынчыларга алтмышынчыларда алтмышынчылардан алтмышынчыларны алтмышынчыларның алтмышынчыны алтмышынчының @@ -168,4 +169,5 @@ өстәп өч өчен өченче өченчегә өченчедә өченчедән өченчеләр өченчеләргә өченчеләрдә өченчеләрдән өченчеләрне өченчеләрнең өченчене өченченең өчләп -өчәрләп""".split()) +өчәрләп""".split() +) diff --git a/spacy/lang/uk/stop_words.py b/spacy/lang/uk/stop_words.py index 517c300070a..b11d7a044a3 100644 --- a/spacy/lang/uk/stop_words.py +++ b/spacy/lang/uk/stop_words.py @@ -1,4 +1,5 @@ -STOP_WORDS = set("""а +STOP_WORDS = set( + """а або адже аж @@ -464,4 +465,5 @@ якій якого якої -якщо""".split()) +якщо""".split() +) diff --git a/spacy/lang/ur/lex_attrs.py b/spacy/lang/ur/lex_attrs.py index 916a47bfd19..e590ed3e303 100644 --- a/spacy/lang/ur/lex_attrs.py +++ b/spacy/lang/ur/lex_attrs.py @@ -5,8 +5,7 @@ # https://en.wikibooks.org/wiki/Urdu/Vocabulary/Numbers # https://www.urdu-english.com/lessons/beginner/numbers -_num_words = ( - """ایک دو تین چار پانچ چھ سات آٹھ نو دس گیارہ بارہ تیرہ چودہ پندرہ سولہ سترہ +_num_words = """ایک دو تین چار پانچ چھ سات آٹھ نو دس گیارہ بارہ تیرہ چودہ پندرہ سولہ سترہ اٹهارا انیس بیس اکیس بائیس تئیس چوبیس پچیس چھببیس ستایس اٹھائس انتيس تیس اکتیس بتیس تینتیس چونتیس پینتیس چھتیس سینتیس ارتیس انتالیس چالیس اکتالیس بیالیس تیتالیس @@ -18,7 +17,6 @@ سٹیاسی اٹھیاسی نواسی نوے اکانوے بانوے ترانوے چورانوے پچانوے چھیانوے ستانوے اٹھانوے ننانوے سو """.split() -) # source https://www.google.com/intl/ur/inputtools/try/ diff --git a/spacy/lang/ur/stop_words.py b/spacy/lang/ur/stop_words.py index 00f0dd2d6b4..abfa3649713 100644 --- a/spacy/lang/ur/stop_words.py +++ b/spacy/lang/ur/stop_words.py @@ -1,5 +1,6 @@ # Source: collected from different resource on internet -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ثھی خو گی @@ -508,4 +509,5 @@ ہورہی ثبعث ضت -""".split()) +""".split() +) diff --git a/spacy/lang/vi/stop_words.py b/spacy/lang/vi/stop_words.py index 9163e10938e..1d2ecdf8d4b 100644 --- a/spacy/lang/vi/stop_words.py +++ b/spacy/lang/vi/stop_words.py @@ -1,5 +1,6 @@ # Source: https://github.com/stopwords/vietnamese-stopwords -STOP_WORDS = set(""" +STOP_WORDS = set( + """ a_lô a_ha ai @@ -1942,4 +1943,7 @@ ừ_ào ừ_ừ ử -""".split("\n")) +""".split( + "\n" + ) +) diff --git a/spacy/lang/zh/stop_words.py b/spacy/lang/zh/stop_words.py index d54fe689504..42ae4a1de04 100644 --- a/spacy/lang/zh/stop_words.py +++ b/spacy/lang/zh/stop_words.py @@ -1,6 +1,7 @@ # stop words as whitespace-separated list # Chinese stop words,maybe not enough -STOP_WORDS = set(""" +STOP_WORDS = set( + """ ! " # @@ -1894,4 +1895,5 @@ ~± ~+ ¥ -""".split()) +""".split() +) diff --git a/spacy/pipeline/_edit_tree_internals/schemas.py b/spacy/pipeline/_edit_tree_internals/schemas.py index d20945dc5f1..ef7a076b6cd 100644 --- a/spacy/pipeline/_edit_tree_internals/schemas.py +++ b/spacy/pipeline/_edit_tree_internals/schemas.py @@ -1,7 +1,16 @@ from collections import defaultdict from typing import Any, Dict, List, Union -from pydantic import BaseModel, ConfigDict, Field, RootModel, StrictBool, StrictInt, StrictStr, ValidationError +from pydantic import ( + BaseModel, + ConfigDict, + Field, + RootModel, + StrictBool, + StrictInt, + StrictStr, + ValidationError, +) class MatchNodeSchema(BaseModel): diff --git a/spacy/pipeline/attributeruler.py b/spacy/pipeline/attributeruler.py index fd037480cb2..ded48969e20 100644 --- a/spacy/pipeline/attributeruler.py +++ b/spacy/pipeline/attributeruler.py @@ -19,7 +19,9 @@ from .pipe import Pipe MatcherPatternType = List[Dict[Union[int, str], Any]] -AttributeRulerPatternType = Dict[str, Union[List[MatcherPatternType], MatcherPatternType, Dict, int]] +AttributeRulerPatternType = Dict[ + str, Union[List[MatcherPatternType], MatcherPatternType, Dict, int] +] TagMapType = Dict[str, Dict[Union[int, str], Union[int, str]]] MorphRulesType = Dict[str, Dict[str, Dict[Union[int, str], Union[int, str]]]] diff --git a/spacy/schemas.py b/spacy/schemas.py index c0ecee314ee..e3200348013 100644 --- a/spacy/schemas.py +++ b/spacy/schemas.py @@ -299,7 +299,11 @@ class TokenPattern(BaseModel): op: Optional[TokenPatternOperator] = None underscore: Optional[Dict[StrictStr, UnderscoreValue]] = Field(None, alias="_") - model_config = ConfigDict(extra="forbid", populate_by_name=True, alias_generator=lambda value: value.upper()) + model_config = ConfigDict( + extra="forbid", + populate_by_name=True, + alias_generator=lambda value: value.upper(), + ) @field_validator("*", mode="before") @classmethod diff --git a/spacy/tests/matcher/test_pattern_validation.py b/spacy/tests/matcher/test_pattern_validation.py index 554522fe8a1..e0dc7d5a1dd 100644 --- a/spacy/tests/matcher/test_pattern_validation.py +++ b/spacy/tests/matcher/test_pattern_validation.py @@ -10,7 +10,11 @@ # Bad patterns flagged in all cases ([{"XX": "foo"}], 1, 1), ([{"IS_ALPHA": {"==": True}}, {"LIKE_NUM": None}], 2, 1), - ([{"IS_PUNCT": True, "OP": "$"}], 2, 1), # v2: union reports 2 errors (enum + pattern) + ( + [{"IS_PUNCT": True, "OP": "$"}], + 2, + 1, + ), # v2: union reports 2 errors (enum + pattern) ([{"_": "foo"}], 1, 1), ('[{"TEXT": "foo"}, {"LOWER": "bar"}]', 1, 1), ([{"ENT_IOB": "foo"}], 1, 1), @@ -24,10 +28,22 @@ ([{"TEXT": "foo", "OP": "{1, 3}"}], 2, 1), # v2: union reports 2 errors ([{"TEXT": "foo", "OP": "{-2}"}], 2, 1), # v2: union reports 2 errors # Bad patterns flagged outside of Matcher - ([{"_": {"foo": "bar", "baz": {"IN": "foo"}}}], 7, 0), # v2: more detailed union errors + ( + [{"_": {"foo": "bar", "baz": {"IN": "foo"}}}], + 7, + 0, + ), # v2: more detailed union errors # Bad patterns not flagged with minimal checks - ([{"LENGTH": "2", "TEXT": 2}, {"LOWER": "test"}], 5, 0), # v2: more detailed union errors - ([{"LENGTH": {"IN": [1, 2, "3"]}}, {"POS": {"IN": "VERB"}}], 5, 0), # v2: more detailed union errors + ( + [{"LENGTH": "2", "TEXT": 2}, {"LOWER": "test"}], + 5, + 0, + ), # v2: more detailed union errors + ( + [{"LENGTH": {"IN": [1, 2, "3"]}}, {"POS": {"IN": "VERB"}}], + 5, + 0, + ), # v2: more detailed union errors ([{"LENGTH": {"VALUE": 5}}], 3, 0), # v2: more detailed union errors ([{"TEXT": {"VALUE": "foo"}}], 2, 0), ([{"IS_DIGIT": -1}], 1, 0), From a84a2e64442bc69b96bb4d38eed6bde1bc5e2900 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 08:36:11 +0100 Subject: [PATCH 03/32] Replace black, isort, and flake8 with ruff for linting and formatting - requirements.txt: remove black, isort, flake8; add ruff - pyproject.toml: replace [tool.isort] with [tool.ruff] config - setup.cfg: remove [flake8] section (rules moved to pyproject.toml) - .pre-commit-config.yaml: replace black/flake8 hooks with ruff/ruff-format --- .pre-commit-config.yaml | 16 +++++----------- pyproject.toml | 9 ++++++++- requirements.txt | 4 +--- setup.cfg | 10 ---------- 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e2c5e98fd97..7d57c3a0c56 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,7 @@ repos: -- repo: https://github.com/ambv/black - rev: 22.3.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.9.0 hooks: - - id: black - language_version: python3.7 - additional_dependencies: ['click==8.0.4'] -- repo: https://github.com/pycqa/flake8 - rev: 5.0.4 - hooks: - - id: flake8 - args: - - "--config=setup.cfg" + - id: ruff + args: ['--fix'] + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 24d21dc342d..d60460e0c5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,5 +62,12 @@ repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest [tool.cibuildwheel.pyodide] -[tool.isort] +[tool.ruff] +line-length = 88 + +[tool.ruff.lint] +select = ["E", "F", "W", "C", "B", "B9"] +ignore = ["E203", "E266", "E501", "E731", "W503", "E741", "F541"] + +[tool.ruff.lint.isort] profile = "black" diff --git a/requirements.txt b/requirements.txt index 4fcf639ad4a..27a335fa6c1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,14 +26,12 @@ cython>=3.0,<4.0 pytest>=5.2.0,!=7.1.0 pytest-timeout>=1.3.0,<2.0.0 mock>=2.0.0,<3.0.0 -flake8>=3.8.0,<6.0.0 hypothesis>=3.27.0,<7.0.0 mypy>=1.5.0,<1.6.0; platform_machine != "aarch64" and python_version >= "3.8" types-mock>=0.1.1 types-setuptools>=57.0.0 types-requests types-setuptools>=57.0.0 -black>=25.0.0 +ruff>=0.9.0 cython-lint>=0.15.0 -isort>=5.0,<6.0 confection>=1.1.0,<2.0.0 diff --git a/setup.cfg b/setup.cfg index 7fdd3979868..6d2c7c06162 100644 --- a/setup.cfg +++ b/setup.cfg @@ -131,16 +131,6 @@ universal = false [sdist] formats = gztar -[flake8] -ignore = E203, E266, E501, E731, W503, E741, F541 -max-line-length = 80 -select = B,C,E,F,W,T4,B9 -exclude = - .env, - .git, - __pycache__, - _tokenizer_exceptions_list.py, - [tool:pytest] markers = slow: mark a test as slow From e9d7df6c3a4eaf80556abe0d8f94668151aed41a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 08:36:53 +0100 Subject: [PATCH 04/32] Remove W503 from ruff ignore list (not a valid ruff rule) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d60460e0c5e..801d5e0985a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ line-length = 88 [tool.ruff.lint] select = ["E", "F", "W", "C", "B", "B9"] -ignore = ["E203", "E266", "E501", "E731", "W503", "E741", "F541"] +ignore = ["E203", "E266", "E501", "E731", "E741", "F541"] [tool.ruff.lint.isort] profile = "black" From 200a3646c7c4358ee18522c8d32179ec1a0eae84 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 08:37:22 +0100 Subject: [PATCH 05/32] Fix ruff isort config: replace unsupported profile with equivalent settings --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 801d5e0985a..395c2f7a108 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,4 +70,5 @@ select = ["E", "F", "W", "C", "B", "B9"] ignore = ["E203", "E266", "E501", "E731", "E741", "F541"] [tool.ruff.lint.isort] -profile = "black" +combine-as-imports = true +split-on-trailing-comma = true From 041f47b3b29a2f5231e53027f444bea762d4a83a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 08:37:39 +0100 Subject: [PATCH 06/32] Format --- spacy/cli/apply.py | 15 +- spacy/cli/assemble.py | 23 +- spacy/cli/benchmark_speed.py | 28 ++- spacy/cli/convert.py | 52 ++++- spacy/cli/debug_config.py | 26 ++- spacy/cli/debug_data.py | 29 ++- spacy/cli/debug_diff.py | 36 +++- spacy/cli/debug_model.py | 18 +- spacy/cli/download.py | 13 +- spacy/cli/evaluate.py | 45 +++- spacy/cli/find_function.py | 4 +- spacy/cli/find_threshold.py | 38 +++- spacy/cli/info.py | 22 +- spacy/cli/init_config.py | 72 +++++-- spacy/cli/init_pipeline.py | 83 ++++++-- spacy/cli/package.py | 68 ++++-- spacy/cli/pretrain.py | 29 ++- spacy/cli/profile.py | 11 +- spacy/cli/train.py | 29 ++- spacy/lang/am/lex_attrs.py | 2 +- spacy/lang/el/tokenizer_exceptions.py | 1 - spacy/lang/es/lemmatizer.py | 5 +- spacy/lang/gd/stop_words.py | 4 +- spacy/lang/gd/tokenizer_exceptions.py | 4 +- spacy/lang/id/tokenizer_exceptions.py | 4 +- spacy/lang/ms/examples.py | 2 +- spacy/lang/tokenizer_exceptions.py | 10 +- spacy/lang/vi/stop_words.py | 4 +- spacy/language.py | 10 +- spacy/matcher/dependencymatcher.pyi | 6 +- spacy/matcher/matcher.pyi | 6 +- spacy/ml/models/entity_linker.py | 6 +- spacy/ml/staticvectors.py | 2 +- spacy/pipeline/attributeruler.py | 3 +- spacy/tests/lang/et/test_tokenizer.py | 3 +- spacy/tests/package/test_requirements.py | 6 +- spacy/tests/pipeline/test_entity_linker.py | 12 +- spacy/tests/pipeline/test_sentencizer.py | 40 +++- spacy/tests/pipeline/test_tok2vec.py | 58 ++++- spacy/tests/test_cli.py | 198 ++++++++++++++++-- spacy/tests/test_factory_imports.py | 12 +- spacy/tests/test_factory_registrations.py | 6 +- spacy/tests/test_registry_population.py | 6 +- spacy/tokens/doc.pyi | 10 +- spacy/tokens/span.pyi | 8 +- spacy/tokens/span_group.pyi | 2 +- spacy/tokens/token.pyi | 8 +- spacy/training/batchers.py | 8 +- .../training/converters/conll_ner_to_docs.py | 3 +- spacy/training/converters/conllu_to_docs.py | 2 +- spacy/training/loggers.py | 2 +- spacy/ty.py | 4 +- spacy/util.py | 4 +- 53 files changed, 861 insertions(+), 241 deletions(-) diff --git a/spacy/cli/apply.py b/spacy/cli/apply.py index ffd8105060a..7671026f488 100644 --- a/spacy/cli/apply.py +++ b/spacy/cli/apply.py @@ -22,7 +22,7 @@ out_help = "Path to save the resulting .spacy file" code_help = ( - "Path to Python file with additional " "code (registered functions) to be imported" + "Path to Python file with additional code (registered functions) to be imported" ) gold_help = "Use gold preprocessing provided in the .spacy files" force_msg = ( @@ -72,11 +72,15 @@ def apply_cli( data_path: Path = Arg(..., help=path_help, exists=True), output_file: Path = Arg(..., help=out_help, dir_okay=False), code_path: Optional[Path] = Opt(None, "--code", "-c", help=code_help), - text_key: str = Opt("text", "--text-key", "-tk", help="Key containing text string for JSONL"), - force_overwrite: bool = Opt(False, "--force", "-F", help="Force overwriting the output file"), + text_key: str = Opt( + "text", "--text-key", "-tk", help="Key containing text string for JSONL" + ), + force_overwrite: bool = Opt( + False, "--force", "-F", help="Force overwriting the output file" + ), use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU."), batch_size: int = Opt(1, "--batch-size", "-b", help="Batch size."), - n_process: int = Opt(1, "--n-process", "-n", help="number of processors to use.") + n_process: int = Opt(1, "--n-process", "-n", help="number of processors to use."), ): """ Apply a trained pipeline to documents to get predictions. @@ -114,8 +118,7 @@ def apply( if len(paths) == 0: docbin.to_disk(output_file) msg.warn( - "Did not find data to process," - f" {data_path} seems to be an empty directory." + f"Did not find data to process, {data_path} seems to be an empty directory." ) return nlp = load_model(model) diff --git a/spacy/cli/assemble.py b/spacy/cli/assemble.py index f74bbacb555..bc97a9d594f 100644 --- a/spacy/cli/assemble.py +++ b/spacy/cli/assemble.py @@ -24,10 +24,25 @@ def assemble_cli( # fmt: off ctx: typer.Context, # This is only used to read additional arguments - config_path: Path = Arg(..., help="Path to config file", exists=True, allow_dash=True), - output_path: Path = Arg(..., help="Output directory to store assembled pipeline in"), - code_path: Optional[Path] = Opt(None, "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), - verbose: bool = Opt(False, "--verbose", "-V", "-VV", help="Display more information for debugging purposes"), + config_path: Path = Arg( + ..., help="Path to config file", exists=True, allow_dash=True + ), + output_path: Path = Arg( + ..., help="Output directory to store assembled pipeline in" + ), + code_path: Optional[Path] = Opt( + None, + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), + verbose: bool = Opt( + False, + "--verbose", + "-V", + "-VV", + help="Display more information for debugging purposes", + ), # fmt: on ): """ diff --git a/spacy/cli/benchmark_speed.py b/spacy/cli/benchmark_speed.py index 4dd10049cda..052e7d43416 100644 --- a/spacy/cli/benchmark_speed.py +++ b/spacy/cli/benchmark_speed.py @@ -24,13 +24,29 @@ def benchmark_speed_cli( # fmt: off ctx: typer.Context, model: str = Arg(..., help="Model name or path"), - data_path: Path = Arg(..., help="Location of binary evaluation data in .spacy format", exists=True), - batch_size: Optional[int] = Opt(None, "--batch-size", "-b", min=1, help="Override the pipeline batch size"), + data_path: Path = Arg( + ..., help="Location of binary evaluation data in .spacy format", exists=True + ), + batch_size: Optional[int] = Opt( + None, "--batch-size", "-b", min=1, help="Override the pipeline batch size" + ), no_shuffle: bool = Opt(False, "--no-shuffle", help="Do not shuffle benchmark data"), use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"), - n_batches: int = Opt(50, "--batches", help="Minimum number of batches to benchmark", min=30,), - warmup_epochs: int = Opt(3, "--warmup", "-w", min=0, help="Number of iterations over the data for warmup"), - code_path: Optional[Path] = Opt(None, "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), + n_batches: int = Opt( + 50, + "--batches", + help="Minimum number of batches to benchmark", + min=30, + ), + warmup_epochs: int = Opt( + 3, "--warmup", "-w", min=0, help="Number of iterations over the data for warmup" + ), + code_path: Optional[Path] = Opt( + None, + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), # fmt: on ): """ @@ -151,7 +167,7 @@ def print_mean_with_ci(sample: numpy.ndarray): low = bootstrap_means[int(len(bootstrap_means) * 0.025)] high = bootstrap_means[int(len(bootstrap_means) * 0.975)] - print(f"Mean: {mean:.1f} words/s (95% CI: {low-mean:.1f} +{high-mean:.1f})") + print(f"Mean: {mean:.1f} words/s (95% CI: {low - mean:.1f} +{high - mean:.1f})") def print_outliers(sample: numpy.ndarray): diff --git a/spacy/cli/convert.py b/spacy/cli/convert.py index a66a68133b3..140999207f3 100644 --- a/spacy/cli/convert.py +++ b/spacy/cli/convert.py @@ -48,17 +48,47 @@ class FileTypes(str, Enum): def convert_cli( # fmt: off input_path: str = Arg(..., help="Input file or directory", exists=True), - output_dir: Path = Arg("-", help="Output directory. '-' for stdout.", allow_dash=True, exists=True), - file_type: FileTypes = Opt("spacy", "--file-type", "-t", help="Type of data to produce"), - n_sents: int = Opt(1, "--n-sents", "-n", help="Number of sentences per doc (0 to disable)"), - seg_sents: bool = Opt(False, "--seg-sents", "-s", help="Segment sentences (for -c ner)"), - model: Optional[str] = Opt(None, "--model", "--base", "-b", help="Trained spaCy pipeline for sentence segmentation to use as base (for --seg-sents)"), - morphology: bool = Opt(False, "--morphology", "-m", help="Enable appending morphology to tags"), - merge_subtokens: bool = Opt(False, "--merge-subtokens", "-T", help="Merge CoNLL-U subtokens"), - converter: str = Opt(AUTO, "--converter", "-c", help=f"Converter: {tuple(CONVERTERS.keys())}"), - ner_map: Optional[Path] = Opt(None, "--ner-map", "-nm", help="NER tag mapping (as JSON-encoded dict of entity types)", exists=True), - lang: Optional[str] = Opt(None, "--lang", "-l", help="Language (if tokenizer required)"), - concatenate: bool = Opt(None, "--concatenate", "-C", help="Concatenate output to a single file"), + output_dir: Path = Arg( + "-", help="Output directory. '-' for stdout.", allow_dash=True, exists=True + ), + file_type: FileTypes = Opt( + "spacy", "--file-type", "-t", help="Type of data to produce" + ), + n_sents: int = Opt( + 1, "--n-sents", "-n", help="Number of sentences per doc (0 to disable)" + ), + seg_sents: bool = Opt( + False, "--seg-sents", "-s", help="Segment sentences (for -c ner)" + ), + model: Optional[str] = Opt( + None, + "--model", + "--base", + "-b", + help="Trained spaCy pipeline for sentence segmentation to use as base (for --seg-sents)", + ), + morphology: bool = Opt( + False, "--morphology", "-m", help="Enable appending morphology to tags" + ), + merge_subtokens: bool = Opt( + False, "--merge-subtokens", "-T", help="Merge CoNLL-U subtokens" + ), + converter: str = Opt( + AUTO, "--converter", "-c", help=f"Converter: {tuple(CONVERTERS.keys())}" + ), + ner_map: Optional[Path] = Opt( + None, + "--ner-map", + "-nm", + help="NER tag mapping (as JSON-encoded dict of entity types)", + exists=True, + ), + lang: Optional[str] = Opt( + None, "--lang", "-l", help="Language (if tokenizer required)" + ), + concatenate: bool = Opt( + None, "--concatenate", "-C", help="Concatenate output to a single file" + ), # fmt: on ): """ diff --git a/spacy/cli/debug_config.py b/spacy/cli/debug_config.py index 0e5382cd956..f049d7fd149 100644 --- a/spacy/cli/debug_config.py +++ b/spacy/cli/debug_config.py @@ -26,10 +26,28 @@ def debug_config_cli( # fmt: off ctx: typer.Context, # This is only used to read additional arguments - config_path: Path = Arg(..., help="Path to config file", exists=True, allow_dash=True), - code_path: Optional[Path] = Opt(None, "--code-path", "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), - show_funcs: bool = Opt(False, "--show-functions", "-F", help="Show an overview of all registered functions used in the config and where they come from (modules, files etc.)"), - show_vars: bool = Opt(False, "--show-variables", "-V", help="Show an overview of all variables referenced in the config and their values. This will also reflect variables overwritten on the CLI.") + config_path: Path = Arg( + ..., help="Path to config file", exists=True, allow_dash=True + ), + code_path: Optional[Path] = Opt( + None, + "--code-path", + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), + show_funcs: bool = Opt( + False, + "--show-functions", + "-F", + help="Show an overview of all registered functions used in the config and where they come from (modules, files etc.)", + ), + show_vars: bool = Opt( + False, + "--show-variables", + "-V", + help="Show an overview of all variables referenced in the config and their values. This will also reflect variables overwritten on the CLI.", + ), # fmt: on ): """Debug a config file and show validation errors. The command will diff --git a/spacy/cli/debug_data.py b/spacy/cli/debug_data.py index 1c9c0e0ea3a..df52250cf90 100644 --- a/spacy/cli/debug_data.py +++ b/spacy/cli/debug_data.py @@ -71,11 +71,28 @@ def debug_data_cli( # fmt: off ctx: typer.Context, # This is only used to read additional arguments - config_path: Path = Arg(..., help="Path to config file", exists=True, allow_dash=True), - code_path: Optional[Path] = Opt(None, "--code-path", "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), - ignore_warnings: bool = Opt(False, "--ignore-warnings", "-IW", help="Ignore warnings, only show stats and errors"), - verbose: bool = Opt(False, "--verbose", "-V", help="Print additional information and explanations"), - no_format: bool = Opt(False, "--no-format", "-NF", help="Don't pretty-print the results"), + config_path: Path = Arg( + ..., help="Path to config file", exists=True, allow_dash=True + ), + code_path: Optional[Path] = Opt( + None, + "--code-path", + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), + ignore_warnings: bool = Opt( + False, + "--ignore-warnings", + "-IW", + help="Ignore warnings, only show stats and errors", + ), + verbose: bool = Opt( + False, "--verbose", "-V", help="Print additional information and explanations" + ), + no_format: bool = Opt( + False, "--no-format", "-NF", help="Don't pretty-print the results" + ), # fmt: on ): """ @@ -708,7 +725,7 @@ def debug_data( if len(dev_not_train) != 0: pct = len(dev_not_train) / len(trees_dev) msg.info( - f"{len(dev_not_train)} lemmatizer trees ({pct*100:.1f}% of dev trees)" + f"{len(dev_not_train)} lemmatizer trees ({pct * 100:.1f}% of dev trees)" " were found exclusively in the dev data." ) else: diff --git a/spacy/cli/debug_diff.py b/spacy/cli/debug_diff.py index c53b0acab50..08c31b32df3 100644 --- a/spacy/cli/debug_diff.py +++ b/spacy/cli/debug_diff.py @@ -17,12 +17,36 @@ def debug_diff_cli( # fmt: off ctx: typer.Context, - config_path: Path = Arg(..., help="Path to config file", exists=True, allow_dash=True), - compare_to: Optional[Path] = Opt(None, help="Path to a config file to diff against, or `None` to compare against default settings", exists=True, allow_dash=True), - optimize: Optimizations = Opt(Optimizations.efficiency.value, "--optimize", "-o", help="Whether the user config was optimized for efficiency or accuracy. Only relevant when comparing against the default config."), - gpu: bool = Opt(False, "--gpu", "-G", help="Whether the original config can run on a GPU. Only relevant when comparing against the default config."), - pretraining: bool = Opt(False, "--pretraining", "--pt", help="Whether to compare on a config with pretraining involved. Only relevant when comparing against the default config."), - markdown: bool = Opt(False, "--markdown", "-md", help="Generate Markdown for GitHub issues") + config_path: Path = Arg( + ..., help="Path to config file", exists=True, allow_dash=True + ), + compare_to: Optional[Path] = Opt( + None, + help="Path to a config file to diff against, or `None` to compare against default settings", + exists=True, + allow_dash=True, + ), + optimize: Optimizations = Opt( + Optimizations.efficiency.value, + "--optimize", + "-o", + help="Whether the user config was optimized for efficiency or accuracy. Only relevant when comparing against the default config.", + ), + gpu: bool = Opt( + False, + "--gpu", + "-G", + help="Whether the original config can run on a GPU. Only relevant when comparing against the default config.", + ), + pretraining: bool = Opt( + False, + "--pretraining", + "--pt", + help="Whether to compare on a config with pretraining involved. Only relevant when comparing against the default config.", + ), + markdown: bool = Opt( + False, "--markdown", "-md", help="Generate Markdown for GitHub issues" + ), # fmt: on ): """Show a diff of a config file with respect to spaCy's defaults or another config file. If diff --git a/spacy/cli/debug_model.py b/spacy/cli/debug_model.py index 3c667e42a2b..ec7ffe099d7 100644 --- a/spacy/cli/debug_model.py +++ b/spacy/cli/debug_model.py @@ -36,18 +36,26 @@ def debug_model_cli( # fmt: off ctx: typer.Context, # This is only used to read additional arguments - config_path: Path = Arg(..., help="Path to config file", exists=True, allow_dash=True), - component: str = Arg(..., help="Name of the pipeline component of which the model should be analysed"), - layers: str = Opt("", "--layers", "-l", help="Comma-separated names of layer IDs to print"), + config_path: Path = Arg( + ..., help="Path to config file", exists=True, allow_dash=True + ), + component: str = Arg( + ..., help="Name of the pipeline component of which the model should be analysed" + ), + layers: str = Opt( + "", "--layers", "-l", help="Comma-separated names of layer IDs to print" + ), dimensions: bool = Opt(False, "--dimensions", "-DIM", help="Show dimensions"), parameters: bool = Opt(False, "--parameters", "-PAR", help="Show parameters"), gradients: bool = Opt(False, "--gradients", "-GRAD", help="Show gradients"), attributes: bool = Opt(False, "--attributes", "-ATTR", help="Show attributes"), P0: bool = Opt(False, "--print-step0", "-P0", help="Print model before training"), - P1: bool = Opt(False, "--print-step1", "-P1", help="Print model after initialization"), + P1: bool = Opt( + False, "--print-step1", "-P1", help="Print model after initialization" + ), P2: bool = Opt(False, "--print-step2", "-P2", help="Print model after training"), P3: bool = Opt(False, "--print-step3", "-P3", help="Print final predictions"), - use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU") + use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"), # fmt: on ): """ diff --git a/spacy/cli/download.py b/spacy/cli/download.py index 120616753b8..8a1110dcef3 100644 --- a/spacy/cli/download.py +++ b/spacy/cli/download.py @@ -28,9 +28,16 @@ def download_cli( # fmt: off ctx: typer.Context, model: str = Arg(..., help="Name of pipeline package to download"), - direct: bool = Opt(False, "--direct", "-d", "-D", help="Force direct download of name + version"), - sdist: bool = Opt(False, "--sdist", "-S", help="Download sdist (.tar.gz) archive instead of pre-built binary wheel"), - url: str = Opt(None, "--url", "-U", help="Download from given url") + direct: bool = Opt( + False, "--direct", "-d", "-D", help="Force direct download of name + version" + ), + sdist: bool = Opt( + False, + "--sdist", + "-S", + help="Download sdist (.tar.gz) archive instead of pre-built binary wheel", + ), + url: str = Opt(None, "--url", "-U", help="Download from given url"), # fmt: on ): """ diff --git a/spacy/cli/evaluate.py b/spacy/cli/evaluate.py index 2276ca6b0d4..62131fe13ea 100644 --- a/spacy/cli/evaluate.py +++ b/spacy/cli/evaluate.py @@ -20,15 +20,42 @@ def evaluate_cli( # fmt: off model: str = Arg(..., help="Model name or path"), - data_path: Path = Arg(..., help="Location of binary evaluation data in .spacy format", exists=True), - output: Optional[Path] = Opt(None, "--output", "-o", help="Output JSON file for metrics", dir_okay=False), - code_path: Optional[Path] = Opt(None, "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), + data_path: Path = Arg( + ..., help="Location of binary evaluation data in .spacy format", exists=True + ), + output: Optional[Path] = Opt( + None, "--output", "-o", help="Output JSON file for metrics", dir_okay=False + ), + code_path: Optional[Path] = Opt( + None, + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"), - gold_preproc: bool = Opt(False, "--gold-preproc", "-G", help="Use gold preprocessing"), - displacy_path: Optional[Path] = Opt(None, "--displacy-path", "-dp", help="Directory to output rendered parses as HTML", exists=True, file_okay=False), - displacy_limit: int = Opt(25, "--displacy-limit", "-dl", help="Limit of parses to render as HTML"), - per_component: bool = Opt(False, "--per-component", "-P", help="Return scores per component, only applicable when an output JSON file is specified."), - spans_key: str = Opt("sc", "--spans-key", "-sk", help="Spans key to use when evaluating Doc.spans"), + gold_preproc: bool = Opt( + False, "--gold-preproc", "-G", help="Use gold preprocessing" + ), + displacy_path: Optional[Path] = Opt( + None, + "--displacy-path", + "-dp", + help="Directory to output rendered parses as HTML", + exists=True, + file_okay=False, + ), + displacy_limit: int = Opt( + 25, "--displacy-limit", "-dl", help="Limit of parses to render as HTML" + ), + per_component: bool = Opt( + False, + "--per-component", + "-P", + help="Return scores per component, only applicable when an output JSON file is specified.", + ), + spans_key: str = Opt( + "sc", "--spans-key", "-sk", help="Spans key to use when evaluating Doc.spans" + ), # fmt: on ): """ @@ -123,7 +150,7 @@ def evaluate( if key == "speed": results[metric] = f"{scores[key]:.0f}" else: - results[metric] = f"{scores[key]*100:.2f}" + results[metric] = f"{scores[key] * 100:.2f}" else: results[metric] = "-" data[re.sub(r"[\s/]", "_", key.lower())] = scores[key] diff --git a/spacy/cli/find_function.py b/spacy/cli/find_function.py index f99ce2adc9f..3b3b333337b 100644 --- a/spacy/cli/find_function.py +++ b/spacy/cli/find_function.py @@ -11,7 +11,9 @@ def find_function_cli( # fmt: off func_name: str = Arg(..., help="Name of the registered function."), - registry_name: Optional[str] = Opt(None, "--registry", "-r", help="Name of the catalogue registry."), + registry_name: Optional[str] = Opt( + None, "--registry", "-r", help="Name of the catalogue registry." + ), # fmt: on ): """ diff --git a/spacy/cli/find_threshold.py b/spacy/cli/find_threshold.py index ff7af32e6f6..d89b4c27d55 100644 --- a/spacy/cli/find_threshold.py +++ b/spacy/cli/find_threshold.py @@ -27,15 +27,39 @@ def find_threshold_cli( # fmt: off model: str = Arg(..., help="Model name or path"), - data_path: Path = Arg(..., help="Location of binary evaluation data in .spacy format", exists=True), + data_path: Path = Arg( + ..., help="Location of binary evaluation data in .spacy format", exists=True + ), pipe_name: str = Arg(..., help="Name of pipe to examine thresholds for"), - threshold_key: str = Arg(..., help="Key of threshold attribute in component's configuration"), + threshold_key: str = Arg( + ..., help="Key of threshold attribute in component's configuration" + ), scores_key: str = Arg(..., help="Metric to optimize"), - n_trials: int = Opt(_DEFAULTS["n_trials"], "--n_trials", "-n", help="Number of trials to determine optimal thresholds"), - code_path: Optional[Path] = Opt(None, "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), - use_gpu: int = Opt(_DEFAULTS["use_gpu"], "--gpu-id", "-g", help="GPU ID or -1 for CPU"), - gold_preproc: bool = Opt(_DEFAULTS["gold_preproc"], "--gold-preproc", "-G", help="Use gold preprocessing"), - verbose: bool = Opt(False, "--verbose", "-V", "-VV", help="Display more information for debugging purposes"), + n_trials: int = Opt( + _DEFAULTS["n_trials"], + "--n_trials", + "-n", + help="Number of trials to determine optimal thresholds", + ), + code_path: Optional[Path] = Opt( + None, + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), + use_gpu: int = Opt( + _DEFAULTS["use_gpu"], "--gpu-id", "-g", help="GPU ID or -1 for CPU" + ), + gold_preproc: bool = Opt( + _DEFAULTS["gold_preproc"], "--gold-preproc", "-G", help="Use gold preprocessing" + ), + verbose: bool = Opt( + False, + "--verbose", + "-V", + "-VV", + help="Display more information for debugging purposes", + ), # fmt: on ): """ diff --git a/spacy/cli/info.py b/spacy/cli/info.py index 8bfc6b54f15..ed2394c564e 100644 --- a/spacy/cli/info.py +++ b/spacy/cli/info.py @@ -16,10 +16,24 @@ def info_cli( # fmt: off model: Optional[str] = Arg(None, help="Optional loadable spaCy pipeline"), - markdown: bool = Opt(False, "--markdown", "-md", help="Generate Markdown for GitHub issues"), - silent: bool = Opt(False, "--silent", "-s", "-S", help="Don't print anything (just return)"), - exclude: str = Opt("labels", "--exclude", "-e", help="Comma-separated keys to exclude from the print-out"), - url: bool = Opt(False, "--url", "-u", help="Print the URL to download the most recent compatible version of the pipeline"), + markdown: bool = Opt( + False, "--markdown", "-md", help="Generate Markdown for GitHub issues" + ), + silent: bool = Opt( + False, "--silent", "-s", "-S", help="Don't print anything (just return)" + ), + exclude: str = Opt( + "labels", + "--exclude", + "-e", + help="Comma-separated keys to exclude from the print-out", + ), + url: bool = Opt( + False, + "--url", + "-u", + help="Print the URL to download the most recent compatible version of the pipeline", + ), # fmt: on ): """ diff --git a/spacy/cli/init_config.py b/spacy/cli/init_config.py index a7fb2b5b81f..2cb39056d5e 100644 --- a/spacy/cli/init_config.py +++ b/spacy/cli/init_config.py @@ -49,13 +49,44 @@ class InitValues: @init_cli.command("config") def init_config_cli( # fmt: off - output_file: Path = Arg(..., help="File to save the config to or - for stdout (will only output config and no additional logging info)", allow_dash=True), - lang: str = Opt(InitValues.lang, "--lang", "-l", help="Two-letter code of the language to use"), - pipeline: str = Opt(",".join(InitValues.pipeline), "--pipeline", "-p", help="Comma-separated names of trainable pipeline components to include (without 'tok2vec' or 'transformer')"), - optimize: Optimizations = Opt(InitValues.optimize, "--optimize", "-o", help="Whether to optimize for efficiency (faster inference, smaller model, lower memory consumption) or higher accuracy (potentially larger and slower model). This will impact the choice of architecture, pretrained weights and related hyperparameters."), - gpu: bool = Opt(InitValues.gpu, "--gpu", "-G", help="Whether the model can run on GPU. This will impact the choice of architecture, pretrained weights and related hyperparameters."), - pretraining: bool = Opt(InitValues.pretraining, "--pretraining", "-pt", help="Include config for pretraining (with 'spacy pretrain')"), - force_overwrite: bool = Opt(InitValues.force_overwrite, "--force", "-F", help="Force overwriting the output file"), + output_file: Path = Arg( + ..., + help="File to save the config to or - for stdout (will only output config and no additional logging info)", + allow_dash=True, + ), + lang: str = Opt( + InitValues.lang, "--lang", "-l", help="Two-letter code of the language to use" + ), + pipeline: str = Opt( + ",".join(InitValues.pipeline), + "--pipeline", + "-p", + help="Comma-separated names of trainable pipeline components to include (without 'tok2vec' or 'transformer')", + ), + optimize: Optimizations = Opt( + InitValues.optimize, + "--optimize", + "-o", + help="Whether to optimize for efficiency (faster inference, smaller model, lower memory consumption) or higher accuracy (potentially larger and slower model). This will impact the choice of architecture, pretrained weights and related hyperparameters.", + ), + gpu: bool = Opt( + InitValues.gpu, + "--gpu", + "-G", + help="Whether the model can run on GPU. This will impact the choice of architecture, pretrained weights and related hyperparameters.", + ), + pretraining: bool = Opt( + InitValues.pretraining, + "--pretraining", + "-pt", + help="Include config for pretraining (with 'spacy pretrain')", + ), + force_overwrite: bool = Opt( + InitValues.force_overwrite, + "--force", + "-F", + help="Force overwriting the output file", + ), # fmt: on ): """ @@ -88,11 +119,28 @@ def init_config_cli( @init_cli.command("fill-config") def init_fill_config_cli( # fmt: off - base_path: Path = Arg(..., help="Path to base config to fill", exists=True, dir_okay=False), - output_file: Path = Arg("-", help="Path to output .cfg file (or - for stdout)", allow_dash=True), - pretraining: bool = Opt(False, "--pretraining", "-pt", help="Include config for pretraining (with 'spacy pretrain')"), - diff: bool = Opt(False, "--diff", "-D", help="Print a visual diff highlighting the changes"), - code_path: Optional[Path] = Opt(None, "--code-path", "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), + base_path: Path = Arg( + ..., help="Path to base config to fill", exists=True, dir_okay=False + ), + output_file: Path = Arg( + "-", help="Path to output .cfg file (or - for stdout)", allow_dash=True + ), + pretraining: bool = Opt( + False, + "--pretraining", + "-pt", + help="Include config for pretraining (with 'spacy pretrain')", + ), + diff: bool = Opt( + False, "--diff", "-D", help="Print a visual diff highlighting the changes" + ), + code_path: Optional[Path] = Opt( + None, + "--code-path", + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), # fmt: on ): """ diff --git a/spacy/cli/init_pipeline.py b/spacy/cli/init_pipeline.py index 21eea8edf2f..1c0ff526235 100644 --- a/spacy/cli/init_pipeline.py +++ b/spacy/cli/init_pipeline.py @@ -26,13 +26,42 @@ def init_vectors_cli( lang: str = Arg(..., help="The language of the nlp object to create"), vectors_loc: Path = Arg(..., help="Vectors file in Word2Vec format", exists=True), output_dir: Path = Arg(..., help="Pipeline output directory"), - prune: int = Opt(-1, "--prune", "-p", help="Optional number of vectors to prune to"), - truncate: int = Opt(0, "--truncate", "-t", help="Optional number of vectors to truncate to when reading in vectors file"), + prune: int = Opt( + -1, "--prune", "-p", help="Optional number of vectors to prune to" + ), + truncate: int = Opt( + 0, + "--truncate", + "-t", + help="Optional number of vectors to truncate to when reading in vectors file", + ), mode: str = Opt("default", "--mode", "-m", help="Vectors mode: default or floret"), - name: Optional[str] = Opt(None, "--name", "-n", help="Optional name for the word vectors, e.g. en_core_web_lg.vectors"), - verbose: bool = Opt(False, "--verbose", "-V", "-VV", help="Display more information for debugging purposes"), - jsonl_loc: Optional[Path] = Opt(None, "--lexemes-jsonl", "-j", help="Location of JSONL-formatted attributes file", hidden=True), - attr: str = Opt("ORTH", "--attr", "-a", help="Optional token attribute to use for vectors, e.g. LOWER or NORM"), + name: Optional[str] = Opt( + None, + "--name", + "-n", + help="Optional name for the word vectors, e.g. en_core_web_lg.vectors", + ), + verbose: bool = Opt( + False, + "--verbose", + "-V", + "-VV", + help="Display more information for debugging purposes", + ), + jsonl_loc: Optional[Path] = Opt( + None, + "--lexemes-jsonl", + "-j", + help="Location of JSONL-formatted attributes file", + hidden=True, + ), + attr: str = Opt( + "ORTH", + "--attr", + "-a", + help="Optional token attribute to use for vectors, e.g. LOWER or NORM", + ), # fmt: on ): """Convert word vectors for use with spaCy. Will export an nlp object that @@ -81,11 +110,24 @@ def update_lexemes(nlp: Language, jsonl_loc: Path) -> None: def init_pipeline_cli( # fmt: off ctx: typer.Context, # This is only used to read additional arguments - config_path: Path = Arg(..., help="Path to config file", exists=True, allow_dash=True), + config_path: Path = Arg( + ..., help="Path to config file", exists=True, allow_dash=True + ), output_path: Path = Arg(..., help="Output directory for the prepared data"), - code_path: Optional[Path] = Opt(None, "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), - verbose: bool = Opt(False, "--verbose", "-V", "-VV", help="Display more information for debugging purposes"), - use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU") + code_path: Optional[Path] = Opt( + None, + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), + verbose: bool = Opt( + False, + "--verbose", + "-V", + "-VV", + help="Display more information for debugging purposes", + ), + use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"), # fmt: on ): if verbose: @@ -108,11 +150,24 @@ def init_pipeline_cli( def init_labels_cli( # fmt: off ctx: typer.Context, # This is only used to read additional arguments - config_path: Path = Arg(..., help="Path to config file", exists=True, allow_dash=True), + config_path: Path = Arg( + ..., help="Path to config file", exists=True, allow_dash=True + ), output_path: Path = Arg(..., help="Output directory for the labels"), - code_path: Optional[Path] = Opt(None, "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), - verbose: bool = Opt(False, "--verbose", "-V", "-VV", help="Display more information for debugging purposes"), - use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU") + code_path: Optional[Path] = Opt( + None, + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), + verbose: bool = Opt( + False, + "--verbose", + "-V", + "-VV", + help="Display more information for debugging purposes", + ), + use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"), # fmt: on ): """Generate JSON files for the labels in the data. This helps speed up the diff --git a/spacy/cli/package.py b/spacy/cli/package.py index 67b1d318651..9291aae2827 100644 --- a/spacy/cli/package.py +++ b/spacy/cli/package.py @@ -21,16 +21,56 @@ @app.command("package") def package_cli( # fmt: off - input_dir: Path = Arg(..., help="Directory with pipeline data", exists=True, file_okay=False), - output_dir: Path = Arg(..., help="Output parent directory", exists=True, file_okay=False), - code_paths: str = Opt("", "--code", "-c", help="Comma-separated paths to Python file with additional code (registered functions) to be included in the package"), - meta_path: Optional[Path] = Opt(None, "--meta-path", "--meta", "-m", help="Path to meta.json", exists=True, dir_okay=False), - create_meta: bool = Opt(False, "--create-meta", "-C", help="Create meta.json, even if one exists"), - name: Optional[str] = Opt(None, "--name", "-n", help="Package name to override meta"), - version: Optional[str] = Opt(None, "--version", "-v", help="Package version to override meta"), - build: str = Opt("sdist", "--build", "-b", help="Comma-separated formats to build: sdist and/or wheel, or none."), - force: bool = Opt(False, "--force", "-f", "-F", help="Force overwriting existing data in output directory"), - require_parent: bool = Opt(True, "--require-parent/--no-require-parent", "-R", "-R", help="Include the parent package (e.g. spacy) in the requirements"), + input_dir: Path = Arg( + ..., help="Directory with pipeline data", exists=True, file_okay=False + ), + output_dir: Path = Arg( + ..., help="Output parent directory", exists=True, file_okay=False + ), + code_paths: str = Opt( + "", + "--code", + "-c", + help="Comma-separated paths to Python file with additional code (registered functions) to be included in the package", + ), + meta_path: Optional[Path] = Opt( + None, + "--meta-path", + "--meta", + "-m", + help="Path to meta.json", + exists=True, + dir_okay=False, + ), + create_meta: bool = Opt( + False, "--create-meta", "-C", help="Create meta.json, even if one exists" + ), + name: Optional[str] = Opt( + None, "--name", "-n", help="Package name to override meta" + ), + version: Optional[str] = Opt( + None, "--version", "-v", help="Package version to override meta" + ), + build: str = Opt( + "sdist", + "--build", + "-b", + help="Comma-separated formats to build: sdist and/or wheel, or none.", + ), + force: bool = Opt( + False, + "--force", + "-f", + "-F", + help="Force overwriting existing data in output directory", + ), + require_parent: bool = Opt( + True, + "--require-parent/--no-require-parent", + "-R", + "-R", + help="Include the parent package (e.g. spacy) in the requirements", + ), # fmt: on ): """ @@ -410,7 +450,7 @@ def generate_readme(meta: Dict[str, Any]) -> str: pipeline = ", ".join([md.code(p) for p in meta.get("pipeline", [])]) components = ", ".join([md.code(p) for p in meta.get("components", [])]) vecs = meta.get("vectors", {}) - vectors = f"{vecs.get('keys', 0)} keys, {vecs.get('vectors', 0)} unique vectors ({ vecs.get('width', 0)} dimensions)" + vectors = f"{vecs.get('keys', 0)} keys, {vecs.get('vectors', 0)} unique vectors ({vecs.get('width', 0)} dimensions)" author = meta.get("author") or "n/a" notes = meta.get("notes", "") license_name = meta.get("license") @@ -469,7 +509,7 @@ def _format_accuracy(data: Dict[str, Any], exclude: List[str] = ["speed"]) -> st md = MarkdownRenderer() scalars = [(k, v) for k, v in data.items() if isinstance(v, (int, float))] scores = [ - (md.code(acc.upper()), f"{score*100:.2f}") + (md.code(acc.upper()), f"{score * 100:.2f}") for acc, score in scalars if acc not in exclude ] @@ -488,9 +528,7 @@ def _format_label_scheme(data: Dict[str, Any]) -> str: if not labels: continue col1 = md.bold(md.code(pipe)) - col2 = ", ".join( - [md.code(str(label).replace("|", "\\|")) for label in labels] - ) # noqa: W605 + col2 = ", ".join([md.code(str(label).replace("|", "\\|")) for label in labels]) # noqa: W605 label_data.append((col1, col2)) n_labels += len(labels) n_pipes += 1 diff --git a/spacy/cli/pretrain.py b/spacy/cli/pretrain.py index 446c40510df..daea861a952 100644 --- a/spacy/cli/pretrain.py +++ b/spacy/cli/pretrain.py @@ -25,13 +25,32 @@ def pretrain_cli( # fmt: off ctx: typer.Context, # This is only used to read additional arguments - config_path: Path = Arg(..., help="Path to config file", exists=True, dir_okay=False, allow_dash=True), + config_path: Path = Arg( + ..., help="Path to config file", exists=True, dir_okay=False, allow_dash=True + ), output_dir: Path = Arg(..., help="Directory to write weights to on each epoch"), - code_path: Optional[Path] = Opt(None, "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), - resume_path: Optional[Path] = Opt(None, "--resume-path", "-r", help="Path to pretrained weights from which to resume pretraining"), - epoch_resume: Optional[int] = Opt(None, "--epoch-resume", "-er", help="The epoch to resume counting from when using --resume-path. Prevents unintended overwriting of existing weight files."), + code_path: Optional[Path] = Opt( + None, + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), + resume_path: Optional[Path] = Opt( + None, + "--resume-path", + "-r", + help="Path to pretrained weights from which to resume pretraining", + ), + epoch_resume: Optional[int] = Opt( + None, + "--epoch-resume", + "-er", + help="The epoch to resume counting from when using --resume-path. Prevents unintended overwriting of existing weight files.", + ), use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"), - skip_last: bool = Opt(False, "--skip-last", "-L", help="Skip saving model-last.bin"), + skip_last: bool = Opt( + False, "--skip-last", "-L", help="Skip saving model-last.bin" + ), # fmt: on ): """ diff --git a/spacy/cli/profile.py b/spacy/cli/profile.py index e5b8f11939f..03f7127149e 100644 --- a/spacy/cli/profile.py +++ b/spacy/cli/profile.py @@ -21,8 +21,15 @@ def profile_cli( # fmt: off ctx: typer.Context, # This is only used to read current calling context model: str = Arg(..., help="Trained pipeline to load"), - inputs: Optional[Path] = Arg(None, help="Location of input file. '-' for stdin.", exists=True, allow_dash=True), - n_texts: int = Opt(10000, "--n-texts", "-n", help="Maximum number of texts to use if available"), + inputs: Optional[Path] = Arg( + None, + help="Location of input file. '-' for stdin.", + exists=True, + allow_dash=True, + ), + n_texts: int = Opt( + 10000, "--n-texts", "-n", help="Maximum number of texts to use if available" + ), # fmt: on ): """ diff --git a/spacy/cli/train.py b/spacy/cli/train.py index c72e13b2681..379268286ee 100644 --- a/spacy/cli/train.py +++ b/spacy/cli/train.py @@ -26,11 +26,30 @@ def train_cli( # fmt: off ctx: typer.Context, # This is only used to read additional arguments - config_path: Path = Arg(..., help="Path to config file", exists=True, allow_dash=True), - output_path: Optional[Path] = Opt(None, "--output", "--output-path", "-o", help="Output directory to store trained pipeline in"), - code_path: Optional[Path] = Opt(None, "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"), - verbose: bool = Opt(False, "--verbose", "-V", "-VV", help="Display more information for debugging purposes"), - use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU") + config_path: Path = Arg( + ..., help="Path to config file", exists=True, allow_dash=True + ), + output_path: Optional[Path] = Opt( + None, + "--output", + "--output-path", + "-o", + help="Output directory to store trained pipeline in", + ), + code_path: Optional[Path] = Opt( + None, + "--code", + "-c", + help="Path to Python file with additional code (registered functions) to be imported", + ), + verbose: bool = Opt( + False, + "--verbose", + "-V", + "-VV", + help="Display more information for debugging purposes", + ), + use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"), # fmt: on ): """ diff --git a/spacy/lang/am/lex_attrs.py b/spacy/lang/am/lex_attrs.py index 9e111b8d5eb..c7b2aab35bf 100644 --- a/spacy/lang/am/lex_attrs.py +++ b/spacy/lang/am/lex_attrs.py @@ -60,7 +60,7 @@ "አስራ ስምንተኛ", "አስራ ዘጠነኛ", "ሃያኛ", - "ሰላሳኛ" "አርባኛ", + "ሰላሳኛአርባኛ", "አምሳኛ", "ስድሳኛ", "ሰባኛ", diff --git a/spacy/lang/el/tokenizer_exceptions.py b/spacy/lang/el/tokenizer_exceptions.py index 41317ba9770..d88d4837e2a 100644 --- a/spacy/lang/el/tokenizer_exceptions.py +++ b/spacy/lang/el/tokenizer_exceptions.py @@ -128,7 +128,6 @@ _exc.update(_other_exc) for h in range(1, 12 + 1): - for period in ["π.μ.", "πμ"]: _exc[f"{h}{period}"] = [ {ORTH: f"{h}"}, diff --git a/spacy/lang/es/lemmatizer.py b/spacy/lang/es/lemmatizer.py index ee5d38e8466..05238a75b70 100644 --- a/spacy/lang/es/lemmatizer.py +++ b/spacy/lang/es/lemmatizer.py @@ -415,7 +415,10 @@ def lemmatize_verb_pron( else: rule = self.select_rule("verb", features) verb_lemma = self.lemmatize_verb( - verb, features - {"PronType=Prs"}, rule, index # type: ignore[operator] + verb, + features - {"PronType=Prs"}, + rule, + index, # type: ignore[operator] )[0] pron_lemmas = [] for pron in prons: diff --git a/spacy/lang/gd/stop_words.py b/spacy/lang/gd/stop_words.py index 9f5a66cbc24..d5132c35e31 100644 --- a/spacy/lang/gd/stop_words.py +++ b/spacy/lang/gd/stop_words.py @@ -382,7 +382,5 @@ ì ò ó -""".split( - "\n" - ) +""".split("\n") ) diff --git a/spacy/lang/gd/tokenizer_exceptions.py b/spacy/lang/gd/tokenizer_exceptions.py index 76e169d904d..b65584154cc 100644 --- a/spacy/lang/gd/tokenizer_exceptions.py +++ b/spacy/lang/gd/tokenizer_exceptions.py @@ -1974,9 +1974,7 @@ tuilleadh 's a chòir Tuilleadh 's a chòir tuilleadh sa chòir -Tuilleadh sa chòir""".split( - "\n" -): +Tuilleadh sa chòir""".split("\n"): _exc[orth] = [{ORTH: orth}] diff --git a/spacy/lang/id/tokenizer_exceptions.py b/spacy/lang/id/tokenizer_exceptions.py index 8dea4e97fd1..8e206262c10 100644 --- a/spacy/lang/id/tokenizer_exceptions.py +++ b/spacy/lang/id/tokenizer_exceptions.py @@ -156,7 +156,7 @@ "S.T.", "S.T.Han", "S.Th.", - "S.Th.I" "S.TI.", + "S.Th.IS.TI.", "S.T.P.", "S.TrK", "S.Tekp.", @@ -210,7 +210,7 @@ "hlm.", "i/o", "n.b.", - "p.p." "pjs.", + "p.p.pjs.", "s.d.", "tel.", "u.p.", diff --git a/spacy/lang/ms/examples.py b/spacy/lang/ms/examples.py index 1af439d4a5b..236e0c0f660 100644 --- a/spacy/lang/ms/examples.py +++ b/spacy/lang/ms/examples.py @@ -10,7 +10,7 @@ "Berapa banyak pelajar yang akan menghadiri majlis perpisahan sekolah?", "Pengeluaran makanan berasal dari beberapa lokasi termasuk Cameron Highlands, Johor Bahru, dan Kuching.", "Syarikat XYZ telah menghasilkan 20,000 unit produk baharu dalam setahun terakhir", - "Kuala Lumpur merupakan ibu negara Malaysia." "Kau berada di mana semalam?", + "Kuala Lumpur merupakan ibu negara Malaysia.Kau berada di mana semalam?", "Siapa yang akan memimpin projek itu?", "Siapa perdana menteri Malaysia sekarang?", ] diff --git a/spacy/lang/tokenizer_exceptions.py b/spacy/lang/tokenizer_exceptions.py index dbf9aab4912..b7d91d86f0d 100644 --- a/spacy/lang/tokenizer_exceptions.py +++ b/spacy/lang/tokenizer_exceptions.py @@ -34,11 +34,11 @@ # host & domain names # mods: match is case-sensitive, so include [A-Z] r"(?:" # noqa: E131 - r"(?:" # noqa: E131 - r"[A-Za-z0-9\u00a1-\uffff]" # noqa: E131 - r"[A-Za-z0-9\u00a1-\uffff_-]{0,62}" - r")?" - r"[A-Za-z0-9\u00a1-\uffff]\." + r"(?:" # noqa: E131 + r"[A-Za-z0-9\u00a1-\uffff]" # noqa: E131 + r"[A-Za-z0-9\u00a1-\uffff_-]{0,62}" + r")?" + r"[A-Za-z0-9\u00a1-\uffff]\." r")+" # TLD identifier # mods: use ALPHA_LOWER instead of a wider range so that this doesn't match diff --git a/spacy/lang/vi/stop_words.py b/spacy/lang/vi/stop_words.py index 1d2ecdf8d4b..3481701d5ea 100644 --- a/spacy/lang/vi/stop_words.py +++ b/spacy/lang/vi/stop_words.py @@ -1943,7 +1943,5 @@ ừ_ào ừ_ừ ử -""".split( - "\n" - ) +""".split("\n") ) diff --git a/spacy/language.py b/spacy/language.py index dcf436c65fe..ea9ba3cae8b 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -1589,9 +1589,7 @@ def pipe( # noqa: F811 if batch_size is None: batch_size = self.batch_size - pipes = ( - [] - ) # contains functools.partial objects to easily create multiprocess worker. + pipes = [] # contains functools.partial objects to easily create multiprocess worker. for name, proc in self.pipeline: if name in disable: continue @@ -1626,7 +1624,11 @@ def _has_gpu_model(self, disable: Iterable[str]): if name in disable or not is_trainable: continue - if hasattr(proc, "model") and hasattr(proc.model, "ops") and isinstance(proc.model.ops, CupyOps): # type: ignore + if ( + hasattr(proc, "model") + and hasattr(proc.model, "ops") + and isinstance(proc.model.ops, CupyOps) + ): # type: ignore return True return False diff --git a/spacy/matcher/dependencymatcher.pyi b/spacy/matcher/dependencymatcher.pyi index d84a30a58b0..3d744dfce4b 100644 --- a/spacy/matcher/dependencymatcher.pyi +++ b/spacy/matcher/dependencymatcher.pyi @@ -48,10 +48,12 @@ class DependencyMatcher: *, on_match: Optional[ Callable[[DependencyMatcher, Doc, int, List[Tuple[int, List[int]]]], Any] - ] = ... + ] = ..., ) -> None: ... def has_key(self, key: Union[str, int]) -> bool: ... - def get(self, key: Union[str, int], default: Optional[Any] = ...) -> Tuple[ + def get( + self, key: Union[str, int], default: Optional[Any] = ... + ) -> Tuple[ Optional[ Callable[[DependencyMatcher, Doc, int, List[Tuple[int, List[int]]]], Any] ], diff --git a/spacy/matcher/matcher.pyi b/spacy/matcher/matcher.pyi index c33b534cbd2..e474d250d22 100644 --- a/spacy/matcher/matcher.pyi +++ b/spacy/matcher/matcher.pyi @@ -33,7 +33,7 @@ class Matcher: on_match: Optional[ Callable[[Matcher, Doc, int, List[Tuple[Any, ...]]], Any] ] = ..., - greedy: Optional[str] = ... + greedy: Optional[str] = ..., ) -> None: ... def remove(self, key: str) -> None: ... def has_key(self, key: Union[str, int]) -> bool: ... @@ -56,7 +56,7 @@ class Matcher: *, as_spans: Literal[False] = ..., allow_missing: bool = ..., - with_alignments: bool = ... + with_alignments: bool = ..., ) -> List[Tuple[int, int, int]]: ... @overload def __call__( @@ -65,6 +65,6 @@ class Matcher: *, as_spans: Literal[True], allow_missing: bool = ..., - with_alignments: bool = ... + with_alignments: bool = ..., ) -> List[Span]: ... def _normalize_key(self, key: Any) -> Any: ... diff --git a/spacy/ml/models/entity_linker.py b/spacy/ml/models/entity_linker.py index 8b12720db20..752d1c4433c 100644 --- a/spacy/ml/models/entity_linker.py +++ b/spacy/ml/models/entity_linker.py @@ -122,7 +122,7 @@ def create_candidates() -> Callable[[KnowledgeBase, Span], Iterable[Candidate]]: return get_candidates -def create_candidates_batch() -> ( - Callable[[KnowledgeBase, Iterable[Span]], Iterable[Iterable[Candidate]]] -): +def create_candidates_batch() -> Callable[ + [KnowledgeBase, Iterable[Span]], Iterable[Iterable[Candidate]] +]: return get_candidates_batch diff --git a/spacy/ml/staticvectors.py b/spacy/ml/staticvectors.py index 122ef379544..bc69e53ab24 100644 --- a/spacy/ml/staticvectors.py +++ b/spacy/ml/staticvectors.py @@ -19,7 +19,7 @@ def StaticVectors( *, dropout: Optional[float] = None, init_W: Callable = glorot_uniform_init, - key_attr: str = "ORTH" + key_attr: str = "ORTH", ) -> Model[List[Doc], Ragged]: """Embed Doc objects with their vocab's vectors table, applying a learned linear projection to control the dimensionality. If a dropout rate is diff --git a/spacy/pipeline/attributeruler.py b/spacy/pipeline/attributeruler.py index ded48969e20..aeb0672c7c7 100644 --- a/spacy/pipeline/attributeruler.py +++ b/spacy/pipeline/attributeruler.py @@ -139,7 +139,8 @@ def match(self, doc: Doc): matches = self.matcher(doc, allow_missing=True, as_spans=False) # Sort by the attribute ID, so that later rules have precedence matches = [ - (int(self.vocab.strings[m_id]), m_id, s, e) for m_id, s, e in matches # type: ignore + (int(self.vocab.strings[m_id]), m_id, s, e) + for m_id, s, e in matches # type: ignore ] matches.sort() return matches diff --git a/spacy/tests/lang/et/test_tokenizer.py b/spacy/tests/lang/et/test_tokenizer.py index f0f8079cae8..8bee2288033 100644 --- a/spacy/tests/lang/et/test_tokenizer.py +++ b/spacy/tests/lang/et/test_tokenizer.py @@ -2,8 +2,7 @@ ET_BASIC_TOKENIZATION_TESTS = [ ( - "Kedagi ei või piinata ega ebainimlikult või alandavalt kohelda " - "ega karistada.", + "Kedagi ei või piinata ega ebainimlikult või alandavalt kohelda ega karistada.", [ "Kedagi", "ei", diff --git a/spacy/tests/package/test_requirements.py b/spacy/tests/package/test_requirements.py index e7df02e9769..b9276441222 100644 --- a/spacy/tests/package/test_requirements.py +++ b/spacy/tests/package/test_requirements.py @@ -59,9 +59,9 @@ def test_build_dependencies(): lib, v = _parse_req(line) if lib and not lib.startswith("cupy") and lib not in libs_ignore_setup: req_v = req_dict.get(lib, None) - assert ( - req_v is not None - ), "{} in setup.cfg but not in requirements.txt".format(lib) + assert req_v is not None, ( + "{} in setup.cfg but not in requirements.txt".format(lib) + ) assert (lib + v) == (lib + req_v), ( "{} has different version in setup.cfg and in requirements.txt: " "{} and {} respectively".format(lib, v, req_v) diff --git a/spacy/tests/pipeline/test_entity_linker.py b/spacy/tests/pipeline/test_entity_linker.py index 1b6f49f4cde..5e50a4d2801 100644 --- a/spacy/tests/pipeline/test_entity_linker.py +++ b/spacy/tests/pipeline/test_entity_linker.py @@ -496,15 +496,15 @@ def get_lowercased_candidates_batch(kb, spans): return [get_lowercased_candidates(kb, span) for span in spans] @registry.misc("spacy.LowercaseCandidateGenerator.v1") - def create_candidates() -> ( - Callable[[InMemoryLookupKB, "Span"], Iterable[Candidate]] - ): + def create_candidates() -> Callable[ + [InMemoryLookupKB, "Span"], Iterable[Candidate] + ]: return get_lowercased_candidates @registry.misc("spacy.LowercaseCandidateBatchGenerator.v1") - def create_candidates_batch() -> ( - Callable[[InMemoryLookupKB, Iterable["Span"]], Iterable[Iterable[Candidate]]] - ): + def create_candidates_batch() -> Callable[ + [InMemoryLookupKB, Iterable["Span"]], Iterable[Iterable[Candidate]] + ]: return get_lowercased_candidates_batch # replace the pipe with a new one with with a different candidate generator diff --git a/spacy/tests/pipeline/test_sentencizer.py b/spacy/tests/pipeline/test_sentencizer.py index 9b1ddd53012..826086fc7fe 100644 --- a/spacy/tests/pipeline/test_sentencizer.py +++ b/spacy/tests/pipeline/test_sentencizer.py @@ -135,14 +135,38 @@ def test_sentencizer_serialize_bytes(en_vocab): # fmt: off "lang,text", [ - ('bn', 'বাংলা ভাষা (বাঙলা, বাঙ্গলা, তথা বাঙ্গালা নামগুলোতেও পরিচিত) একটি ইন্দো-আর্য ভাষা, যা দক্ষিণ এশিয়ার বাঙালি জাতির প্রধান কথ্য ও লেখ্য ভাষা। মাতৃভাষীর সংখ্যায় বাংলা ইন্দো-ইউরোপীয় ভাষা পরিবারের চতুর্থ ও বিশ্বের ষষ্ঠ বৃহত্তম ভাষা।[৫] মোট ব্যবহারকারীর সংখ্যা অনুসারে বাংলা বিশ্বের সপ্তম বৃহত্তম ভাষা। বাংলা সার্বভৌম ভাষাভিত্তিক জাতিরাষ্ট্র বাংলাদেশের একমাত্র রাষ্ট্রভাষা তথা সরকারি ভাষা[৬] এবং ভারতের পশ্চিমবঙ্গ, ত্রিপুরা, আসামের বরাক উপত্যকার সরকারি ভাষা। বঙ্গোপসাগরে অবস্থিত আন্দামান দ্বীপপুঞ্জের প্রধান কথ্য ভাষা বাংলা। এছাড়া ভারতের ঝাড়খণ্ড, বিহার, মেঘালয়, মিজোরাম, উড়িষ্যা রাজ্যগুলোতে উল্লেখযোগ্য পরিমাণে বাংলাভাষী জনগণ রয়েছে। ভারতে হিন্দির পরেই সর্বাধিক প্রচলিত ভাষা বাংলা।[৭][৮] এছাড়াও মধ্য প্রাচ্য, আমেরিকা ও ইউরোপে উল্লেখযোগ্য পরিমাণে বাংলাভাষী অভিবাসী রয়েছে।[৯] সারা বিশ্বে সব মিলিয়ে ২৬ কোটির অধিক লোক দৈনন্দিন জীবনে বাংলা ব্যবহার করে।[২] বাংলাদেশের জাতীয় সঙ্গীত এবং ভারতের জাতীয় সঙ্গীত ও স্তোত্র বাংলাতে রচিত।'), - ('de', 'Die deutsche Sprache bzw. Deutsch ([dɔʏ̯t͡ʃ]; abgekürzt dt. oder dtsch.) ist eine westgermanische Sprache. Ihr Sprachraum umfasst Deutschland, Österreich, die Deutschschweiz, Liechtenstein, Luxemburg, Ostbelgien, Südtirol, das Elsass und Lothringen sowie Nordschleswig. Außerdem ist sie eine Minderheitensprache in einigen europäischen und außereuropäischen Ländern, z. B. in Rumänien und Südafrika, sowie Nationalsprache im afrikanischen Namibia.'), - ('hi', 'हिन्दी विश्व की एक प्रमुख भाषा है एवं भारत की राजभाषा है। केन्द्रीय स्तर पर भारत में दूसरी आधिकारिक भाषा अंग्रेजी है। यह हिंदुस्तानी भाषा की एक मानकीकृत रूप है जिसमें संस्कृत के तत्सम तथा तद्भव शब्दों का प्रयोग अधिक है और अरबी-फ़ारसी शब्द कम हैं। हिंदी संवैधानिक रूप से भारत की राजभाषा और भारत की सबसे अधिक बोली और समझी जाने वाली भाषा है। हालाँकि, हिन्दी भारत की राष्ट्रभाषा नहीं है,[3] क्योंकि भारत के संविधान में कोई भी भाषा को ऐसा दर्जा नहीं दिया गया था।[4][5] चीनी के बाद यह विश्व में सबसे अधिक बोली जाने वाली भाषा भी है। विश्व आर्थिक मंच की गणना के अनुसार यह विश्व की दस शक्तिशाली भाषाओं में से एक है।[6]'), - ('kn', 'ದ್ರಾವಿಡ ಭಾಷೆಗಳಲ್ಲಿ ಪ್ರಾಮುಖ್ಯವುಳ್ಳ ಭಾಷೆಯೂ ಭಾರತದ ಪುರಾತನವಾದ ಭಾಷೆಗಳಲ್ಲಿ ಒಂದೂ ಆಗಿರುವ ಕನ್ನಡ ಭಾಷೆಯನ್ನು ಅದರ ವಿವಿಧ ರೂಪಗಳಲ್ಲಿ ಸುಮಾರು ೪೫ ದಶಲಕ್ಷ ಜನರು ಆಡು ನುಡಿಯಾಗಿ ಬಳಸುತ್ತಲಿದ್ದಾರೆ. ಕನ್ನಡ ಕರ್ನಾಟಕ ರಾಜ್ಯದ ಆಡಳಿತ ಭಾಷೆ.[೧೧] ಜಗತ್ತಿನಲ್ಲಿ ಅತ್ಯಂತ ಹೆಚ್ಚು ಮಂದಿ ಮಾತನಾಡುವ ಭಾಷೆಯೆಂಬ ನೆಲೆಯಲ್ಲಿ ಇಪ್ಪತೊಂಬತ್ತನೆಯ ಸ್ಥಾನ ಕನ್ನಡಕ್ಕಿದೆ. ೨೦೧೧ರ ಜನಗಣತಿಯ ಪ್ರಕಾರ ಜಗತ್ತಿನಲ್ಲಿ ೬.೪ ಕೋಟಿ ಜನಗಳು ಕನ್ನಡ ಮಾತನಾಡುತ್ತಾರೆ ಎಂದು ತಿಳಿದುಬಂದಿದೆ. ಇವರಲ್ಲಿ ೫.೫ ಕೋಟಿ ಜನಗಳ ಮಾತೃಭಾಷೆ ಕನ್ನಡವಾಗಿದೆ. ಬ್ರಾಹ್ಮಿ ಲಿಪಿಯಿಂದ ರೂಪುಗೊಂಡ ಕನ್ನಡ ಲಿಪಿಯನ್ನು ಉಪಯೋಗಿಸಿ ಕನ್ನಡ ಭಾಷೆಯನ್ನು ಬರೆಯಲಾಗುತ್ತದೆ. ಕನ್ನಡ ಬರಹದ ಮಾದರಿಗಳಿಗೆ ಸಾವಿರದ ಐನೂರು ವರುಷಗಳ ಚರಿತ್ರೆಯಿದೆ. ಕ್ರಿ.ಶ. ಆರನೆಯ ಶತಮಾನದ ಪಶ್ಚಿಮ ಗಂಗ ಸಾಮ್ರಾಜ್ಯದ ಕಾಲದಲ್ಲಿ [೧೨] ಮತ್ತು ಒಂಬತ್ತನೆಯ ಶತಮಾನದ ರಾಷ್ಟ್ರಕೂಟ ಸಾಮ್ರಾಜ್ಯದ ಕಾಲದಲ್ಲಿ ಹಳಗನ್ನಡ ಸಾಹಿತ್ಯ ಅತ್ಯಂತ ಹೆಚ್ಚಿನ ರಾಜಾಶ್ರಯ ಪಡೆಯಿತು.[೧೩][೧೪] ಅದಲ್ಲದೆ ಸಾವಿರ ವರುಷಗಳ ಸಾಹಿತ್ಯ ಪರಂಪರೆ ಕನ್ನಡಕ್ಕಿದೆ.[೧೫]ವಿನೋಬಾ ಭಾವೆ ಕನ್ನಡ ಲಿಪಿಯನ್ನು ಲಿಪಿಗಳ ರಾಣಿಯೆಂದು ಹೊಗಳಿದ್ದಾರೆ.[ಸೂಕ್ತ ಉಲ್ಲೇಖನ ಬೇಕು]'), - ('si', 'ශ්‍රී ලංකාවේ ප්‍රධාන ජාතිය වන සිංහල ජනයාගේ මව් බස සිංහල වෙයි. අද වන විට මිලියන 20 කට අධික සිංහල සහ මිලියන 3කට අධික සිංහල නොවන ජනගහනයක් සිංහල භාෂාව භාවිත කරති. සිංහල‍ ඉන්දු-යුරෝපීය භාෂාවල උප ගණයක් වන ඉන්දු-ආර්ය භාෂා ගණයට අයිති වන අතර මාල දිවයින භාවිත කරන දිවෙහි භාෂාව සිංහලයෙන් පැවත එන්නකි. සිංහල ශ්‍රී ලංකාවේ නිල භාෂාවයි .'), - ('ta', 'தமிழ் மொழி (Tamil language) தமிழர்களினதும், தமிழ் பேசும் பலரதும் தாய்மொழி ஆகும். தமிழ் திராவிட மொழிக் குடும்பத்தின் முதன்மையான மொழிகளில் ஒன்றும் செம்மொழியும் ஆகும். இந்தியா, இலங்கை, மலேசியா, சிங்கப்பூர் ஆகிய நாடுகளில் அதிக அளவிலும், ஐக்கிய அரபு அமீரகம், தென்னாப்பிரிக்கா, மொரிசியசு, பிஜி, ரீயூனியன், டிரினிடாட் போன்ற நாடுகளில் சிறிய அளவிலும் தமிழ் பேசப்படுகிறது. 1997ஆம் ஆண்டுப் புள்ளி விவரப்படி உலகம் முழுவதிலும் 8 கோடி (80 மில்லியன்) மக்களால் பேசப்படும் தமிழ்[13], ஒரு மொழியைத் தாய்மொழியாகக் கொண்டு பேசும் மக்களின் எண்ணிக்கை அடிப்படையில் பதினெட்டாவது இடத்தில் உள்ளது.[14] இணையத்தில் அதிகம் பயன்படுத்தப்படும் இந்திய மொழிகளில் தமிழ் முதன்மையாக உள்ளதாக 2017 ஆவது ஆண்டில் நடைபெற்ற கூகுள் கணக்கெடுப்பில் தெரிய வந்தது.[15]'), - ('te', 'ఆంధ్ర ప్రదేశ్, తెలంగాణ రాష్ట్రాల అధికార భాష తెలుగు. భారత దేశంలో తెలుగు మాతృభాషగా మాట్లాడే 8.7 కోట్ల (2001) జనాభాతో [1] ప్రాంతీయ భాషలలో మొదటి స్థానంలో ఉంది. ప్రపంచంలోని ప్రజలు అత్యధికముగా మాట్లాడే భాషలలో 15 స్థానములోనూ, భారత దేశములో హిందీ, తర్వాత స్థానములోనూ నిలుస్తుంది. పాతవైన ప్రపంచ భాష గణాంకాల (ఎథ్నోలాగ్) ప్రకారం ప్రపంచవ్యాప్తంగా 7.4 కోట్లు మందికి మాతృభాషగా ఉంది.[2] మొదటి భాషగా మాట్లాడతారు. అతి ప్రాచీన దేశ భాషలలో సంస్కృతము తమిళముతో బాటు తెలుగు భాషను 2008 అక్టోబరు 31న భారత ప్రభుత్వము గుర్తించింది.'), - ('ur', 'اُردُو لشکری زبان[8] (یا جدید معیاری اردو) برصغیر کی معیاری زبانوں میں سے ایک ہے۔ یہ پاکستان کی قومی اور رابطہ عامہ کی زبان ہے، جبکہ بھارت کی چھے ریاستوں کی دفتری زبان کا درجہ رکھتی ہے۔ آئین ہند کے مطابق اسے 22 دفتری شناخت زبانوں میں شامل کیا جاچکا ہے۔ 2001ء کی مردم شماری کے مطابق اردو کو بطور مادری زبان بھارت میں 5.01% فیصد لوگ بولتے ہیں اور اس لحاظ سے یہ بھارت کی چھٹی بڑی زبان ہے جبکہ پاکستان میں اسے بطور مادری زبان 7.59% فیصد لوگ استعمال کرتے ہیں، یہ پاکستان کی پانچویں بڑی زبان ہے۔ اردو تاریخی طور پر ہندوستان کی مسلم آبادی سے جڑی ہے۔[حوالہ درکار] بعض ذخیرہ الفاظ کے علاوہ یہ زبان معیاری ہندی سے قابل فہم ہے جو اس خطے کی ہندوؤں سے منسوب ہے۔[حوالہ درکار] زبانِ اردو کو پہچان و ترقی اس وقت ملی جب برطانوی دور میں انگریز حکمرانوں نے اسے فارسی کی بجائے انگریزی کے ساتھ شمالی ہندوستان کے علاقوں اور جموں و کشمیر میں اسے سنہ 1846ء اور پنجاب میں سنہ 1849ء میں بطور دفتری زبان نافذ کیا۔ اس کے علاوہ خلیجی، یورپی، ایشیائی اور امریکی علاقوں میں اردو بولنے والوں کی ایک بڑی تعداد آباد ہے جو بنیادی طور پر جنوبی ایشیاء سے کوچ کرنے والے اہلِ اردو ہیں۔ 1999ء کے اعداد وشمار کے مطابق اردو زبان کے مجموعی متکلمین کی تعداد دس کروڑ ساٹھ لاکھ کے لگ بھگ تھی۔ اس لحاظ سے یہ دنیا کی نویں بڑی زبان ہے۔'), + ( + "bn", + "বাংলা ভাষা (বাঙলা, বাঙ্গলা, তথা বাঙ্গালা নামগুলোতেও পরিচিত) একটি ইন্দো-আর্য ভাষা, যা দক্ষিণ এশিয়ার বাঙালি জাতির প্রধান কথ্য ও লেখ্য ভাষা। মাতৃভাষীর সংখ্যায় বাংলা ইন্দো-ইউরোপীয় ভাষা পরিবারের চতুর্থ ও বিশ্বের ষষ্ঠ বৃহত্তম ভাষা।[৫] মোট ব্যবহারকারীর সংখ্যা অনুসারে বাংলা বিশ্বের সপ্তম বৃহত্তম ভাষা। বাংলা সার্বভৌম ভাষাভিত্তিক জাতিরাষ্ট্র বাংলাদেশের একমাত্র রাষ্ট্রভাষা তথা সরকারি ভাষা[৬] এবং ভারতের পশ্চিমবঙ্গ, ত্রিপুরা, আসামের বরাক উপত্যকার সরকারি ভাষা। বঙ্গোপসাগরে অবস্থিত আন্দামান দ্বীপপুঞ্জের প্রধান কথ্য ভাষা বাংলা। এছাড়া ভারতের ঝাড়খণ্ড, বিহার, মেঘালয়, মিজোরাম, উড়িষ্যা রাজ্যগুলোতে উল্লেখযোগ্য পরিমাণে বাংলাভাষী জনগণ রয়েছে। ভারতে হিন্দির পরেই সর্বাধিক প্রচলিত ভাষা বাংলা।[৭][৮] এছাড়াও মধ্য প্রাচ্য, আমেরিকা ও ইউরোপে উল্লেখযোগ্য পরিমাণে বাংলাভাষী অভিবাসী রয়েছে।[৯] সারা বিশ্বে সব মিলিয়ে ২৬ কোটির অধিক লোক দৈনন্দিন জীবনে বাংলা ব্যবহার করে।[২] বাংলাদেশের জাতীয় সঙ্গীত এবং ভারতের জাতীয় সঙ্গীত ও স্তোত্র বাংলাতে রচিত।", + ), + ( + "de", + "Die deutsche Sprache bzw. Deutsch ([dɔʏ̯t͡ʃ]; abgekürzt dt. oder dtsch.) ist eine westgermanische Sprache. Ihr Sprachraum umfasst Deutschland, Österreich, die Deutschschweiz, Liechtenstein, Luxemburg, Ostbelgien, Südtirol, das Elsass und Lothringen sowie Nordschleswig. Außerdem ist sie eine Minderheitensprache in einigen europäischen und außereuropäischen Ländern, z. B. in Rumänien und Südafrika, sowie Nationalsprache im afrikanischen Namibia.", + ), + ( + "hi", + "हिन्दी विश्व की एक प्रमुख भाषा है एवं भारत की राजभाषा है। केन्द्रीय स्तर पर भारत में दूसरी आधिकारिक भाषा अंग्रेजी है। यह हिंदुस्तानी भाषा की एक मानकीकृत रूप है जिसमें संस्कृत के तत्सम तथा तद्भव शब्दों का प्रयोग अधिक है और अरबी-फ़ारसी शब्द कम हैं। हिंदी संवैधानिक रूप से भारत की राजभाषा और भारत की सबसे अधिक बोली और समझी जाने वाली भाषा है। हालाँकि, हिन्दी भारत की राष्ट्रभाषा नहीं है,[3] क्योंकि भारत के संविधान में कोई भी भाषा को ऐसा दर्जा नहीं दिया गया था।[4][5] चीनी के बाद यह विश्व में सबसे अधिक बोली जाने वाली भाषा भी है। विश्व आर्थिक मंच की गणना के अनुसार यह विश्व की दस शक्तिशाली भाषाओं में से एक है।[6]", + ), + ( + "kn", + "ದ್ರಾವಿಡ ಭಾಷೆಗಳಲ್ಲಿ ಪ್ರಾಮುಖ್ಯವುಳ್ಳ ಭಾಷೆಯೂ ಭಾರತದ ಪುರಾತನವಾದ ಭಾಷೆಗಳಲ್ಲಿ ಒಂದೂ ಆಗಿರುವ ಕನ್ನಡ ಭಾಷೆಯನ್ನು ಅದರ ವಿವಿಧ ರೂಪಗಳಲ್ಲಿ ಸುಮಾರು ೪೫ ದಶಲಕ್ಷ ಜನರು ಆಡು ನುಡಿಯಾಗಿ ಬಳಸುತ್ತಲಿದ್ದಾರೆ. ಕನ್ನಡ ಕರ್ನಾಟಕ ರಾಜ್ಯದ ಆಡಳಿತ ಭಾಷೆ.[೧೧] ಜಗತ್ತಿನಲ್ಲಿ ಅತ್ಯಂತ ಹೆಚ್ಚು ಮಂದಿ ಮಾತನಾಡುವ ಭಾಷೆಯೆಂಬ ನೆಲೆಯಲ್ಲಿ ಇಪ್ಪತೊಂಬತ್ತನೆಯ ಸ್ಥಾನ ಕನ್ನಡಕ್ಕಿದೆ. ೨೦೧೧ರ ಜನಗಣತಿಯ ಪ್ರಕಾರ ಜಗತ್ತಿನಲ್ಲಿ ೬.೪ ಕೋಟಿ ಜನಗಳು ಕನ್ನಡ ಮಾತನಾಡುತ್ತಾರೆ ಎಂದು ತಿಳಿದುಬಂದಿದೆ. ಇವರಲ್ಲಿ ೫.೫ ಕೋಟಿ ಜನಗಳ ಮಾತೃಭಾಷೆ ಕನ್ನಡವಾಗಿದೆ. ಬ್ರಾಹ್ಮಿ ಲಿಪಿಯಿಂದ ರೂಪುಗೊಂಡ ಕನ್ನಡ ಲಿಪಿಯನ್ನು ಉಪಯೋಗಿಸಿ ಕನ್ನಡ ಭಾಷೆಯನ್ನು ಬರೆಯಲಾಗುತ್ತದೆ. ಕನ್ನಡ ಬರಹದ ಮಾದರಿಗಳಿಗೆ ಸಾವಿರದ ಐನೂರು ವರುಷಗಳ ಚರಿತ್ರೆಯಿದೆ. ಕ್ರಿ.ಶ. ಆರನೆಯ ಶತಮಾನದ ಪಶ್ಚಿಮ ಗಂಗ ಸಾಮ್ರಾಜ್ಯದ ಕಾಲದಲ್ಲಿ [೧೨] ಮತ್ತು ಒಂಬತ್ತನೆಯ ಶತಮಾನದ ರಾಷ್ಟ್ರಕೂಟ ಸಾಮ್ರಾಜ್ಯದ ಕಾಲದಲ್ಲಿ ಹಳಗನ್ನಡ ಸಾಹಿತ್ಯ ಅತ್ಯಂತ ಹೆಚ್ಚಿನ ರಾಜಾಶ್ರಯ ಪಡೆಯಿತು.[೧೩][೧೪] ಅದಲ್ಲದೆ ಸಾವಿರ ವರುಷಗಳ ಸಾಹಿತ್ಯ ಪರಂಪರೆ ಕನ್ನಡಕ್ಕಿದೆ.[೧೫]ವಿನೋಬಾ ಭಾವೆ ಕನ್ನಡ ಲಿಪಿಯನ್ನು ಲಿಪಿಗಳ ರಾಣಿಯೆಂದು ಹೊಗಳಿದ್ದಾರೆ.[ಸೂಕ್ತ ಉಲ್ಲೇಖನ ಬೇಕು]", + ), + ( + "si", + "ශ්‍රී ලංකාවේ ප්‍රධාන ජාතිය වන සිංහල ජනයාගේ මව් බස සිංහල වෙයි. අද වන විට මිලියන 20 කට අධික සිංහල සහ මිලියන 3කට අධික සිංහල නොවන ජනගහනයක් සිංහල භාෂාව භාවිත කරති. සිංහල‍ ඉන්දු-යුරෝපීය භාෂාවල උප ගණයක් වන ඉන්දු-ආර්ය භාෂා ගණයට අයිති වන අතර මාල දිවයින භාවිත කරන දිවෙහි භාෂාව සිංහලයෙන් පැවත එන්නකි. සිංහල ශ්‍රී ලංකාවේ නිල භාෂාවයි .", + ), + ( + "ta", + "தமிழ் மொழி (Tamil language) தமிழர்களினதும், தமிழ் பேசும் பலரதும் தாய்மொழி ஆகும். தமிழ் திராவிட மொழிக் குடும்பத்தின் முதன்மையான மொழிகளில் ஒன்றும் செம்மொழியும் ஆகும். இந்தியா, இலங்கை, மலேசியா, சிங்கப்பூர் ஆகிய நாடுகளில் அதிக அளவிலும், ஐக்கிய அரபு அமீரகம், தென்னாப்பிரிக்கா, மொரிசியசு, பிஜி, ரீயூனியன், டிரினிடாட் போன்ற நாடுகளில் சிறிய அளவிலும் தமிழ் பேசப்படுகிறது. 1997ஆம் ஆண்டுப் புள்ளி விவரப்படி உலகம் முழுவதிலும் 8 கோடி (80 மில்லியன்) மக்களால் பேசப்படும் தமிழ்[13], ஒரு மொழியைத் தாய்மொழியாகக் கொண்டு பேசும் மக்களின் எண்ணிக்கை அடிப்படையில் பதினெட்டாவது இடத்தில் உள்ளது.[14] இணையத்தில் அதிகம் பயன்படுத்தப்படும் இந்திய மொழிகளில் தமிழ் முதன்மையாக உள்ளதாக 2017 ஆவது ஆண்டில் நடைபெற்ற கூகுள் கணக்கெடுப்பில் தெரிய வந்தது.[15]", + ), + ( + "te", + "ఆంధ్ర ప్రదేశ్, తెలంగాణ రాష్ట్రాల అధికార భాష తెలుగు. భారత దేశంలో తెలుగు మాతృభాషగా మాట్లాడే 8.7 కోట్ల (2001) జనాభాతో [1] ప్రాంతీయ భాషలలో మొదటి స్థానంలో ఉంది. ప్రపంచంలోని ప్రజలు అత్యధికముగా మాట్లాడే భాషలలో 15 స్థానములోనూ, భారత దేశములో హిందీ, తర్వాత స్థానములోనూ నిలుస్తుంది. పాతవైన ప్రపంచ భాష గణాంకాల (ఎథ్నోలాగ్) ప్రకారం ప్రపంచవ్యాప్తంగా 7.4 కోట్లు మందికి మాతృభాషగా ఉంది.[2] మొదటి భాషగా మాట్లాడతారు. అతి ప్రాచీన దేశ భాషలలో సంస్కృతము తమిళముతో బాటు తెలుగు భాషను 2008 అక్టోబరు 31న భారత ప్రభుత్వము గుర్తించింది.", + ), + ( + "ur", + "اُردُو لشکری زبان[8] (یا جدید معیاری اردو) برصغیر کی معیاری زبانوں میں سے ایک ہے۔ یہ پاکستان کی قومی اور رابطہ عامہ کی زبان ہے، جبکہ بھارت کی چھے ریاستوں کی دفتری زبان کا درجہ رکھتی ہے۔ آئین ہند کے مطابق اسے 22 دفتری شناخت زبانوں میں شامل کیا جاچکا ہے۔ 2001ء کی مردم شماری کے مطابق اردو کو بطور مادری زبان بھارت میں 5.01% فیصد لوگ بولتے ہیں اور اس لحاظ سے یہ بھارت کی چھٹی بڑی زبان ہے جبکہ پاکستان میں اسے بطور مادری زبان 7.59% فیصد لوگ استعمال کرتے ہیں، یہ پاکستان کی پانچویں بڑی زبان ہے۔ اردو تاریخی طور پر ہندوستان کی مسلم آبادی سے جڑی ہے۔[حوالہ درکار] بعض ذخیرہ الفاظ کے علاوہ یہ زبان معیاری ہندی سے قابل فہم ہے جو اس خطے کی ہندوؤں سے منسوب ہے۔[حوالہ درکار] زبانِ اردو کو پہچان و ترقی اس وقت ملی جب برطانوی دور میں انگریز حکمرانوں نے اسے فارسی کی بجائے انگریزی کے ساتھ شمالی ہندوستان کے علاقوں اور جموں و کشمیر میں اسے سنہ 1846ء اور پنجاب میں سنہ 1849ء میں بطور دفتری زبان نافذ کیا۔ اس کے علاوہ خلیجی، یورپی، ایشیائی اور امریکی علاقوں میں اردو بولنے والوں کی ایک بڑی تعداد آباد ہے جو بنیادی طور پر جنوبی ایشیاء سے کوچ کرنے والے اہلِ اردو ہیں۔ 1999ء کے اعداد وشمار کے مطابق اردو زبان کے مجموعی متکلمین کی تعداد دس کروڑ ساٹھ لاکھ کے لگ بھگ تھی۔ اس لحاظ سے یہ دنیا کی نویں بڑی زبان ہے۔", + ), ], # fmt: on ) diff --git a/spacy/tests/pipeline/test_tok2vec.py b/spacy/tests/pipeline/test_tok2vec.py index 998f0472c7e..ddd9a990c65 100644 --- a/spacy/tests/pipeline/test_tok2vec.py +++ b/spacy/tests/pipeline/test_tok2vec.py @@ -65,10 +65,30 @@ def test_tok2vec_batch_sizes(batch_size, width, embed_size): "embed_arch,embed_config", # fmt: off [ - ("spacy.MultiHashEmbed.v1", {"rows": [100, 100], "attrs": ["SHAPE", "LOWER"], "include_static_vectors": False}), - ("spacy.MultiHashEmbed.v1", {"rows": [100, 20], "attrs": ["ORTH", "PREFIX"], "include_static_vectors": False}), - ("spacy.CharacterEmbed.v1", {"rows": 100, "nM": 64, "nC": 8, "include_static_vectors": False}), - ("spacy.CharacterEmbed.v1", {"rows": 100, "nM": 16, "nC": 2, "include_static_vectors": False}), + ( + "spacy.MultiHashEmbed.v1", + { + "rows": [100, 100], + "attrs": ["SHAPE", "LOWER"], + "include_static_vectors": False, + }, + ), + ( + "spacy.MultiHashEmbed.v1", + { + "rows": [100, 20], + "attrs": ["ORTH", "PREFIX"], + "include_static_vectors": False, + }, + ), + ( + "spacy.CharacterEmbed.v1", + {"rows": 100, "nM": 64, "nC": 8, "include_static_vectors": False}, + ), + ( + "spacy.CharacterEmbed.v1", + {"rows": 100, "nM": 16, "nC": 2, "include_static_vectors": False}, + ), ], # fmt: on ) @@ -76,10 +96,26 @@ def test_tok2vec_batch_sizes(batch_size, width, embed_size): "tok2vec_arch,encode_arch,encode_config", # fmt: off [ - ("spacy.Tok2Vec.v1", "spacy.MaxoutWindowEncoder.v1", {"window_size": 1, "maxout_pieces": 3, "depth": 2}), - ("spacy.Tok2Vec.v2", "spacy.MaxoutWindowEncoder.v2", {"window_size": 1, "maxout_pieces": 3, "depth": 2}), - ("spacy.Tok2Vec.v1", "spacy.MishWindowEncoder.v1", {"window_size": 1, "depth": 6}), - ("spacy.Tok2Vec.v2", "spacy.MishWindowEncoder.v2", {"window_size": 1, "depth": 6}), + ( + "spacy.Tok2Vec.v1", + "spacy.MaxoutWindowEncoder.v1", + {"window_size": 1, "maxout_pieces": 3, "depth": 2}, + ), + ( + "spacy.Tok2Vec.v2", + "spacy.MaxoutWindowEncoder.v2", + {"window_size": 1, "maxout_pieces": 3, "depth": 2}, + ), + ( + "spacy.Tok2Vec.v1", + "spacy.MishWindowEncoder.v1", + {"window_size": 1, "depth": 6}, + ), + ( + "spacy.Tok2Vec.v2", + "spacy.MishWindowEncoder.v2", + {"window_size": 1, "depth": 6}, + ), ], # fmt: on ) @@ -164,9 +200,9 @@ def test_init_tok2vec(): @pytest.mark.parametrize("with_vectors", (False, True)) def test_tok2vec_listener(with_vectors): orig_config = Config().from_str(cfg_string) - orig_config["components"]["tok2vec"]["model"]["embed"][ - "include_static_vectors" - ] = with_vectors + orig_config["components"]["tok2vec"]["model"]["embed"]["include_static_vectors"] = ( + with_vectors + ) nlp = util.load_model_from_config(orig_config, auto_fill=True, validate=True) if with_vectors: diff --git a/spacy/tests/test_cli.py b/spacy/tests/test_cli.py index 43d5f62837a..8415e5c92ff 100644 --- a/spacy/tests/test_cli.py +++ b/spacy/tests/test_cli.py @@ -153,21 +153,171 @@ def test_issue12566(factory: str, output_file: str): "Briana McNaira - Cultural Chaos .", "tokens": [ # fmt: off - {"id": 0, "start": 0, "end": 8, "tag": "ADV", "pos": "ADV", "morph": "Degree=Pos", "lemma": "niedawno", "dep": "advmod", "head": 1, }, - {"id": 1, "start": 9, "end": 15, "tag": "PRAET", "pos": "VERB", "morph": "Animacy=Hum|Aspect=Imp|Gender=Masc|Mood=Ind|Number=Sing|Tense=Past|VerbForm=Fin|Voice=Act", "lemma": "czytać", "dep": "ROOT", "head": 1, }, - {"id": 2, "start": 16, "end": 18, "tag": "AGLT", "pos": "NOUN", "morph": "Animacy=Inan|Case=Ins|Gender=Masc|Number=Sing", "lemma": "em", "dep": "iobj", "head": 1, }, - {"id": 3, "start": 19, "end": 23, "tag": "ADJ", "pos": "ADJ", "morph": "Case=Acc|Degree=Pos|Gender=Fem|Number=Sing", "lemma": "nowy", "dep": "amod", "head": 4, }, - {"id": 4, "start": 24, "end": 31, "tag": "SUBST", "pos": "NOUN", "morph": "Case=Acc|Gender=Fem|Number=Sing", "lemma": "książka", "dep": "obj", "head": 1, }, - {"id": 5, "start": 32, "end": 43, "tag": "ADJ", "pos": "ADJ", "morph": "Animacy=Nhum|Case=Gen|Degree=Pos|Gender=Masc|Number=Sing", "lemma": "znakomit", "dep": "acl", "head": 4, }, - {"id": 6, "start": 44, "end": 54, "tag": "ADJ", "pos": "ADJ", "morph": "Animacy=Hum|Case=Gen|Degree=Pos|Gender=Masc|Number=Sing", "lemma": "szkockiy", "dep": "amod", "head": 7, }, - {"id": 7, "start": 55, "end": 66, "tag": "SUBST", "pos": "NOUN", "morph": "Animacy=Hum|Case=Gen|Gender=Masc|Number=Sing", "lemma": "medioznawca", "dep": "iobj", "head": 5, }, - {"id": 8, "start": 67, "end": 68, "tag": "INTERP", "pos": "PUNCT", "morph": "PunctType=Comm", "lemma": ",", "dep": "punct", "head": 9, }, - {"id": 9, "start": 69, "end": 75, "tag": "SUBST", "pos": "PROPN", "morph": "Animacy=Hum|Case=Gen|Gender=Masc|Number=Sing", "lemma": "Brian", "dep": "nmod", "head": 4, }, - {"id": 10, "start": 76, "end": 83, "tag": "SUBST", "pos": "PROPN", "morph": "Animacy=Hum|Case=Gen|Gender=Masc|Number=Sing", "lemma": "McNair", "dep": "flat", "head": 9, }, - {"id": 11, "start": 84, "end": 85, "tag": "INTERP", "pos": "PUNCT", "morph": "PunctType=Dash", "lemma": "-", "dep": "punct", "head": 12, }, - {"id": 12, "start": 86, "end": 94, "tag": "SUBST", "pos": "PROPN", "morph": "Animacy=Inan|Case=Nom|Gender=Masc|Number=Sing", "lemma": "Cultural", "dep": "conj", "head": 4, }, - {"id": 13, "start": 95, "end": 100, "tag": "SUBST", "pos": "NOUN", "morph": "Animacy=Inan|Case=Nom|Gender=Masc|Number=Sing", "lemma": "Chaos", "dep": "flat", "head": 12, }, - {"id": 14, "start": 101, "end": 102, "tag": "INTERP", "pos": "PUNCT", "morph": "PunctType=Peri", "lemma": ".", "dep": "punct", "head": 1, }, + { + "id": 0, + "start": 0, + "end": 8, + "tag": "ADV", + "pos": "ADV", + "morph": "Degree=Pos", + "lemma": "niedawno", + "dep": "advmod", + "head": 1, + }, + { + "id": 1, + "start": 9, + "end": 15, + "tag": "PRAET", + "pos": "VERB", + "morph": "Animacy=Hum|Aspect=Imp|Gender=Masc|Mood=Ind|Number=Sing|Tense=Past|VerbForm=Fin|Voice=Act", + "lemma": "czytać", + "dep": "ROOT", + "head": 1, + }, + { + "id": 2, + "start": 16, + "end": 18, + "tag": "AGLT", + "pos": "NOUN", + "morph": "Animacy=Inan|Case=Ins|Gender=Masc|Number=Sing", + "lemma": "em", + "dep": "iobj", + "head": 1, + }, + { + "id": 3, + "start": 19, + "end": 23, + "tag": "ADJ", + "pos": "ADJ", + "morph": "Case=Acc|Degree=Pos|Gender=Fem|Number=Sing", + "lemma": "nowy", + "dep": "amod", + "head": 4, + }, + { + "id": 4, + "start": 24, + "end": 31, + "tag": "SUBST", + "pos": "NOUN", + "morph": "Case=Acc|Gender=Fem|Number=Sing", + "lemma": "książka", + "dep": "obj", + "head": 1, + }, + { + "id": 5, + "start": 32, + "end": 43, + "tag": "ADJ", + "pos": "ADJ", + "morph": "Animacy=Nhum|Case=Gen|Degree=Pos|Gender=Masc|Number=Sing", + "lemma": "znakomit", + "dep": "acl", + "head": 4, + }, + { + "id": 6, + "start": 44, + "end": 54, + "tag": "ADJ", + "pos": "ADJ", + "morph": "Animacy=Hum|Case=Gen|Degree=Pos|Gender=Masc|Number=Sing", + "lemma": "szkockiy", + "dep": "amod", + "head": 7, + }, + { + "id": 7, + "start": 55, + "end": 66, + "tag": "SUBST", + "pos": "NOUN", + "morph": "Animacy=Hum|Case=Gen|Gender=Masc|Number=Sing", + "lemma": "medioznawca", + "dep": "iobj", + "head": 5, + }, + { + "id": 8, + "start": 67, + "end": 68, + "tag": "INTERP", + "pos": "PUNCT", + "morph": "PunctType=Comm", + "lemma": ",", + "dep": "punct", + "head": 9, + }, + { + "id": 9, + "start": 69, + "end": 75, + "tag": "SUBST", + "pos": "PROPN", + "morph": "Animacy=Hum|Case=Gen|Gender=Masc|Number=Sing", + "lemma": "Brian", + "dep": "nmod", + "head": 4, + }, + { + "id": 10, + "start": 76, + "end": 83, + "tag": "SUBST", + "pos": "PROPN", + "morph": "Animacy=Hum|Case=Gen|Gender=Masc|Number=Sing", + "lemma": "McNair", + "dep": "flat", + "head": 9, + }, + { + "id": 11, + "start": 84, + "end": 85, + "tag": "INTERP", + "pos": "PUNCT", + "morph": "PunctType=Dash", + "lemma": "-", + "dep": "punct", + "head": 12, + }, + { + "id": 12, + "start": 86, + "end": 94, + "tag": "SUBST", + "pos": "PROPN", + "morph": "Animacy=Inan|Case=Nom|Gender=Masc|Number=Sing", + "lemma": "Cultural", + "dep": "conj", + "head": 4, + }, + { + "id": 13, + "start": 95, + "end": 100, + "tag": "SUBST", + "pos": "NOUN", + "morph": "Animacy=Inan|Case=Nom|Gender=Masc|Number=Sing", + "lemma": "Chaos", + "dep": "flat", + "head": 12, + }, + { + "id": 14, + "start": 101, + "end": 102, + "tag": "INTERP", + "pos": "PUNCT", + "morph": "PunctType=Peri", + "lemma": ".", + "dep": "punct", + "head": 1, + }, # fmt: on ], } @@ -420,8 +570,14 @@ def test_cli_converters_conll_ner_to_docs(): (["--x.foo=bar"], {"x.foo": "bar"}), (["--x.foo", "--x.bar", "baz"], {"x.foo": True, "x.bar": "baz"}), (["--x.foo", "--x.bar=baz"], {"x.foo": True, "x.bar": "baz"}), - (["--x.foo", "10.1", "--x.bar", "--x.baz", "false"], {"x.foo": 10.1, "x.bar": True, "x.baz": False}), - (["--x.foo", "10.1", "--x.bar", "--x.baz=false"], {"x.foo": 10.1, "x.bar": True, "x.baz": False}) + ( + ["--x.foo", "10.1", "--x.bar", "--x.baz", "false"], + {"x.foo": 10.1, "x.bar": True, "x.baz": False}, + ), + ( + ["--x.foo", "10.1", "--x.bar", "--x.baz=false"], + {"x.foo": 10.1, "x.bar": True, "x.baz": False}, + ), # fmt: on ], ) @@ -499,11 +655,11 @@ def test_model_recommendations(): # fmt: off "parser,textcat,tagger", " parser, textcat ,tagger ", - 'parser,textcat,tagger', - ' parser, textcat ,tagger ', + "parser,textcat,tagger", + " parser, textcat ,tagger ", ' "parser"," textcat " ,"tagger "', " 'parser',' textcat ' ,'tagger '", - '[parser,textcat,tagger]', + "[parser,textcat,tagger]", '["parser","textcat","tagger"]', '[" parser" ,"textcat ", " tagger " ]', "[parser,textcat,tagger]", @@ -522,7 +678,7 @@ def test_string_to_list(value): [ # fmt: off "1,2,3", - '[1,2,3]', + "[1,2,3]", '["1","2","3"]', '[" 1" ,"2 ", " 3 " ]', "[' 1' , '2', ' 3 ' ]", diff --git a/spacy/tests/test_factory_imports.py b/spacy/tests/test_factory_imports.py index a975af0bbd2..7a1b4a769a8 100644 --- a/spacy/tests/test_factory_imports.py +++ b/spacy/tests/test_factory_imports.py @@ -67,16 +67,16 @@ def test_factory_import_compatibility(factory_name, original_module, compat_modu # Import from the original module (registrations.py) original_module_obj = importlib.import_module(original_module) original_factory = getattr(original_module_obj, factory_name) - assert ( - original_factory is not None - ), f"Could not import {factory_name} from {original_module}" + assert original_factory is not None, ( + f"Could not import {factory_name} from {original_module}" + ) # Import from the compatibility module (component file) compat_module_obj = importlib.import_module(compat_module) compat_factory = getattr(compat_module_obj, factory_name) - assert ( - compat_factory is not None - ), f"Could not import {factory_name} from {compat_module}" + assert compat_factory is not None, ( + f"Could not import {factory_name} from {compat_module}" + ) # Test that they're the same function (identity) assert original_factory is compat_factory, ( diff --git a/spacy/tests/test_factory_registrations.py b/spacy/tests/test_factory_registrations.py index 8e93f54f0b0..ab604c3a6d5 100644 --- a/spacy/tests/test_factory_registrations.py +++ b/spacy/tests/test_factory_registrations.py @@ -82,9 +82,9 @@ def test_factory_registrations_preserved(reference_factory_registrations): missing_registrations = set(reference_factory_registrations.keys()) - set( current_registrations.keys() ) - assert ( - not missing_registrations - ), f"Missing factory registrations: {', '.join(sorted(missing_registrations))}" + assert not missing_registrations, ( + f"Missing factory registrations: {', '.join(sorted(missing_registrations))}" + ) # Check for new registrations (not an error, but informative) new_registrations = set(current_registrations.keys()) - set( diff --git a/spacy/tests/test_registry_population.py b/spacy/tests/test_registry_population.py index 592e74dd20a..c67136f9c31 100644 --- a/spacy/tests/test_registry_population.py +++ b/spacy/tests/test_registry_population.py @@ -50,6 +50,6 @@ def test_registry_entries(reference_registry): # Check for missing entries - these would indicate our new registry population # mechanism is missing something missing_entries = expected_set - current_set - assert ( - not missing_entries - ), f"Registry '{registry_name}' missing entries: {', '.join(missing_entries)}" + assert not missing_entries, ( + f"Registry '{registry_name}' missing entries: {', '.join(missing_entries)}" + ) diff --git a/spacy/tokens/doc.pyi b/spacy/tokens/doc.pyi index d92f04d0564..b8b26ce8b0d 100644 --- a/spacy/tokens/doc.pyi +++ b/spacy/tokens/doc.pyi @@ -57,7 +57,9 @@ class Doc: force: bool = ..., ) -> None: ... @classmethod - def get_extension(cls, name: str) -> Tuple[ + def get_extension( + cls, name: str + ) -> Tuple[ Optional[Any], Optional[DocMethod], Optional[Callable[[Doc], Any]], @@ -66,7 +68,9 @@ class Doc: @classmethod def has_extension(cls, name: str) -> bool: ... @classmethod - def remove_extension(cls, name: str) -> Tuple[ + def remove_extension( + cls, name: str + ) -> Tuple[ Optional[Any], Optional[DocMethod], Optional[Callable[[Doc], Any]], @@ -144,7 +148,7 @@ class Doc: blocked: Optional[List[Span]] = ..., missing: Optional[List[Span]] = ..., outside: Optional[List[Span]] = ..., - default: str = ... + default: str = ..., ) -> None: ... @property def noun_chunks(self) -> Iterator[Span]: ... diff --git a/spacy/tokens/span.pyi b/spacy/tokens/span.pyi index 070aaffb3a8..b982eb810b8 100644 --- a/spacy/tokens/span.pyi +++ b/spacy/tokens/span.pyi @@ -23,7 +23,9 @@ class Span: force: bool = ..., ) -> None: ... @classmethod - def get_extension(cls, name: str) -> Tuple[ + def get_extension( + cls, name: str + ) -> Tuple[ Optional[Any], Optional[SpanMethod], Optional[Callable[[Span], Any]], @@ -32,7 +34,9 @@ class Span: @classmethod def has_extension(cls, name: str) -> bool: ... @classmethod - def remove_extension(cls, name: str) -> Tuple[ + def remove_extension( + cls, name: str + ) -> Tuple[ Optional[Any], Optional[SpanMethod], Optional[Callable[[Span], Any]], diff --git a/spacy/tokens/span_group.pyi b/spacy/tokens/span_group.pyi index d063bb59533..3bd2b6788fb 100644 --- a/spacy/tokens/span_group.pyi +++ b/spacy/tokens/span_group.pyi @@ -12,7 +12,7 @@ class SpanGroup: *, name: str = ..., attrs: Dict[str, Any] = ..., - spans: Iterable[Span] = ... + spans: Iterable[Span] = ..., ) -> None: ... def __repr__(self) -> str: ... @property diff --git a/spacy/tokens/token.pyi b/spacy/tokens/token.pyi index 7e56ae3bccd..435ace52707 100644 --- a/spacy/tokens/token.pyi +++ b/spacy/tokens/token.pyi @@ -27,7 +27,9 @@ class Token: force: bool = ..., ) -> None: ... @classmethod - def get_extension(cls, name: str) -> Tuple[ + def get_extension( + cls, name: str + ) -> Tuple[ Optional[Any], Optional[TokenMethod], Optional[Callable[[Token], Any]], @@ -36,7 +38,9 @@ class Token: @classmethod def has_extension(cls, name: str) -> bool: ... @classmethod - def remove_extension(cls, name: str) -> Tuple[ + def remove_extension( + cls, name: str + ) -> Tuple[ Optional[Any], Optional[TokenMethod], Optional[Callable[[Token], Any]], diff --git a/spacy/training/batchers.py b/spacy/training/batchers.py index 4a1dfa94515..4f3ac5de795 100644 --- a/spacy/training/batchers.py +++ b/spacy/training/batchers.py @@ -24,7 +24,7 @@ def configure_minibatch_by_padded_size( size: Sizing, buffer: int, discard_oversize: bool, - get_length: Optional[Callable[[ItemT], int]] = None + get_length: Optional[Callable[[ItemT], int]] = None, ) -> BatcherT: """Create a batcher that uses the `batch_by_padded_size` strategy. @@ -49,7 +49,7 @@ def configure_minibatch_by_padded_size( size=size, buffer=buffer, discard_oversize=discard_oversize, - **optionals + **optionals, ) @@ -58,7 +58,7 @@ def configure_minibatch_by_words( size: Sizing, tolerance: float, discard_oversize: bool, - get_length: Optional[Callable[[ItemT], int]] = None + get_length: Optional[Callable[[ItemT], int]] = None, ) -> BatcherT: """Create a batcher that uses the "minibatch by words" strategy. @@ -76,7 +76,7 @@ def configure_minibatch_by_words( size=size, tolerance=tolerance, discard_oversize=discard_oversize, - **optionals + **optionals, ) diff --git a/spacy/training/converters/conll_ner_to_docs.py b/spacy/training/converters/conll_ner_to_docs.py index b19d1791b27..e66a8a8dfed 100644 --- a/spacy/training/converters/conll_ner_to_docs.py +++ b/spacy/training/converters/conll_ner_to_docs.py @@ -74,8 +74,7 @@ def conll_ner_to_docs( # provide warnings for problematic data if "\n\n" not in input_data: msg.warn( - "No sentence boundaries found. Use `-s` to automatically segment " - "sentences." + "No sentence boundaries found. Use `-s` to automatically segment sentences." ) if doc_delimiter not in input_data: msg.warn( diff --git a/spacy/training/converters/conllu_to_docs.py b/spacy/training/converters/conllu_to_docs.py index bda5c88c3d4..3a60c4e024b 100644 --- a/spacy/training/converters/conllu_to_docs.py +++ b/spacy/training/converters/conllu_to_docs.py @@ -15,7 +15,7 @@ def conllu_to_docs( ner_map=None, merge_subtokens=False, no_print=False, - **_ + **_, ): """ Convert conllu files into JSON format for use with train cli. diff --git a/spacy/training/loggers.py b/spacy/training/loggers.py index 488ca4a7136..05c5d3bb681 100644 --- a/spacy/training/loggers.py +++ b/spacy/training/loggers.py @@ -176,7 +176,7 @@ def log_step(info: Optional[Dict[str, Any]]) -> None: initial = info["step"] else: total = eval_frequency - desc = f"Epoch {info['epoch']+1}" + desc = f"Epoch {info['epoch'] + 1}" initial = 0 # Set disable=None, so that it disables on non-TTY progress = tqdm.tqdm( diff --git a/spacy/ty.py b/spacy/ty.py index b37f2e18a1f..c18ce284dc0 100644 --- a/spacy/ty.py +++ b/spacy/ty.py @@ -29,7 +29,7 @@ def update( *, drop: float = 0.0, sgd: Optional[Optimizer] = None, - losses: Optional[Dict[str, float]] = None + losses: Optional[Dict[str, float]] = None, ) -> Dict[str, float]: ... def finish_update(self, sgd: Optimizer) -> None: ... @@ -41,7 +41,7 @@ def initialize( self, get_examples: Callable[[], Iterable["Example"]], nlp: "Language", - **kwargs: Any + **kwargs: Any, ): ... diff --git a/spacy/util.py b/spacy/util.py index ad5a7e0bada..14d7b539994 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -557,7 +557,9 @@ def load_model_from_package( RETURNS (Language): The loaded nlp object. """ cls = importlib.import_module(name) - return cls.load(vocab=vocab, disable=disable, enable=enable, exclude=exclude, config=config) # type: ignore[attr-defined] + return cls.load( + vocab=vocab, disable=disable, enable=enable, exclude=exclude, config=config + ) # type: ignore[attr-defined] def load_model_from_path( From 4cf4e9e350188e2be626ceb4eda77448af160585 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 08:59:49 +0100 Subject: [PATCH 07/32] Ignore mypy errors (for now) --- spacy/__init__.py | 2 +- spacy/cli/debug_config.py | 4 ++-- spacy/cli/debug_data.py | 2 +- spacy/cli/debug_model.py | 2 +- spacy/cli/find_threshold.py | 4 ++-- spacy/compat.py | 4 ++-- spacy/lang/es/lemmatizer.py | 2 +- spacy/language.py | 8 ++++---- spacy/schemas.py | 2 +- spacy/training/batchers.py | 1 + spacy/training/initialize.py | 2 +- spacy/training/loop.py | 2 +- spacy/training/pretrain.py | 2 +- 13 files changed, 19 insertions(+), 18 deletions(-) diff --git a/spacy/__init__.py b/spacy/__init__.py index 9d7fdf29ba7..5b3ff25c872 100644 --- a/spacy/__init__.py +++ b/spacy/__init__.py @@ -41,7 +41,7 @@ ConfigSchemaInit, ConfigSchema, ): - _schema.model_rebuild(_types_namespace=_rebuild_ns) + _schema.model_rebuild(_types_namespace=_rebuild_ns) # type: ignore[attr-defined] if sys.maxunicode == 65535: raise SystemError(Errors.E130) diff --git a/spacy/cli/debug_config.py b/spacy/cli/debug_config.py index f049d7fd149..4876b6ff9e1 100644 --- a/spacy/cli/debug_config.py +++ b/spacy/cli/debug_config.py @@ -82,10 +82,10 @@ def debug_config( config = nlp.config.interpolate() msg.divider("Config validation for [initialize]") with show_validation_error(config_path): - T = registry.resolve(config["initialize"], schema=ConfigSchemaInit) + T = registry.resolve(config["initialize"], schema=ConfigSchemaInit) # type: ignore[arg-type] msg.divider("Config validation for [training]") with show_validation_error(config_path): - T = registry.resolve(config["training"], schema=ConfigSchemaTraining) + T = registry.resolve(config["training"], schema=ConfigSchemaTraining) # type: ignore[arg-type] dot_names = [T["train_corpus"], T["dev_corpus"]] util.resolve_dot_names(config, dot_names) msg.good("Config is valid") diff --git a/spacy/cli/debug_data.py b/spacy/cli/debug_data.py index df52250cf90..6ba18e7f224 100644 --- a/spacy/cli/debug_data.py +++ b/spacy/cli/debug_data.py @@ -137,7 +137,7 @@ def debug_data( cfg = util.load_config(config_path, overrides=config_overrides) nlp = util.load_model_from_config(cfg) config = nlp.config.interpolate() - T = registry.resolve(config["training"], schema=ConfigSchemaTraining) + T = registry.resolve(config["training"], schema=ConfigSchemaTraining) # type: ignore[arg-type] # Use original config here, not resolved version sourced_components = get_sourced_components(cfg) frozen_components = T["frozen_components"] diff --git a/spacy/cli/debug_model.py b/spacy/cli/debug_model.py index ec7ffe099d7..dc0de3e1489 100644 --- a/spacy/cli/debug_model.py +++ b/spacy/cli/debug_model.py @@ -89,7 +89,7 @@ def debug_model_cli( with show_validation_error(config_path): nlp = util.load_model_from_config(raw_config) config = nlp.config.interpolate() - T = registry.resolve(config["training"], schema=ConfigSchemaTraining) + T = registry.resolve(config["training"], schema=ConfigSchemaTraining) # type: ignore[arg-type] seed = T["seed"] if seed is not None: msg.info(f"Fixing random seed: {seed}") diff --git a/spacy/cli/find_threshold.py b/spacy/cli/find_threshold.py index 05b6fdc9517..c260785bb21 100644 --- a/spacy/cli/find_threshold.py +++ b/spacy/cli/find_threshold.py @@ -207,8 +207,8 @@ def filter_config( ), ) if hasattr(pipe, "cfg"): - nlp.get_pipe(pipe_name).cfg = set_nested_item( - pipe.cfg, config_keys, threshold + nlp.get_pipe(pipe_name).cfg = set_nested_item( # type: ignore[attr-defined] + pipe.cfg, config_keys, threshold # type: ignore[attr-defined] ) eval_scores = nlp.evaluate(dev_dataset) diff --git a/spacy/compat.py b/spacy/compat.py index abaca49302f..828ed1ba62e 100644 --- a/spacy/compat.py +++ b/spacy/compat.py @@ -35,8 +35,8 @@ try: # Python 3.8+ import importlib.metadata as importlib_metadata except ImportError: - from catalogue import ( - _importlib_metadata as importlib_metadata, # type: ignore[no-redef] # noqa: F401 + from catalogue import ( # type: ignore[no-redef] + _importlib_metadata as importlib_metadata, # noqa: F401 ) from thinc.api import Optimizer # noqa: F401 diff --git a/spacy/lang/es/lemmatizer.py b/spacy/lang/es/lemmatizer.py index 05238a75b70..3102f3b9bc4 100644 --- a/spacy/lang/es/lemmatizer.py +++ b/spacy/lang/es/lemmatizer.py @@ -416,7 +416,7 @@ def lemmatize_verb_pron( rule = self.select_rule("verb", features) verb_lemma = self.lemmatize_verb( verb, - features - {"PronType=Prs"}, + features - {"PronType=Prs"}, # type: ignore[operator] rule, index, # type: ignore[operator] )[0] diff --git a/spacy/language.py b/spacy/language.py index ea9ba3cae8b..9bc944eada9 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -1323,7 +1323,7 @@ def get_examples(): # Make sure the config is interpolated so we can resolve subsections config = self.config.interpolate() # These are the settings provided in the [initialize] block in the config - I = registry.resolve(config["initialize"], schema=ConfigSchemaInit) + I = registry.resolve(config["initialize"], schema=ConfigSchemaInit) # type: ignore[arg-type] before_init = I["before_init"] if before_init is not None: before_init(self) @@ -1353,7 +1353,7 @@ def get_examples(): proc.initialize(get_examples, nlp=self, **p_settings) pretrain_cfg = config.get("pretraining") if pretrain_cfg: - P = registry.resolve(pretrain_cfg, schema=ConfigSchemaPretrain) + P = registry.resolve(pretrain_cfg, schema=ConfigSchemaPretrain) # type: ignore[arg-type] init_tok2vec(self, P, I) self._link_components() self._optimizer = sgd @@ -1823,7 +1823,7 @@ def from_config( orig_pretraining = config.pop("pretraining", None) config["components"] = {} if auto_fill: - filled = registry.fill(config, validate=validate, schema=ConfigSchema) + filled = registry.fill(config, validate=validate, schema=ConfigSchema) # type: ignore[arg-type] else: filled = config filled["components"] = orig_pipeline @@ -1832,7 +1832,7 @@ def from_config( filled["pretraining"] = orig_pretraining config["pretraining"] = orig_pretraining resolved_nlp = registry.resolve( - filled["nlp"], validate=validate, schema=ConfigSchemaNlp + filled["nlp"], validate=validate, schema=ConfigSchemaNlp # type: ignore[arg-type] ) create_tokenizer = resolved_nlp["tokenizer"] create_vectors = resolved_nlp["vectors"] diff --git a/spacy/schemas.py b/spacy/schemas.py index e3200348013..dd0481a0ea9 100644 --- a/spacy/schemas.py +++ b/spacy/schemas.py @@ -251,7 +251,7 @@ class TokenPatternOperatorSimple(str, Enum): TokenPatternOperatorMinMax = constr(pattern=r"^(\{\d+\}|\{\d+,\d*\}|\{\d*,\d+\})$") -TokenPatternOperator = Union[TokenPatternOperatorSimple, TokenPatternOperatorMinMax] +TokenPatternOperator = Union[TokenPatternOperatorSimple, TokenPatternOperatorMinMax] # type: ignore[valid-type] StringValue = Union[TokenPatternString, StrictStr] NumberValue = Union[TokenPatternNumber, StrictInt, StrictFloat] UnderscoreValue = Union[ diff --git a/spacy/training/batchers.py b/spacy/training/batchers.py index 8158e9fdf8f..40e437dcc8c 100644 --- a/spacy/training/batchers.py +++ b/spacy/training/batchers.py @@ -4,6 +4,7 @@ Any, Callable, Iterable, + Iterator, List, Optional, Sequence, diff --git a/spacy/training/initialize.py b/spacy/training/initialize.py index 64cdddf9c43..164a0867494 100644 --- a/spacy/training/initialize.py +++ b/spacy/training/initialize.py @@ -50,7 +50,7 @@ def init_nlp(config: Config, *, use_gpu: int = -1) -> "Language": logger.info("Set up nlp object from config") config = nlp.config.interpolate() # Resolve all training-relevant sections using the filled nlp config - T = registry.resolve(config["training"], schema=ConfigSchemaTraining) + T = registry.resolve(config["training"], schema=ConfigSchemaTraining) # type: ignore[arg-type] dot_names = [T["train_corpus"], T["dev_corpus"]] if not isinstance(T["train_corpus"], str): raise ConfigValidationError( diff --git a/spacy/training/loop.py b/spacy/training/loop.py index 6f5099858f1..d6f1ad7d608 100644 --- a/spacy/training/loop.py +++ b/spacy/training/loop.py @@ -62,7 +62,7 @@ def train( allocator = config["training"]["gpu_allocator"] if use_gpu >= 0 and allocator: set_gpu_allocator(allocator) - T = registry.resolve(config["training"], schema=ConfigSchemaTraining) + T = registry.resolve(config["training"], schema=ConfigSchemaTraining) # type: ignore[arg-type] dot_names = [T["train_corpus"], T["dev_corpus"]] train_corpus, dev_corpus = resolve_dot_names(config, dot_names) optimizer = T["optimizer"] diff --git a/spacy/training/pretrain.py b/spacy/training/pretrain.py index 14a813a0993..32eada4d749 100644 --- a/spacy/training/pretrain.py +++ b/spacy/training/pretrain.py @@ -42,7 +42,7 @@ def pretrain( config["initialize"]["init_tok2vec"] = None nlp = load_model_from_config(config) _config = nlp.config.interpolate() - P = registry.resolve(_config["pretraining"], schema=ConfigSchemaPretrain) + P = registry.resolve(_config["pretraining"], schema=ConfigSchemaPretrain) # type: ignore[arg-type] corpus = dot_to_object(_config, P["corpus"]) corpus = registry.resolve({"corpus": corpus})["corpus"] batcher = P["batcher"] From e684b0c1d16b764c8206af90e388aba17efe1ed5 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 09:01:46 +0100 Subject: [PATCH 08/32] Apply ruff formatting to find_threshold.py and language.py --- spacy/cli/find_threshold.py | 4 +++- spacy/language.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spacy/cli/find_threshold.py b/spacy/cli/find_threshold.py index c260785bb21..1873f476fcd 100644 --- a/spacy/cli/find_threshold.py +++ b/spacy/cli/find_threshold.py @@ -208,7 +208,9 @@ def filter_config( ) if hasattr(pipe, "cfg"): nlp.get_pipe(pipe_name).cfg = set_nested_item( # type: ignore[attr-defined] - pipe.cfg, config_keys, threshold # type: ignore[attr-defined] + pipe.cfg, + config_keys, + threshold, # type: ignore[attr-defined] ) eval_scores = nlp.evaluate(dev_dataset) diff --git a/spacy/language.py b/spacy/language.py index 9bc944eada9..8e91018254e 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -1832,7 +1832,9 @@ def from_config( filled["pretraining"] = orig_pretraining config["pretraining"] = orig_pretraining resolved_nlp = registry.resolve( - filled["nlp"], validate=validate, schema=ConfigSchemaNlp # type: ignore[arg-type] + filled["nlp"], + validate=validate, + schema=ConfigSchemaNlp, # type: ignore[arg-type] ) create_tokenizer = resolved_nlp["tokenizer"] create_vectors = resolved_nlp["vectors"] From e17f2e6286f44926e88f07c925c71e8167b92b40 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 12:49:59 +0100 Subject: [PATCH 09/32] Replace deprecated pydantic Field(help=...) with Field(title=...) --- spacy/schemas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spacy/schemas.py b/spacy/schemas.py index dd0481a0ea9..359c3fd0f83 100644 --- a/spacy/schemas.py +++ b/spacy/schemas.py @@ -420,8 +420,8 @@ class ConfigSchemaInit(BaseModel): lookups: Optional[Lookups] = Field(..., title="Vocabulary lookups, e.g. lexeme normalization") vectors: Optional[StrictStr] = Field(..., title="Path to vectors") init_tok2vec: Optional[StrictStr] = Field(..., title="Path to pretrained tok2vec weights") - tokenizer: Dict[StrictStr, Any] = Field(..., help="Arguments to be passed into Tokenizer.initialize") - components: Dict[StrictStr, Dict[StrictStr, Any]] = Field(..., help="Arguments for TrainablePipe.initialize methods of pipeline components, keyed by component") + tokenizer: Dict[StrictStr, Any] = Field(..., title="Arguments to be passed into Tokenizer.initialize") + components: Dict[StrictStr, Dict[StrictStr, Any]] = Field(..., title="Arguments for TrainablePipe.initialize methods of pipeline components, keyed by component") before_init: Optional[Callable[["Language"], "Language"]] = Field(..., title="Optional callback to modify nlp object before initialization") after_init: Optional[Callable[["Language"], "Language"]] = Field(..., title="Optional callback to modify nlp object after initialization") # fmt: on From a0f5d7b9ebbb853699606971eac830b5b14d4477 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 13:01:46 +0100 Subject: [PATCH 10/32] Fix EntityLinker_v1 import to use legacy module --- spacy/pipeline/factories.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/pipeline/factories.py b/spacy/pipeline/factories.py index e76704237ee..c981b30458d 100644 --- a/spacy/pipeline/factories.py +++ b/spacy/pipeline/factories.py @@ -14,7 +14,8 @@ ) # Import factory default configurations -from ..pipeline.entity_linker import DEFAULT_NEL_MODEL, EntityLinker, EntityLinker_v1 +from ..pipeline.entity_linker import DEFAULT_NEL_MODEL, EntityLinker +from ..pipeline.legacy import EntityLinker_v1 from ..pipeline.entityruler import DEFAULT_ENT_ID_SEP, EntityRuler from ..pipeline.functions import DocCleaner, TokenSplitter from ..pipeline.lemmatizer import Lemmatizer From dfba77b9b9371f14a97bf437a5a99215439dc64a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 13:07:05 +0100 Subject: [PATCH 11/32] Fix import sorting in factories.py --- spacy/pipeline/factories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy/pipeline/factories.py b/spacy/pipeline/factories.py index c981b30458d..8c71067b32e 100644 --- a/spacy/pipeline/factories.py +++ b/spacy/pipeline/factories.py @@ -15,9 +15,9 @@ # Import factory default configurations from ..pipeline.entity_linker import DEFAULT_NEL_MODEL, EntityLinker -from ..pipeline.legacy import EntityLinker_v1 from ..pipeline.entityruler import DEFAULT_ENT_ID_SEP, EntityRuler from ..pipeline.functions import DocCleaner, TokenSplitter +from ..pipeline.legacy import EntityLinker_v1 from ..pipeline.lemmatizer import Lemmatizer from ..pipeline.morphologizer import DEFAULT_MORPH_MODEL, Morphologizer from ..pipeline.multitask import DEFAULT_MT_MODEL, MultitaskObjective From abb0414288bb857d8355e5bf8216960fcd8312ba Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 13:16:47 +0100 Subject: [PATCH 12/32] Replace deprecated pydantic .dict() with .model_dump() --- spacy/cli/init_config.py | 2 +- spacy/matcher/phrasematcher.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spacy/cli/init_config.py b/spacy/cli/init_config.py index 2cb39056d5e..c7081040280 100644 --- a/spacy/cli/init_config.py +++ b/spacy/cli/init_config.py @@ -216,7 +216,7 @@ def init_config( # Filter out duplicates since tok2vec and transformer are added by template pipeline = [pipe for pipe in pipeline if pipe not in ("tok2vec", "transformer")] defaults = RECOMMENDATIONS["__default__"] - reco = RecommendationSchema(**RECOMMENDATIONS.get(lang, defaults)).dict() + reco = RecommendationSchema(**RECOMMENDATIONS.get(lang, defaults)).model_dump() variables = { "lang": lang, "components": pipeline, diff --git a/spacy/matcher/phrasematcher.pyx b/spacy/matcher/phrasematcher.pyx index ccc830e35c1..a71f85f6e63 100644 --- a/spacy/matcher/phrasematcher.pyx +++ b/spacy/matcher/phrasematcher.pyx @@ -57,7 +57,7 @@ cdef class PhraseMatcher: attr = "ORTH" if attr == "IS_SENT_START": attr = "SENT_START" - if attr.lower() not in TokenPattern().dict(): + if attr.lower() not in TokenPattern().model_dump(): raise ValueError(Errors.E152.format(attr=attr)) self.attr = IDS.get(attr) From b11a6e3f4215300cae8316994205845cb05cab3e Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 13:42:13 +0100 Subject: [PATCH 13/32] Add ruff to test ignore list and filter pydantic deprecation warnings from confection --- setup.cfg | 3 +++ spacy/tests/package/test_requirements.py | 1 + 2 files changed, 4 insertions(+) diff --git a/setup.cfg b/setup.cfg index 6d2c7c06162..9ea2d0d610d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -135,6 +135,9 @@ formats = gztar markers = slow: mark a test as slow issue: reference specific issue +filterwarnings = + error + ignore::pydantic.warnings.PydanticDeprecatedSince20 [mypy] ignore_missing_imports = True diff --git a/spacy/tests/package/test_requirements.py b/spacy/tests/package/test_requirements.py index b9276441222..f4c6f056aa2 100644 --- a/spacy/tests/package/test_requirements.py +++ b/spacy/tests/package/test_requirements.py @@ -15,6 +15,7 @@ def test_build_dependencies(): "cython-lint", "black", "isort", + "ruff", "mypy", "types-dataclasses", "types-mock", From d434682a4630be99a97f35cdd8bb889a9c5137f7 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 14:43:34 +0100 Subject: [PATCH 14/32] Fix tests for confection 1.1+: warning filters, zh segmenter test, lazy tok2vec import, str->Path coercion --- .github/workflows/tests.yml | 8 ++++---- setup.cfg | 2 +- spacy/tests/lang/zh/test_tokenizer.py | 3 +-- spacy/tests/pipeline/test_textcat.py | 1 + spacy/training/corpus.py | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index adfce07f50b..c1ed9492592 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -93,7 +93,7 @@ jobs: shell: bash - name: Test import - run: python -W error -c "import spacy" + run: python -W error -W 'ignore::DeprecationWarning:pydantic' -c "import spacy" - name: "Test download CLI" run: | @@ -104,12 +104,12 @@ jobs: - name: "Test download_url in info CLI" run: | - python -W error -m spacy info ca_core_news_sm | grep -q download_url + python -W error -W 'ignore::DeprecationWarning:pydantic' -m spacy info ca_core_news_sm | grep -q download_url if: matrix.python_version == '3.9' - name: "Test no warnings on load (#11713)" run: | - python -W error -c "import ca_core_news_sm; nlp = ca_core_news_sm.load(); doc=nlp('test')" + python -W error -W 'ignore::DeprecationWarning:pydantic' -c "import ca_core_news_sm; nlp = ca_core_news_sm.load(); doc=nlp('test')" if: matrix.python_version == '3.9' - name: "Test convert CLI" @@ -154,7 +154,7 @@ jobs: - name: "Run CPU tests" run: | - python -m pytest --pyargs spacy -W error + python -m pytest --pyargs spacy -W error -W 'ignore::DeprecationWarning:pydantic' if: "!(startsWith(matrix.os, 'macos') && matrix.python_version == '3.11')" - name: "Run CPU tests with thinc-apple-ops" diff --git a/setup.cfg b/setup.cfg index 9ea2d0d610d..bc28d36de03 100644 --- a/setup.cfg +++ b/setup.cfg @@ -137,7 +137,7 @@ markers = issue: reference specific issue filterwarnings = error - ignore::pydantic.warnings.PydanticDeprecatedSince20 + ignore::DeprecationWarning:pydantic [mypy] ignore_missing_imports = True diff --git a/spacy/tests/lang/zh/test_tokenizer.py b/spacy/tests/lang/zh/test_tokenizer.py index cdba5e39709..49c3775a9be 100644 --- a/spacy/tests/lang/zh/test_tokenizer.py +++ b/spacy/tests/lang/zh/test_tokenizer.py @@ -1,5 +1,4 @@ import pytest -from thinc.api import ConfigValidationError from spacy.lang.zh import Chinese, _get_pkuseg_trie_data @@ -66,7 +65,7 @@ def test_zh_extra_spaces(zh_tokenizer_char): def test_zh_unsupported_segmenter(): config = {"nlp": {"tokenizer": {"segmenter": "unk"}}} - with pytest.raises(ConfigValidationError): + with pytest.warns(UserWarning, match="W103"): Chinese.from_config(config) diff --git a/spacy/tests/pipeline/test_textcat.py b/spacy/tests/pipeline/test_textcat.py index f2bfe003d39..be4d56cfe5e 100644 --- a/spacy/tests/pipeline/test_textcat.py +++ b/spacy/tests/pipeline/test_textcat.py @@ -23,6 +23,7 @@ multi_label_default_config, ) from spacy.pipeline.tok2vec import DEFAULT_TOK2VEC_MODEL +from spacy.tests.tok2vec import build_lazy_init_tok2vec as _ # noqa: F401 from spacy.scorer import Scorer from spacy.tokens import Doc, DocBin from spacy.training import Example diff --git a/spacy/training/corpus.py b/spacy/training/corpus.py index 5cc2733a540..30e32911e6b 100644 --- a/spacy/training/corpus.py +++ b/spacy/training/corpus.py @@ -50,9 +50,10 @@ def create_jsonl_reader( @util.registry.readers("spacy.read_labels.v1") -def read_labels(path: Path, *, require: bool = False): +def read_labels(path: Union[str, Path], *, require: bool = False): # I decided not to give this a generic name, because I don't want people to # use it for arbitrary stuff, as I want this require arg with default False. + path = Path(path) if not require and not path.exists(): return None return srsly.read_json(path) From 8b42d87830854bf90bd1292de17df82d80bbd06f Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 14:45:56 +0100 Subject: [PATCH 15/32] Monkeypatch _get_pip_install_cmd in download test for envs without pip on PATH --- spacy/tests/test_cli.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spacy/tests/test_cli.py b/spacy/tests/test_cli.py index 8415e5c92ff..4bac40f0b89 100644 --- a/spacy/tests/test_cli.py +++ b/spacy/tests/test_cli.py @@ -1229,6 +1229,9 @@ def test_download_rejects_relative_urls(monkeypatch): relative path in the filename""" monkeypatch.setattr(download_module, "run_command", lambda cmd: None) + monkeypatch.setattr( + download_module, "_get_pip_install_cmd", lambda: ["pip", "install"] + ) # Check that normal download works download_module.download("en_core_web_sm-3.7.1", direct=True) From 326df3b7094210f064cb34dec699bac07fd838d1 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 15:16:50 +0100 Subject: [PATCH 16/32] Remove pydantic deprecation warning filters (fixed in confection) --- .github/workflows/tests.yml | 3 +-- setup.cfg | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c1ed9492592..6cbf651fddb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -154,8 +154,7 @@ jobs: - name: "Run CPU tests" run: | - python -m pytest --pyargs spacy -W error -W 'ignore::DeprecationWarning:pydantic' - if: "!(startsWith(matrix.os, 'macos') && matrix.python_version == '3.11')" + python -m pytest --pyargs spacy -W error if: "!(startsWith(matrix.os, 'macos') && matrix.python_version == '3.11')" - name: "Run CPU tests with thinc-apple-ops" run: | diff --git a/setup.cfg b/setup.cfg index bc28d36de03..28d2fd99022 100644 --- a/setup.cfg +++ b/setup.cfg @@ -137,7 +137,6 @@ markers = issue: reference specific issue filterwarnings = error - ignore::DeprecationWarning:pydantic [mypy] ignore_missing_imports = True From 4f59963dd8bc472e9685283e25a71daf1f5af4d4 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 15:33:20 +0100 Subject: [PATCH 17/32] Fix import sorting in test_textcat.py --- spacy/tests/pipeline/test_textcat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy/tests/pipeline/test_textcat.py b/spacy/tests/pipeline/test_textcat.py index be4d56cfe5e..e7499404f63 100644 --- a/spacy/tests/pipeline/test_textcat.py +++ b/spacy/tests/pipeline/test_textcat.py @@ -23,8 +23,8 @@ multi_label_default_config, ) from spacy.pipeline.tok2vec import DEFAULT_TOK2VEC_MODEL -from spacy.tests.tok2vec import build_lazy_init_tok2vec as _ # noqa: F401 from spacy.scorer import Scorer +from spacy.tests.tok2vec import build_lazy_init_tok2vec as _ # noqa: F401 from spacy.tokens import Doc, DocBin from spacy.training import Example from spacy.training.initialize import init_nlp From 00d26d0795f5c5369e0bddfbedf380c92dc6c543 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 15:36:56 +0100 Subject: [PATCH 18/32] Add Python 3.14 to CI matrix and classifiers --- .github/workflows/tests.yml | 2 +- setup.cfg | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6cbf651fddb..8893bf8c319 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python_version: ["3.10", "3.11", "3.12", "3.13"] + python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"] runs-on: ${{ matrix.os }} diff --git a/setup.cfg b/setup.cfg index 28d2fd99022..38f6208a878 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,7 @@ classifiers = Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 Programming Language :: Python :: 3.13 + Programming Language :: Python :: 3.14 Topic :: Scientific/Engineering project_urls = Release notes = https://github.com/explosion/spaCy/releases @@ -30,7 +31,7 @@ project_urls = [options] zip_safe = false include_package_data = true -python_requires = >=3.9,<3.15 +python_requires = >=3.9,<3.16 # NOTE: This section is superseded by pyproject.toml and will be removed in # spaCy v4 setup_requires = From ff1bced640de4ac70f9cd173b8071eeeeaa06a1e Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 15:37:45 +0100 Subject: [PATCH 19/32] Set python_requires upper bound to <3.15 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 38f6208a878..13720baf685 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ project_urls = [options] zip_safe = false include_package_data = true -python_requires = >=3.9,<3.16 +python_requires = >=3.9,<3.15 # NOTE: This section is superseded by pyproject.toml and will be removed in # spaCy v4 setup_requires = From 990577a4263afdaf6e256a9788067f84283ac71d Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 17:34:37 +0100 Subject: [PATCH 20/32] Fix mangled YAML in tests.yml and remove remaining pydantic warning filters --- .github/workflows/tests.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8893bf8c319..daa25ed6466 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -93,7 +93,7 @@ jobs: shell: bash - name: Test import - run: python -W error -W 'ignore::DeprecationWarning:pydantic' -c "import spacy" + run: python -W error -c "import spacy" - name: "Test download CLI" run: | @@ -104,12 +104,12 @@ jobs: - name: "Test download_url in info CLI" run: | - python -W error -W 'ignore::DeprecationWarning:pydantic' -m spacy info ca_core_news_sm | grep -q download_url + python -W error -m spacy info ca_core_news_sm | grep -q download_url if: matrix.python_version == '3.9' - name: "Test no warnings on load (#11713)" run: | - python -W error -W 'ignore::DeprecationWarning:pydantic' -c "import ca_core_news_sm; nlp = ca_core_news_sm.load(); doc=nlp('test')" + python -W error -c "import ca_core_news_sm; nlp = ca_core_news_sm.load(); doc=nlp('test')" if: matrix.python_version == '3.9' - name: "Test convert CLI" @@ -154,7 +154,8 @@ jobs: - name: "Run CPU tests" run: | - python -m pytest --pyargs spacy -W error if: "!(startsWith(matrix.os, 'macos') && matrix.python_version == '3.11')" + python -m pytest --pyargs spacy -W error + if: "!(startsWith(matrix.os, 'macos') && matrix.python_version == '3.11')" - name: "Run CPU tests with thinc-apple-ops" run: | From 3ed48a2abe39210f7f85850675bd33920f5698c7 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 18:14:38 +0100 Subject: [PATCH 21/32] Filter pydantic v1 incompatibility warning for Python 3.14 support --- .github/workflows/tests.yml | 4 ++-- setup.cfg | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index daa25ed6466..0a7cfa81f04 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -93,7 +93,7 @@ jobs: shell: bash - name: Test import - run: python -W error -c "import spacy" + run: python -W error -W 'ignore:Core Pydantic V1:UserWarning:pydantic' -c "import spacy" - name: "Test download CLI" run: | @@ -154,7 +154,7 @@ jobs: - name: "Run CPU tests" run: | - python -m pytest --pyargs spacy -W error + python -m pytest --pyargs spacy -W error -W 'ignore:Core Pydantic V1:UserWarning:pydantic' if: "!(startsWith(matrix.os, 'macos') && matrix.python_version == '3.11')" - name: "Run CPU tests with thinc-apple-ops" diff --git a/setup.cfg b/setup.cfg index 13720baf685..da35de04094 100644 --- a/setup.cfg +++ b/setup.cfg @@ -138,6 +138,7 @@ markers = issue: reference specific issue filterwarnings = error + ignore:Core Pydantic V1:UserWarning:pydantic [mypy] ignore_missing_imports = True From 45db7d772e2e4b49344d777eefd0e75fe09c8abe Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 21 Mar 2026 18:22:48 +0100 Subject: [PATCH 22/32] Skip Python 3.14 in CI until dependencies have wheels --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0a7cfa81f04..3bd2606db8c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"] + python_version: ["3.10", "3.11", "3.12", "3.13"] runs-on: ${{ matrix.os }} From eab3119380849be2a7991a8eba500761de9c747a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 22 Mar 2026 20:32:46 +0100 Subject: [PATCH 23/32] Fix zh tokenizer test: expect ConfigValidationError for invalid segmenter enum --- spacy/tests/lang/zh/test_tokenizer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/tests/lang/zh/test_tokenizer.py b/spacy/tests/lang/zh/test_tokenizer.py index 49c3775a9be..cb9b4ec539a 100644 --- a/spacy/tests/lang/zh/test_tokenizer.py +++ b/spacy/tests/lang/zh/test_tokenizer.py @@ -1,4 +1,5 @@ import pytest +from confection import ConfigValidationError from spacy.lang.zh import Chinese, _get_pkuseg_trie_data @@ -65,7 +66,7 @@ def test_zh_extra_spaces(zh_tokenizer_char): def test_zh_unsupported_segmenter(): config = {"nlp": {"tokenizer": {"segmenter": "unk"}}} - with pytest.warns(UserWarning, match="W103"): + with pytest.raises(ConfigValidationError): Chinese.from_config(config) From 27199bc23f58e4885308b94c6469b4ba985a42b8 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Mar 2026 08:33:03 +0100 Subject: [PATCH 24/32] Enable Python 3.14 in CI test matrix --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3bd2606db8c..0a7cfa81f04 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python_version: ["3.10", "3.11", "3.12", "3.13"] + python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"] runs-on: ${{ matrix.os }} From 953ee384548a498fffeaa33bf9fd9dc108fb2851 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Mar 2026 10:25:32 +0100 Subject: [PATCH 25/32] Set fail-fast: false to get full 3.14 CI results across all platforms --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0a7cfa81f04..feebfcee930 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: name: Test needs: Validate strategy: - fail-fast: true + fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"] From b05ff52005049412d8836922c80829db0cc88201 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Mar 2026 10:28:20 +0100 Subject: [PATCH 26/32] Require pydantic v2 (>=2.0.0) now that confection 1.1 has dropped pydantic --- requirements.txt | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 27a335fa6c1..4985d8080ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ weasel>=1.0.0,<2.0.0 numpy>=2.0.0,<3.0.0 requests>=2.13.0,<3.0.0 tqdm>=4.38.0,<5.0.0 -pydantic>=1.7.4,!=1.8,!=1.8.1,<3.0.0 +pydantic>=2.0.0,<3.0.0 jinja2 # Official Python utilities setuptools diff --git a/setup.cfg b/setup.cfg index da35de04094..ae36dac1c03 100644 --- a/setup.cfg +++ b/setup.cfg @@ -62,7 +62,7 @@ install_requires = numpy>=1.15.0; python_version < "3.9" numpy>=1.19.0; python_version >= "3.9" requests>=2.13.0,<3.0.0 - pydantic>=1.7.4,!=1.8,!=1.8.1,<3.0.0 + pydantic>=2.0.0,<3.0.0 jinja2 # Official Python utilities setuptools From 1c40afd3765b66c4d37c030658edb86fe60ffc2a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Mar 2026 10:51:28 +0100 Subject: [PATCH 27/32] Require srsly v3 (>=3.0.0) for Python 3.14 cloudpickle fix --- requirements.txt | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4985d8080ce..ece697a66ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ thinc>=8.3.12,<8.4.0 ml_datasets>=0.2.0,<0.3.0 murmurhash>=0.28.0,<1.1.0 wasabi>=0.9.1,<1.2.0 -srsly>=2.4.3,<3.0.0 +srsly>=3.0.0,<4.0.0 catalogue>=2.0.6,<2.1.0 typer>=0.3.0,<1.0.0 weasel>=1.0.0,<2.0.0 diff --git a/setup.cfg b/setup.cfg index ae36dac1c03..6481712f84b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,7 +52,7 @@ install_requires = preshed>=3.0.2,<3.1.0 thinc>=8.3.12,<8.4.0 wasabi>=0.9.1,<1.2.0 - srsly>=2.4.3,<3.0.0 + srsly>=3.0.0,<4.0.0 catalogue>=2.0.6,<2.1.0 weasel>=1.0.0,<2.0.0 confection>=1.1.0,<2.0.0 From ac0c3fe175684141f621c7c7a52e8c545979953c Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Mar 2026 11:15:58 +0100 Subject: [PATCH 28/32] Bump ml_datasets pin to >=0.2.1 for srsly v3 compatibility --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ece697a66ea..2955c770619 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ spacy-loggers>=1.0.0,<2.0.0 cymem>=2.0.2,<2.1.0 preshed>=3.0.2,<3.1.0 thinc>=8.3.12,<8.4.0 -ml_datasets>=0.2.0,<0.3.0 +ml_datasets>=0.2.1,<0.3.0 murmurhash>=0.28.0,<1.1.0 wasabi>=0.9.1,<1.2.0 srsly>=3.0.0,<4.0.0 From 34f43bde787c4d6c3ec9508055c47b4f32ceb544 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Mar 2026 11:27:21 +0100 Subject: [PATCH 29/32] Revert srsly pin to >=2.4.3,<3.0.0 (srsly v3 has msgpack strict_map_key breakage) --- requirements.txt | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2955c770619..1783984f6b3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ thinc>=8.3.12,<8.4.0 ml_datasets>=0.2.1,<0.3.0 murmurhash>=0.28.0,<1.1.0 wasabi>=0.9.1,<1.2.0 -srsly>=3.0.0,<4.0.0 +srsly>=2.4.3,<3.0.0 catalogue>=2.0.6,<2.1.0 typer>=0.3.0,<1.0.0 weasel>=1.0.0,<2.0.0 diff --git a/setup.cfg b/setup.cfg index 6481712f84b..ae36dac1c03 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,7 +52,7 @@ install_requires = preshed>=3.0.2,<3.1.0 thinc>=8.3.12,<8.4.0 wasabi>=0.9.1,<1.2.0 - srsly>=3.0.0,<4.0.0 + srsly>=2.4.3,<3.0.0 catalogue>=2.0.6,<2.1.0 weasel>=1.0.0,<2.0.0 confection>=1.1.0,<2.0.0 From 9abb59cf8c62dc56784d025793bde2ceba49e48f Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Mar 2026 11:38:28 +0100 Subject: [PATCH 30/32] Fix secret exposure in explosionbot workflow pip install command Use git config insteadOf to authenticate private repo access via env var rather than interpolating the token directly into the pip install URL, which would expose it in process listings and potentially in logs. --- .github/workflows/explosionbot.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/explosionbot.yml b/.github/workflows/explosionbot.yml index 78a27cfa3ba..af518e2c1fc 100644 --- a/.github/workflows/explosionbot.yml +++ b/.github/workflows/explosionbot.yml @@ -19,9 +19,11 @@ jobs: - uses: actions/setup-python@v4 - name: Install and run explosion-bot run: | - pip install git+https://${{ secrets.EXPLOSIONBOT_TOKEN }}@github.com/explosion/explosion-bot + git config --global url."https://x-access-token:${EXPLOSIONBOT_TOKEN}@github.com/".insteadOf "https://github.com/" + pip install git+https://github.com/explosion/explosion-bot python -m explosionbot env: + EXPLOSIONBOT_TOKEN: ${{ secrets.EXPLOSIONBOT_TOKEN }} INPUT_TOKEN: ${{ secrets.EXPLOSIONBOT_TOKEN }} INPUT_BK_TOKEN: ${{ secrets.BUILDKITE_SECRET }} ENABLED_COMMANDS: "test_gpu,test_slow,test_slow_gpu" From 7b9fe93d1365e6c5c9799742309293317171c570 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Mar 2026 11:45:46 +0100 Subject: [PATCH 31/32] Harden GitHub Actions: pin actions to SHA, add least-privilege permissions, remove debug logging --- .github/workflows/cibuildwheel.yml | 5 ++++- .github/workflows/explosionbot.yml | 6 ++++-- .github/workflows/issue-manager.yml | 6 +++++- .github/workflows/lock.yml | 2 +- .github/workflows/publish_pypi.yml | 4 +++- .github/workflows/spacy_universe_alert.yml | 13 ++++--------- .github/workflows/tests.yml | 10 ++++++---- .github/workflows/universe_validation.yml | 6 ++++-- 8 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 5f8ba9285ac..5f731a31595 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -7,9 +7,12 @@ on: # ** matches 'zero or more of any character' - 'release-v[0-9]+.[0-9]+.[0-9]+**' - 'prerelease-v[0-9]+.[0-9]+.[0-9]+**' + +permissions: {} + jobs: build_wheels: - uses: explosion/gha-cibuildwheel/.github/workflows/cibuildwheel.yml@main + uses: explosion/gha-cibuildwheel/.github/workflows/cibuildwheel.yml@2c98f757f13d112cf73fcf4b627249f1fffb5aae # main permissions: contents: write actions: read diff --git a/.github/workflows/explosionbot.yml b/.github/workflows/explosionbot.yml index af518e2c1fc..979385ccb90 100644 --- a/.github/workflows/explosionbot.yml +++ b/.github/workflows/explosionbot.yml @@ -6,6 +6,8 @@ on: - created - edited +permissions: {} + jobs: explosion-bot: if: github.repository_owner == 'explosion' @@ -15,8 +17,8 @@ jobs: env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 - name: Install and run explosion-bot run: | git config --global url."https://x-access-token:${EXPLOSIONBOT_TOKEN}@github.com/".insteadOf "https://github.com/" diff --git a/.github/workflows/issue-manager.yml b/.github/workflows/issue-manager.yml index 6c7d7d5a6f8..264707485e7 100644 --- a/.github/workflows/issue-manager.yml +++ b/.github/workflows/issue-manager.yml @@ -11,12 +11,16 @@ on: types: - labeled +permissions: {} + jobs: issue-manager: + permissions: + issues: write if: github.repository_owner == 'explosion' runs-on: ubuntu-latest steps: - - uses: tiangolo/issue-manager@0.4.0 + - uses: tiangolo/issue-manager@4d1b7e05935a404dc8337d30bd23be46be8bb8e5 # 0.4.0 with: token: ${{ secrets.GITHUB_TOKEN }} config: > diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 2bbdd64c771..8fcf3028476 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -16,7 +16,7 @@ jobs: if: github.repository_owner == 'explosion' runs-on: ubuntu-latest steps: - - uses: dessant/lock-threads@v5 + - uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5 with: process-only: 'issues' issue-inactive-days: '30' diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 9f432874cc2..fcc6f2a9999 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -8,6 +8,8 @@ on: types: - published +permissions: {} + jobs: upload_pypi: runs-on: ubuntu-latest @@ -21,7 +23,7 @@ jobs: # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') steps: - - uses: robinraju/release-downloader@v1 + - uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1 with: tag: ${{ github.event.release.tag_name }} fileName: '*' diff --git a/.github/workflows/spacy_universe_alert.yml b/.github/workflows/spacy_universe_alert.yml index 01731ffe0d7..ec0230699be 100644 --- a/.github/workflows/spacy_universe_alert.yml +++ b/.github/workflows/spacy_universe_alert.yml @@ -5,21 +5,16 @@ on: paths: - "website/meta/universe.json" +permissions: {} + jobs: build: if: github.repository_owner == 'explosion' runs-on: ubuntu-latest steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - PR_NUMBER: ${{github.event.number}} - run: | - echo "$GITHUB_CONTEXT" - - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 with: python-version: '3.10' - name: Install Bernadette app dependency and send an alert diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index feebfcee930..b20dba12f04 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,6 +19,8 @@ on: - "*.mdx" - "website/**" +permissions: {} + jobs: validate: name: Validate @@ -26,10 +28,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repo - uses: actions/checkout@v4 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Configure Python version - uses: actions/setup-python@v4 + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 with: python-version: "3.10" @@ -54,10 +56,10 @@ jobs: steps: - name: Check out repo - uses: actions/checkout@v4 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Configure Python version - uses: actions/setup-python@v4 + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 with: python-version: ${{ matrix.python_version }} diff --git a/.github/workflows/universe_validation.yml b/.github/workflows/universe_validation.yml index ce7df49dbae..e97850cd4b0 100644 --- a/.github/workflows/universe_validation.yml +++ b/.github/workflows/universe_validation.yml @@ -13,6 +13,8 @@ on: paths: - "website/meta/universe.json" +permissions: {} + jobs: validate: name: Validate @@ -20,10 +22,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repo - uses: actions/checkout@v4 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Configure Python version - uses: actions/setup-python@v4 + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 with: python-version: "3.7" From 9725c1ada3a7a9a675c1b46e71877b082894ae79 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Mar 2026 13:01:41 +0100 Subject: [PATCH 32/32] Require srsly >=2.5.3 for Python 3.14 cloudpickle fix --- requirements.txt | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1783984f6b3..50c6382bea3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ thinc>=8.3.12,<8.4.0 ml_datasets>=0.2.1,<0.3.0 murmurhash>=0.28.0,<1.1.0 wasabi>=0.9.1,<1.2.0 -srsly>=2.4.3,<3.0.0 +srsly>=2.5.3,<3.0.0 catalogue>=2.0.6,<2.1.0 typer>=0.3.0,<1.0.0 weasel>=1.0.0,<2.0.0 diff --git a/setup.cfg b/setup.cfg index ae36dac1c03..66cf942218b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,7 +52,7 @@ install_requires = preshed>=3.0.2,<3.1.0 thinc>=8.3.12,<8.4.0 wasabi>=0.9.1,<1.2.0 - srsly>=2.4.3,<3.0.0 + srsly>=2.5.3,<3.0.0 catalogue>=2.0.6,<2.1.0 weasel>=1.0.0,<2.0.0 confection>=1.1.0,<2.0.0