本文整理汇总了Python中factual.Factual.boost方法的典型用法代码示例。如果您正苦于以下问题:Python Factual.boost方法的具体用法?Python Factual.boost怎么用?Python Factual.boost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类factual.Factual
的用法示例。
在下文中一共展示了Factual.boost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FactualAPITestSuite
# 需要导入模块: from factual import Factual [as 别名]
# 或者: from factual.Factual import boost [as 别名]
#.........这里部分代码省略.........
q = self.facets.search("starbucks").select("country")
results = q.data()['country']
self.assertTrue(results['us'] > 5000)
self.assertTrue(results['ca'] > 200)
def test_facets2(self):
q = self.facets.search("starbucks").select("locality,region").filters({"country":"US"})
locality = q.data()['locality']
region = q.data()['region']
self.assertTrue(locality['chicago'] > 50)
self.assertTrue(region['tx'] > 200)
def test_facets_geo(self):
q = self.facets.select("locality").geo(circle(34.06018, -118.41835, 1000))
locality = q.data()['locality']
self.assertTrue(locality['los angeles'] > 3000)
self.assertTrue(locality['beverly hills'] > 500)
def test_geopulse(self):
geopulse = self.factual.geopulse(point(34.06021, -118.41828))
income_only = geopulse.select('income')
all_results = geopulse.data()
income_results = income_only.data()
self.assertIn('demographics', all_results)
demographics = all_results['demographics']
self.assertIn('area_statistics', demographics)
area_statistics = demographics['area_statistics']
self.assertIn('commercial_residential', area_statistics)
commercial_residential = area_statistics['commercial_residential']
self.assertTrue(0 <= commercial_residential['business'] <= 100)
income_demographics = income_results['demographics']
self.assertEqual(1, len(income_demographics))
self.assertIn('income', income_demographics)
def test_geocode(self):
geocode = self.factual.geocode(point(34.058744, -118.416937))
result = geocode.data()[0]
self.assertEqual('1999 Avenue Of The Stars', result['address'])
self.assertLess(result['$distance'], 20)
def test_submit_without_id(self):
values = {'longitude': 100}
submit = self.factual.submit('us-sandbox', values=values).user('python_driver_tester')
response = submit.write()
if 'new_entity' in response:
self.assertTrue(response['new_entity'])
else:
self.assertIn('status', response)
self.assertEqual('warning', response['status'])
def test_submit_with_id(self):
values = {'longitude': 100}
submit = self.factual.submit('us-sandbox', factual_id=SANDBOX_UUID, values=values).user('python_driver_tester')
response = submit.write()
if 'new_entity' in response:
self.assertFalse(response['new_entity'])
else:
self.assertIn('status', response)
self.assertEqual('warning', response['status'])
def test_clear(self):
clear = self.factual.clear('us-sandbox', SANDBOX_UUID, 'latitude,longitude').user('python_driver_tester')
response = clear.write()
self.assertIn('commit_id', response)
self.assertGreater(len(response['commit_id']), 0)
def test_flag(self):
flag = self.factual.flag('us-sandbox', SANDBOX_UUID).user('python_driver_tester').other().debug(True)
response = flag.write()
self.assertEqual('ok', response['status'])
def test_diffs(self):
diffs = self.factual.diffs('places-us', 1372694400000, 1372695300000).data()
self.assertGreater(len(diffs), 0)
def test_diffs_streaming(self):
diff_request = self.factual.diffs('places-us', 1372694400000, 1372695300000)
batch = diff_request.data()
streamed = list(diff_request.stream())
self.assertSequenceEqual(batch, streamed)
def test_match(self):
match = self.factual.match('places-us', {'name':'McDonalds','address':'10451 Santa Monica Blvd','locality':'Los Angeles','region':'CA'})
match_id = match.get_id()
self.assertEqual('c730d193-ba4d-4e98-8620-29c672f2f117', match_id)
def test_multi(self):
q1 = self.factual.table('places').filters({'postcode':'90067'})
q2 = self.factual.facets('places').filters({'postcode':'90067'}).select('category_labels')
response = self.factual.multi({'query1':q1,'query2':q2})
self.assertTrue('query1' in response and 'query2' in response)
def test_get_row(self):
row = self.factual.get_row('places', FACTUAL_UUID)
self.assertEqual('Factual', row['name'])
def test_boost(self):
boost = self.factual.boost('us-sandbox', SANDBOX_UUID).user('python_driver_tester')
response = boost.write()
self.assertEqual('ok', response['status'])