mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-06-27 16:10:34 +08:00
Tests for updated text tags api
This commit is contained in:
@@ -13,3 +13,4 @@ v0.4.4, Thu Sep 25 -- Added dependencies installation to setup.py
|
||||
v0.4.5, Thu Sep 25 -- Added interface to local indico server
|
||||
v0.4.6, Fri Oct 27 -- Updated to point to new indico api servers, cleaner REST API
|
||||
v0.4.8, Fri Nov 7 -- Updated API interface to include new text tags API
|
||||
v0.4.11, Wed Dec 18 -- Updated tests for text tags
|
||||
@@ -3,7 +3,7 @@ import indicoio.config as config
|
||||
|
||||
JSON_HEADERS = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||
|
||||
Version, version, __version__, VERSION = ('0.4.5',) * 4
|
||||
Version, version, __version__, VERSION = ('0.4.11',) * 4
|
||||
|
||||
from indicoio.text.sentiment import political, posneg
|
||||
from indicoio.text.sentiment import posneg as sentiment
|
||||
|
||||
@@ -8,7 +8,7 @@ except ImportError:
|
||||
|
||||
setup(
|
||||
name="IndicoIo",
|
||||
version='0.4.8',
|
||||
version='0.4.11',
|
||||
packages=[
|
||||
"indicoio",
|
||||
"indicoio.text",
|
||||
|
||||
@@ -23,22 +23,10 @@ class FullAPIRun(unittest.TestCase):
|
||||
self.assertTrue(np.ptp(vector) > span)
|
||||
|
||||
def test_text_tags(self):
|
||||
expected_keys = set(['fashion', 'art', 'energy', 'economics', 'entrepreneur',
|
||||
'books', 'politics', 'gardening', 'nba', 'conservative',
|
||||
'technology', 'startups', 'relationships', 'education',
|
||||
'humor', 'psychology', 'bicycling', 'investing', 'travel',
|
||||
'cooking', 'christianity', 'environment', 'religion', 'health',
|
||||
'hockey', 'pets', 'music', 'soccer', 'guns', 'gaming', 'jobs',
|
||||
'business', 'nature', 'food', 'cars', 'photography', 'philosophy',
|
||||
'geek', 'sports', 'baseball', 'news', 'television', 'entertainment',
|
||||
'parenting', 'comics', 'science', 'nfl','programming',
|
||||
'personalfinance', 'atheism', 'movies', 'anime', 'fitness',
|
||||
'military', 'realestate', 'history'])
|
||||
text = "On Monday, president Barack Obama will be..."
|
||||
results = text_tags(text)
|
||||
max_keys = sorted(results.keys(), key=lambda x:results.get(x), reverse=True)
|
||||
assert 'politics' in max_keys[:3]
|
||||
self.assertFalse(set(results.keys()) - expected_keys)
|
||||
assert 'political_discussion' in max_keys[:5]
|
||||
|
||||
def test_political(self):
|
||||
political_set = set(['Libertarian', 'Liberal', 'Conservative', 'Green'])
|
||||
|
||||
Reference in New Issue
Block a user