Skip to content

Commit

Permalink
test: multiprocessing in quality component
Browse files Browse the repository at this point in the history
  • Loading branch information
HLasse committed Dec 15, 2022
1 parent f16443f commit de9126b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions textdescriptives/tests/test_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from typing import List, Tuple

import ftfy
import pytest
import spacy

Expand All @@ -18,6 +19,8 @@
top_ngram_chr_fraction,
)

from .books import flatland, oliver_twist, secret_garden


@pytest.fixture
def nlp():
Expand Down Expand Up @@ -254,3 +257,12 @@ def test_passed_quality_check(text: str, passed: bool, nlp: spacy.Language):
nlp.add_pipe("textdescriptives.quality", config={"force": True})
doc = nlp(text)
assert doc._.passed_quality_check == passed


def test_quality_multi_process(nlp):
texts = [oliver_twist, secret_garden, flatland]
texts = [ftfy.fix_text(text) for text in texts]

docs = nlp.pipe(texts, n_process=3)
for doc in docs:
assert doc._.quality

0 comments on commit de9126b

Please sign in to comment.