Skip to content

Commit

Permalink
Remove last remnants of TextBlob
Browse files Browse the repository at this point in the history
  • Loading branch information
suchow committed Jul 9, 2015
1 parent 0c216dc commit a8daa5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
10 changes: 4 additions & 6 deletions tests/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from unittest import TestCase
import os
from textblob import TextBlob
import codecs


Expand All @@ -24,8 +23,7 @@ def check(self, lst):

errors = []
for text in lst:
blob = TextBlob(text)
errors.append(self.this_check.check(blob))
errors.append(self.this_check.check(text))

return len(errors[0]) == 0

Expand All @@ -44,9 +42,9 @@ def test_wpe(self):

# Compute the number of words per (wpe) error.
with codecs.open(example_path, "r", encoding='utf-8') as f:
blob = TextBlob(f.read())
num_errors = len(self.this_check.check(blob))
num_words = len(blob.words)
text = f.read()
num_errors = len(self.this_check.check(text))
num_words = len(text.words)

try:
wpe = 1.0 * num_words / num_errors
Expand Down
11 changes: 3 additions & 8 deletions tests/test_garner_dates.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
from check import Check
from proselint.checks.garner import dates
from textblob import TextBlob


class TestCheck(Check):

__test__ = True

def test_50s_hyphenation(self):
text = TextBlob(
"""The 50's were swell."""
)
text = """The 50's were swell."""
errors = dates.check_decade_apostrophes_short(text)
assert len(errors) == 1

def test_50_Cent_hyphenation(self):
text = TextBlob(
"""Dr. Dre suggested to 50's manager that he look into signing
Eminem to the G-Unit record label."""
)
text = """Dr. Dre suggested to 50's manager that he look into signing
Eminem to the G-Unit record label."""
errors = dates.check_decade_apostrophes_short(text)
assert len(errors) == 0
20 changes: 7 additions & 13 deletions tests/test_topic_detector.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
from tools import topics
from textblob import TextBlob


class TestTopicDetector(object):

def test_50_Cent_detector_on_topic(self):
"""Check precision of the 50 Cent topic-detector."""
blob = TextBlob(
"""With the aid of Eminem and Dr. Dre (who produced his first
text = """With the aid of Eminem and Dr. Dre (who produced his first
major-label album, Get Rich or Die Tryin'), Jackson became one
of the world's best selling rappers and rose to prominence with
East Coast hip hop group G-Unit (which he leads de facto). """
)
assert("50 Cent" in topics(blob))

blob = TextBlob(
"""Hip hop was started in the early 50's."""
)
assert("50 Cent" not in topics(blob))
assert("50 Cent" in topics(text))

blob = TextBlob(
"""Nowadays it costs 50 cents to buy a lollipop."""
)
assert("50 Cent" not in topics(blob))
text = """Hip hop was started in the early 50's."""
assert("50 Cent" not in topics(text))

text = """Nowadays it costs 50 cents to buy a lollipop."""
assert("50 Cent" not in topics(text))

0 comments on commit a8daa5d

Please sign in to comment.