-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Update_setup
- Loading branch information
Showing
11 changed files
with
160 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Configuration: https://dependabot.com/docs/config-file/ | ||
# Docs: https://docs.github.com/en/github/administering-a-repository/keeping-your-dependencies-updated-automatically | ||
|
||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
allow: | ||
- dependency-type: "all" | ||
commit-message: | ||
prefix: ":arrow_up:" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
allow: | ||
- dependency-type: "all" | ||
commit-message: | ||
prefix: ":arrow_up:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,115 @@ | ||
import spacy | ||
from spacy.tokens import Doc | ||
from spacy.lang.en import English | ||
import pytest | ||
from textdescriptives.components import POSStatistics | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def nlp(): | ||
nlp = spacy.load("en_core_web_sm", disable=('ner', 'textcat')) | ||
nlp = spacy.load("en_core_web_sm", disable=("ner", "textcat")) | ||
nlp.add_pipe("pos_stats") | ||
|
||
return nlp | ||
|
||
def test_pos_integrations(nlp): | ||
assert "pos_stats" == nlp.pipe_names[-1] | ||
|
||
def test_pos_proportions_doc(nlp): | ||
doc = nlp( | ||
"Here is the first sentence. It was pretty short. Let's make another one that's slightly longer and more complex." | ||
@pytest.fixture(scope="function") | ||
def doc(nlp): | ||
words = [ | ||
"Here", | ||
"is", | ||
"the", | ||
"first", | ||
"sentence", | ||
".", | ||
"It", | ||
"was", | ||
"pretty", | ||
"short", | ||
".", | ||
"Let", | ||
"'s", | ||
"make", | ||
"another", | ||
"one", | ||
"that", | ||
"'s", | ||
"slightly", | ||
"longer", | ||
"and", | ||
"more", | ||
"complex", | ||
".", | ||
] | ||
pos = [ | ||
"ADV", | ||
"AUX", | ||
"DET", | ||
"ADJ", | ||
"NOUN", | ||
"PUNCT", | ||
"PRON", | ||
"AUX", | ||
"ADV", | ||
"ADJ", | ||
"PUNCT", | ||
"VERB", | ||
"PRON", | ||
"VERB", | ||
"DET", | ||
"NOUN", | ||
"PRON", | ||
"AUX", | ||
"ADV", | ||
"ADJ", | ||
"CCONJ", | ||
"ADV", | ||
"ADJ", | ||
"PUNCT", | ||
] | ||
doc = Doc( | ||
nlp.vocab, | ||
words=words, | ||
pos=pos, | ||
) | ||
return doc | ||
|
||
|
||
def test_pos_integrations(nlp): | ||
assert "pos_stats" == nlp.pipe_names[-1] | ||
|
||
assert doc._.pos_proportions == pytest.approx({'pos_prop_ADV': 0.1666, 'pos_prop_AUX': 0.0833, 'pos_prop_DET': 0.125, 'pos_prop_ADJ': 0.1666, 'pos_prop_NOUN': 0.0833, 'pos_prop_PUNCT': 0.125, 'pos_prop_PRON': 0.0833, 'pos_prop_VERB': 0.125, 'pos_prop_CCONJ': 0.0416}, rel=1e-2) | ||
|
||
def test_pos_proportions_span(nlp): | ||
doc = nlp( | ||
"Here is the first sentence. It was pretty short. Let's make another one that's slightly longer and more complex." | ||
def test_pos_proportions_doc(doc): | ||
assert doc._.pos_proportions == pytest.approx( | ||
{ | ||
"pos_prop_ADV": 0.1666, | ||
"pos_prop_AUX": 0.125, | ||
"pos_prop_DET": 0.083, | ||
"pos_prop_ADJ": 0.1666, | ||
"pos_prop_NOUN": 0.0833, | ||
"pos_prop_PUNCT": 0.125, | ||
"pos_prop_PRON": 0.125, | ||
"pos_prop_VERB": 0.083, | ||
"pos_prop_CCONJ": 0.0416, | ||
}, | ||
rel=0.05, | ||
) | ||
|
||
span = doc[0:] | ||
|
||
assert doc._.pos_proportions == pytest.approx({'pos_prop_ADV': 0.1666, 'pos_prop_AUX': 0.0833, 'pos_prop_DET': 0.125, 'pos_prop_ADJ': 0.1666, 'pos_prop_NOUN': 0.0833, 'pos_prop_PUNCT': 0.125, 'pos_prop_PRON': 0.0833, 'pos_prop_VERB': 0.125, 'pos_prop_CCONJ': 0.0416}, rel=1e-2) | ||
|
||
def test_pos_proportions_span(doc): | ||
span = doc[:] | ||
|
||
assert span._.pos_proportions == pytest.approx( | ||
{ | ||
"pos_prop_ADV": 0.1666, | ||
"pos_prop_AUX": 0.125, | ||
"pos_prop_DET": 0.083, | ||
"pos_prop_ADJ": 0.1666, | ||
"pos_prop_NOUN": 0.0833, | ||
"pos_prop_PUNCT": 0.125, | ||
"pos_prop_PRON": 0.125, | ||
"pos_prop_VERB": 0.083, | ||
"pos_prop_CCONJ": 0.0416, | ||
}, | ||
rel=0.01, | ||
) |