mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-06-27 16:10:34 +08:00
Updates to test suite for text tags
This commit is contained in:
@@ -2,7 +2,7 @@ import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from indicoio.local import political, sentiment, fer, facial_features, language, image_features
|
||||
from indicoio.local import political, sentiment, fer, facial_features, language, image_features, text_tags
|
||||
|
||||
DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
@@ -20,11 +20,23 @@ class FullAPIRun(unittest.TestCase):
|
||||
self.assertTrue(vector.min() < minimum)
|
||||
self.assertTrue(np.ptp(vector) > span)
|
||||
|
||||
def test_document_classification(self):
|
||||
categories = set(['arts'])
|
||||
def test_text_tags(self):
|
||||
expected_keys = set(['fashion', 'art', 'energy', 'economics', 'entreprener',
|
||||
'books', 'politics', 'gardening', 'nba', 'conservative',
|
||||
'technology', 'startps', 'relationships', 'edcation',
|
||||
'hmor', 'psychology', 'bicycling', 'investing', 'travel',
|
||||
'cooking', 'christianity', 'environment', 'religion', 'health',
|
||||
'hockey', 'pets', 'msic', 'soccer', 'gns', 'gaming', 'jobs',
|
||||
'bsiness', 'natre', '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 = classification(text)
|
||||
self.assertTrue(categories < set(results.keys()))
|
||||
results = text_tags(text)
|
||||
max_keys = sorted(results.keys(), key=lambda x:results.get(x), reverse=True)
|
||||
assert 'politics' in max_keys[:3]
|
||||
self.assertTrue(expected_keys == set(results.keys()))
|
||||
|
||||
def test_political(self):
|
||||
political_set = set(['Libertarian', 'Liberal', 'Conservative', 'Green'])
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
import numpy as np
|
||||
import skimage.io
|
||||
|
||||
from indicoio import political, sentiment, fer, facial_features, language, image_features, classification
|
||||
from indicoio import political, sentiment, fer, facial_features, language, image_features, text_tags
|
||||
|
||||
DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
@@ -22,11 +22,23 @@ class FullAPIRun(unittest.TestCase):
|
||||
self.assertTrue(vector.min() < minimum)
|
||||
self.assertTrue(np.ptp(vector) > span)
|
||||
|
||||
def test_document_classification(self):
|
||||
categories = set(['arts'])
|
||||
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 = classification(text)
|
||||
self.assertTrue(categories < set(results.keys()))
|
||||
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)
|
||||
|
||||
def test_political(self):
|
||||
political_set = set(['Libertarian', 'Liberal', 'Conservative', 'Green'])
|
||||
|
||||
Reference in New Issue
Block a user