Skip to content

Commit

Permalink
Merge branch 'SummerOfCode-NoHate-travis_ci_reorg'
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesomi committed Sep 14, 2020
2 parents 2b8c617 + b880515 commit a82f848
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ install:
# 'python3' is a 'command not found' error on Windows but 'py' works on Windows only
script:
- black --check .
- python -m unittest discover -s tests -t . || python3 -m unittest discover -s tests -t .
- python -m unittest discover -s tests -t . || python3 -m unittest discover -s tests -t .
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ dev =
nbsphinx
parameterized>=0.7.4
coverage
pre-commit
pre-commit
2 changes: 1 addition & 1 deletion tests/test_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ def test_pos(self):
]
)

self.assertEquals(pos_tagging, s_true)
self.assertEqual(pos_tagging, s_true)
2 changes: 1 addition & 1 deletion tests/test_representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_vectorization_not_tokenized_yet_warning(self, name, test_function, *arg
@parameterized.expand(test_cases_vectorization)
def test_vectorization_arguments_to_sklearn(self, name, test_function, *args):
try:
test_function(s_not_tokenized, max_features=1, min_df=1, max_df=1.0)
test_function(s_tokenized, max_features=1, min_df=1, max_df=1.0)
except TypeError:
self.fail("Sklearn arguments not handled correctly.")

Expand Down
2 changes: 1 addition & 1 deletion texthero/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def handle_nans(replace_nans_with):
... def replace_b_with_c(s):
... return s.str.replace("b", "c")
>>> s_with_nan = pd.Series(["Test b", np.nan])
>>> replace_b_with_c(s_with_nan)
>>> replace_b_with_c(s_with_nan) # doctest: +SKIP
0 Test c
1 I was missing!
dtype: object
Expand Down
17 changes: 9 additions & 8 deletions texthero/nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import spacy
import pandas as pd
import en_core_web_sm
from nltk.stem import PorterStemmer, SnowballStemmer

from texthero._types import TextSeries, InputSeries


Expand Down Expand Up @@ -54,9 +54,9 @@ def named_entities(s: TextSeries, package="spacy") -> pd.Series:
"""
entities = []

nlp = spacy.load("en_core_web_sm", disable=["tagger", "parser"])
# nlp.pipe is now 'ner'
nlp = en_core_web_sm.load(disable=["tagger", "parser"])

# nlp.pipe is now 'ner'
for doc in nlp.pipe(s.astype("unicode").values, batch_size=32):
entities.append(
[(ent.text, ent.label_, ent.start_char, ent.end_char) for ent in doc.ents]
Expand Down Expand Up @@ -93,9 +93,9 @@ def noun_chunks(s: TextSeries) -> pd.Series:

noun_chunks = []

nlp = spacy.load("en_core_web_sm", disable=["ner"])
# nlp.pipe is now "tagger", "parser"
nlp = en_core_web_sm.load(disable=["ner"])

# nlp.pipe is now "tagger", "parser"
for doc in nlp.pipe(s.astype("unicode").values, batch_size=32):
noun_chunks.append(
[
Expand Down Expand Up @@ -131,7 +131,8 @@ def count_sentences(s: TextSeries) -> pd.Series:
"""
number_of_sentences = []

nlp = spacy.load("en_core_web_sm", disable=["tagger", "parser", "ner"])
nlp = en_core_web_sm.load(disable=["tagger", "parser", "ner"])

nlp.add_pipe(nlp.create_pipe("sentencizer")) # Pipe is only "sentencizer"

for doc in nlp.pipe(s.values, batch_size=32):
Expand Down Expand Up @@ -204,9 +205,9 @@ def pos_tag(s: TextSeries) -> pd.Series:

pos_tags = []

nlp = spacy.load("en_core_web_sm", disable=["parser", "ner"])
# nlp.pipe is now "tagger"
nlp = en_core_web_sm.load(disable=["parser", "ner"])

# nlp.pipe is now "tagger"
for doc in nlp.pipe(s.astype("unicode").values, batch_size=32):
pos_tags.append(
[
Expand Down

0 comments on commit a82f848

Please sign in to comment.