예제 #1
0
class SamplerTestCase(unittest.TestCase):
    def setUp(self):
        client_id = "QhqrWe9agsd0Ad6Gs0qgMQ"
        client_secret = "6WQWRMV8edOhaThyWgm96wAJkIzJ1pHOhm5N0AD20edrnzv0lwi3wfgZAFp0IqQ6WIc-pZki83kjpViwptlcsiV0-Ij3HI6AJxhOTE4jsjNOoZOHZI3823twg8yZWXYx"
        search_term = 'term'
        parameters = {'limit': 50, 'location': 'AZ'}
        self.yelp = SearchApi(client_id=client_id,
                              client_secret=client_secret,
                              top_k=300,
                              delay=5,
                              search_term=search_term,
                              **parameters)

    def test_sota_sampler(self):
        local_file = os.path.abspath(
            os.path.dirname(__file__) + os.path.sep +
            "../../") + '/yelp_example/yelp_3000_AZ.csv'
        localdata = LocalData(local_file, 'csv', "business_id", ["name"],
                              ["name", "full_address"])
        localdata_ids, localdata_query, localdata_er = localdata.getlocalData()
        initQueries = utils.queryGene(localdata_query, 2)
        sampler.sota_sampler(query_pool=initQueries,
                             api=self.yelp,
                             match_term=localdata.getQueryList(),
                             top_k=300,
                             adjustment=1,
                             samplenum=1)
        self.yelp.getSession().close()
        assert True
예제 #2
0
class SamplerTestCase(unittest.TestCase):
    def setUp(self):
        client_id = "kCe2YbZePXsPnC204ZrXoQ"
        client_secret = "s9KnvEEQW7jaA2wlrBi4X2fnDQ0F7asdklXVvJUidWp8i50ov24E8EjkHX2AUhoL"
        search_term = 'term'
        parameters = {'limit': 50, 'location': 'AZ'}
        self.yelp = SearchApi(client_id=client_id,
                              client_secret=client_secret,
                              top_k=300,
                              delay=5,
                              search_term=search_term,
                              **parameters)

    def test_sota_sampler(self):
        local_file = os.path.abspath(
            os.path.dirname(__file__) + os.path.sep +
            "../../") + '/example/yelp_3000.pkl'
        localdata = LocalData(local_file, 'pkl', "row['business_id']",
                              ["row['name']"],
                              ["row['name']", "row['full_address']"])
        localdata_ids, localdata_query, localdata_er = localdata.getlocalData()
        initQueries = utils.queryGene(localdata_query, 2)
        sampler.sota_sampler(query_pool=initQueries,
                             api=self.yelp,
                             match_term=localdata.getQueryList(),
                             top_k=300,
                             adjustment=1,
                             samplenum=1)
        self.yelp.getSession().close()
        assert True
예제 #3
0
class YelpSearchapiTestCase(unittest.TestCase):
    def setUp(self):
        client_id = "kCe2YbZePXsPnC204ZrXoQ"
        client_secret = "s9KnvEEQW7jaA2wlrBi4X2fnDQ0F7asdklXVvJUidWp8i50ov24E8EjkHX2AUhoL"
        search_term = 'term'
        parameters = {'limit': 50, 'location': 'AZ'}
        self.yelp = SearchApi(client_id=client_id, client_secret=client_secret, top_k=1000, delay=5,
                              search_term=search_term,
                              **parameters)

    def tearDown(self):
        self.yelp = None

    def test_callApi(self):
        query = ['tai', 'restaurant']
        params = self.yelp.getKwargs()
        params[self.yelp.getSearchTerm()] = '+'.join(query)
        params['offset'] = 0
        results = self.yelp.callAPI(params)
        assert len(results) >= 20

    def test_callMulApi_term(self):
        queries = [['tai'], ['restaurant']]
        results = self.yelp.callMulAPI(queries)
        assert len(results) >= 1000

    def test_callMulApi_categories(self):
        self.yelp.setSearchTerm('categories')
        categories = [['bars'], ['french']]
        results = self.yelp.callMulAPI(categories)
        print len(results)
        assert len(results) >= 700

    def test_callMulApi_sort(self):
        self.yelp.setSearchTerm('sort_by')
        sort_by = [['rating'], ['best_match']]
        results = self.yelp.callMulAPI(sort_by)
        self.yelp.getSession().close()
        assert len(results) >= 1000
예제 #4
0
class YelpSearchapiTestCase(unittest.TestCase):
    def setUp(self):
        client_id = "QhqrWe9agsd0Ad6Gs0qgMQ"
        client_secret = "6WQWRMV8edOhaThyWgm96wAJkIzJ1pHOhm5N0AD20edrnzv0lwi3wfgZAFp0IqQ6WIc-pZki83kjpViwptlcsiV0-Ij3HI6AJxhOTE4jsjNOoZOHZI3823twg8yZWXYx"
        search_term = 'term'
        parameters = {'limit': 50, 'location': 'AZ'}
        self.yelp = SearchApi(client_id=client_id, client_secret=client_secret, top_k=300, delay=5,
                              search_term=search_term,
                              **parameters)

    def tearDown(self):
        self.yelp = None

    def test_callApi(self):
        query = ['tai', 'restaurant']
        params = self.yelp.getKwargs()
        params[self.yelp.getSearchTerm()] = '+'.join(query)
        params['offset'] = 0
        results = self.yelp.callAPI(params)
        assert len(results) >= 20

    def test_callMulApi_term(self):
        queries = [['tai'], ['restaurant']]
        results = self.yelp.callMulAPI(queries)
        assert len(results) >= 200

    def test_callMulApi_categories(self):
        self.yelp.setSearchTerm('categories')
        categories = [['bars'], ['french']]
        results = self.yelp.callMulAPI(categories)
        assert len(results) >= 200

    def test_callMulApi_sort(self):
        self.yelp.setSearchTerm('sort_by')
        sort_by = [['rating'], ['best_match']]
        results = self.yelp.callMulAPI(sort_by)
        self.yelp.getSession().close()
        assert len(results) >= 200
예제 #5
0
from deeperlib.api.yelp.searchapi import SearchApi
from deeperlib.core import utils
from deeperlib.data_processing.local_data import LocalData
from deeperlib.estimator import sampler

# ==== Sota-Sampler Yelp ====
client_id = "kCe2YbZePXsPnC204ZrXoQ"
client_secret = "s9KnvEEQW7jaA2wlrBi4X2fnDQ0F7asdklXVvJUidWp8i50ov24E8EjkHX2AUhoL"
search_term = 'term'
parameters = {'limit': 50, 'location': 'AZ'}
yelp = SearchApi(client_id=client_id,
                 client_secret=client_secret,
                 top_k=300,
                 delay=5,
                 search_term=search_term,
                 **parameters)
local_file = 'yelp_3000.pkl'
localdata = LocalData(local_file, 'pkl', "row['business_id']", ["row['name']"],
                      ["row['name']", "row['full_address']"])
localdata_ids, localdata_query, localdata_er = localdata.getlocalData()
initQueries = utils.queryGene(localdata_query, 2)
sampler.sota_sampler(query_pool=initQueries,
                     api=yelp,
                     match_term=localdata.getQueryList(),
                     top_k=300,
                     adjustment=1)
yelp.getSession().close()