本文整理汇总了Python中db.Database.high_phrase方法的典型用法代码示例。如果您正苦于以下问题:Python Database.high_phrase方法的具体用法?Python Database.high_phrase怎么用?Python Database.high_phrase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Database
的用法示例。
在下文中一共展示了Database.high_phrase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: int
# 需要导入模块: from db import Database [as 别名]
# 或者: from db.Database import high_phrase [as 别名]
HighPhrases = {}
HotPhrases = {}
BurstingPhrases = {}
while True:
try:
Time = time.time()
T = int(Time)
high = C.highvalue(limit=100)
hot = C.realtime_hot_phrases()
bursting = C.realtime_bursting_phrases()
print 'new'
for V in high['values']:
HighPhrases[V] = True
DB.high_phrase(V.split('bit.ly/')[1],T)
print V, T
for P in hot:
phrase = P['phrase']
HotPhrases[phrase] = sum(map(lambda x:x['visitors'],P['ghashes']))
DB.hot_phrase(phrase,T,HotPhrases[phrase])
print phrase, T, HotPhrases[phrase]
for P in bursting:
phrase = P['phrase']
BurstingPhrases[phrase] = sum(map(lambda x:x['visitors'],P['ghashes']))
DB.bursting_phrase(phrase,T,BurstingPhrases[phrase],P['mean'],P['rate'],P['std'])
print phrase, T, BurstingPhrases[phrase], P['mean'], P['rate'], P['std']
time.sleep(5*60-(time.time()-Time))
示例2: Database
# 需要导入模块: from db import Database [as 别名]
# 或者: from db.Database import high_phrase [as 别名]
DB = Database("crontracking.db")
HighPhrases = {}
HotPhrases = {}
BurstingPhrases = {}
try:
T = int(time.time())
high = C.highvalue(limit=100)
hot = C.realtime_hot_phrases()
bursting = C.realtime_bursting_phrases()
print "new"
for V in high["values"]:
HighPhrases[V] = True
DB.high_phrase(V.split("bit.ly/")[1], T)
print V, T
for P in hot:
phrase = P["phrase"]
HotPhrases[phrase] = sum(map(lambda x: x["visitors"], P["ghashes"]))
DB.hot_phrase(phrase, T, HotPhrases[phrase])
print phrase, T, HotPhrases[phrase]
for P in bursting:
phrase = P["phrase"]
BurstingPhrases[phrase] = sum(map(lambda x: x["visitors"], P["ghashes"]))
DB.bursting_phrase(phrase, T, BurstingPhrases[phrase], P["mean"], P["rate"], P["std"])
print phrase, T, BurstingPhrases[phrase], P["mean"], P["rate"], P["std"]
except Exception, er:
示例3: sum
# 需要导入模块: from db import Database [as 别名]
# 或者: from db.Database import high_phrase [as 别名]
HighPhrases = {}
HotPhrases = {}
BurstingPhrases = {}
errors = 0
while True:
try:
high = C.highvalue(limit=100)
hot = C.realtime_hot_phrases()
bursting = C.realtime_bursting_phrases()
print 'new'
for V in high['values']:
HighPhrases[V] = True
DB.high_phrase(V.split('bit.ly/')[1],time.time())
print V, time.time()
for P in hot:
phrase = P['phrase']
HotPhrases[phrase] = sum(map(lambda x:x['visitors'],P['ghashes']))
DB.hot_phrase(phrase,time.time(),HotPhrases[phrase])
print phrase, time.time(), HotPhrases[phrase]
for P in bursting:
phrase = P['phrase']
BurstingPhrases[phrase] = sum(map(lambda x:x['visitors'],P['ghashes']))
DB.bursting_phrase(phrase,time.time(),BurstingPhrases[phrase],P['mean'],P['rate'],P['std'])
print phrase, time.time(), BurstingPhrases[phrase], P['mean'], P['rate'], P['std']
errors = 0