from tokenizer import tokenize

class TrendTracker(object):

	def __init__(self):
		self.users = {}
		self.words = {}
		self.initialize()

	def initialize(self):
		pass

	def track_message(self, user, message):
		self.users[user] = self.users.get(user, 0) + 1
		for word in tokenize(message):
			self.words[word] = self.words.get(word, 0) + 1

	def get_user_trend(self, limit=5):
		return sorted(self.users.keys(), key=lambda x: self.users[x], reverse=True)[:limit]

	def get_keyword_trend(self, limit=10):
		return sorted([k in self.words.keys() if len(k) > 1], key=lambda x: self.words[x], reverse=True)[:limit]

	def sync(self):
		pass

@@ -23,16 +23,46 @@
 tokenize
+%0Afrom datetime import datetime
 %0A%0Aclass 
@@ -137,24 +137,40 @@
 .words = %7B%7D%0A
+%09%09self.log = %5B%5D%0A
 %09%09self.initi
@@ -250,16 +250,38 @@
 ssage):%0A
+%09%09# Append statistics%0A
 %09%09self.u
@@ -321,16 +321,19 @@
  0) + 1%0A
+%09%09%0A
 %09%09for wo
@@ -357,16 +357,16 @@
 ssage):%0A
-
 %09%09%09self.
@@ -408,16 +408,136 @@
 0) + 1%0A%0A
+%09%09# Append log%0A%09%09self.log.append(%7B%0A%09%09%09%09'at': datetime.utcnow().isoformat(),%0A%09%09%09%09'by': user,%0A%09%09%09%09'text': message,%0A%09%09%09%7D)%0A%0A
 %09def get

Add internal logging