def calculate_favourite_word(self): # NOTA: Só procura na XII legislatura import datetime d = datetime.date(day=20, month=6, year=2011) if self.entry_set.filter(day__date__gt=d): self.favourite_word = text_utils.most_frequent_word(self.entry_set.filter(day__date__gt=d)) self.save()
def calculate_top5words(self): if self.entry_set.all(): top5words = text_utils.most_frequent_word(self.entry_set.all(), 5) words = [] for word, count in top5words: words.append({word: count}) wordict = {'words': words} self.top5words = wordict self.save() output = u"" for w in self.get_5words_list(): output += ' ' + w print output