Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit cb94e1b

Browse files
author
Sean Myers
committed
Fixed CATEGORIES TO CATEGORY
1 parent 733b3bb commit cb94e1b

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

category_predictor/test_category_predictor.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
LONG_TEXT = "Hello world" * 101
1616
TEXT = u"Hello"
1717
BIZ_ID = u"Yelp"
18-
CATEGORIES = u'Company'
18+
CATEGORY = u'Company'
1919

2020

2121
class TestCategoryPredictor(TestCase):
2222

2323
def test_smoke(self):
2424
"""Does a complete run with mock data"""
25-
business = BUSINESS_TEMPLATE % (CATEGORIES, BIZ_ID)
25+
business = BUSINESS_TEMPLATE % (CATEGORY, BIZ_ID)
2626
review = REVIEW_TEMPLATE % (LONG_TEXT, BIZ_ID)
2727
total_input = business + review
2828
static_stdin = StringIO(total_input)
@@ -38,35 +38,35 @@ def test_smoke(self):
3838
results.append(value)
3939

4040
# Results should be the probability of that category being chosen.
41-
result = {CATEGORIES: 1}
41+
result = {CATEGORY: 1}
4242
self.assertEqual(results[0], result)
4343

4444
def test_review_category(self):
4545
"""Tests the category_mapper to make sure it is properly running"""
46-
business = BUSINESS_TEMPLATE % (CATEGORIES, BIZ_ID)
46+
business = BUSINESS_TEMPLATE % (CATEGORY, BIZ_ID)
4747
review = REVIEW_TEMPLATE % (TEXT, BIZ_ID)
4848
job = CategoryPredictor()
4949
review_results = list(job.review_category_mapper(None, json.loads(review)))
5050
biz_results = list(job.review_category_mapper(None, json.loads(business)))
5151
self.assertEqual(review_results, [(BIZ_ID, ('review', TEXT))])
52-
self.assertEqual(biz_results, [(BIZ_ID, ('categories', [CATEGORIES]))])
52+
self.assertEqual(biz_results, [(BIZ_ID, ('categories', [CATEGORY]))])
5353

5454
def test_categories_to_reviews(self):
5555
"""Tests add_categories_to_reviews to make sure it is properly running"""
56-
category = [('categories', [CATEGORIES]), ('review', TEXT)]
56+
category = [('categories', [CATEGORY]), ('review', TEXT)]
5757

5858
job = CategoryPredictor()
5959
category_results = list(job.add_categories_to_reviews_reducer(BIZ_ID, category))
60-
result = [('all', {CATEGORIES: 1}), (CATEGORIES, TEXT)]
60+
result = [('all', {CATEGORY: 1}), (CATEGORY, TEXT)]
6161
self.assertEqual(category_results,result)
6262

6363
def test_tokenize_reviews(self):
6464
"""Tests tokenize_reviews_mapper to make sure it is properly running"""
65-
review = {CATEGORIES: 1}
65+
review = {CATEGORY: 1}
6666

6767
job = CategoryPredictor()
6868
token_results = list(job.tokenize_reviews_mapper('all', review))
69-
result = [('all', {CATEGORIES: 1})]
69+
result = [('all', {CATEGORY: 1})]
7070
self.assertEqual(token_results, result)
7171

7272

review_autopilot/test_autopilot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from autopilot import ReviewAutoPilot
88

99
# These are used to create stdin string data.
10-
CATEGORIES = 'Company'
10+
CATEGORY = 'Company'
1111
REVIEW_TEMPLATE = '{"type":"review", "stars":3, "text":"%s",\
1212
"business_id":"%s"}\n'
1313
BUSINESS_TEMPLATE = '{"type":"business", "categories": "%s",\
@@ -46,7 +46,7 @@ def test_smoke(self):
4646
text = ('foo bar foo baz foo car foo daz ' + ('foo ' * 10) + 'foofoo yelp'
4747
'foo yar foo foo bar bar dar')
4848
single_review = REVIEW_TEMPLATE % (text, BIZ)
49-
business = BUSINESS_TEMPLATE % (CATEGORIES, BIZ)
49+
business = BUSINESS_TEMPLATE % (CATEGORY, BIZ)
5050
static_stdin = StringIO(single_review + business)
5151

5252
job = ReviewAutoPilot(['-r', 'inline', '--no-conf', '-'])
@@ -67,16 +67,16 @@ def test_categories_reducer(self):
6767
"""Tests join_reviews_with_categories_reducer with null data and some
6868
static data."""
6969
job = ReviewAutoPilot()
70-
VALUES = (('business', {'categories': CATEGORIES}), ('review', TEXT))
70+
VALUES = (('business', {'categories': CATEGORY}), ('review', TEXT))
7171
category_results = list(job.join_reviews_with_categories_reducer(BIZ, VALUES))
72-
results = [(CATEGORIES, TEXT)]
72+
results = [(CATEGORY, TEXT)]
7373
self.assertEqual(category_results, results)
7474

7575
def test_split_mapper(self):
7676
"""Tests split_mapper reducer in autopilot"""
7777
job = ReviewAutoPilot()
7878
TEST_RETURN = (('hello', 'C'), ('<end>', 1))
79-
self.assertEqual(job.review_split_mapper(CATEGORIES, TEXT).next(),
79+
self.assertEqual(job.review_split_mapper(CATEGORY, TEXT).next(),
8080
TEST_RETURN)
8181

8282

0 commit comments

Comments
 (0)