Пример #1
0
def trending_concepts():
	#first lets get out data from Keen
	complist = connect.compList()
	#print complist
	keenOut = extractcompdata(complist)
	for aggs in keenOut:
		if aggs.has_key('aggtags'):
			#turn to lower

			for tags in aggs['aggtags']:
				tags = tags.lower()
	print len(keenOut)
	print keenOut[0]['screen_names']
	print keenOut[0]['aggtags']
	comp_names =[]
	hash_tags =[]
	total = Counter()
	compTotal = Counter()
	for a in range(len(keenOut)):
		if keenOut[a].has_key('aggtags'):
			#access list and determine tweets with hashtags
			total.update(keenOut[a]['aggtags'][b].lower() for b in range(len(keenOut[a]['aggtags'])))
					
		
	#listof tuple of competitors and Collections
	collectList=[]
		
# 	#loop through competitors and build counts
	for comps in complist:
		#create counter
		temp = comps
		print temp
		temps = Counter()
		for a in range(len(keenOut)):

			if keenOut[a]['screen_names'] == comps and keenOut[a].has_key('aggtags'):
			
				temps.update(element.lower() for element in keenOut[a]['aggtags'])

		collectList.append(temps.most_common(5))

					
	grandList = zip(complist,collectList)			
	#pprint.pprint (total.most_common(10))	
	#pprint.pprint( grandList)
	return grandList
Пример #2
0
def competitors():
	try:
		#get users time line
		competitors = connections.compList()
		
		outputList = []
		print "we'll be searching and updating Keen IO with tweets from %s" % competitors
		
		for name in competitors:
			timeOutlist = usertimeline(name)
			if len(timeOutlist) > 0:
				outputList.append(timeOutlist)
			
			#tweetcounts(name,"User Timeline")
		print "FINAL - - - - -"
		print "count of List output %d" % len(outputList)

		#pprint.pprint (outputList)
		return outputList
	except Exception, e:
		print e
Пример #3
0
def trending_concepts_total(time_period):
	#first lets get out data from Keen
	complist = connect.compList()
	#print complist
	keenOut = extractcompdata_time(complist,time_period)
	for aggs in keenOut:
		if aggs.has_key('hashtags'):
			#turn to lower
			for tags in aggs['hashtags']:
				tags = tags.lower()
	print len(keenOut)
	comp_names =[]
	hash_tags =[]
	total = Counter()
	compTotal = Counter()
	for a in range(len(keenOut)):
		print keenOut[a]
		if keenOut[a].has_key('hashtags'):
			#access list and determine tweets with hashtags
			total.update(keenOut[a]['hashtags'][b].lower() for b in range(len(keenOut[a]['hashtags'])))
						
	return total.most_common(5)