def getresponse(self):
     response = {}
     items = self.getrateditems()
     if items == []:
         return self.geterrorresponse("Items could not be rated")
     else:
         (summary, tweettext) = self.getsummary(items)
         blogcontent = [i.content for i in self.items]
         (infogain1, infogain2) = util.informationgaincompare(" ".join(blogcontent), tweettext, self.title)
         response['status'] = 200
         response['content'] = {'summary':summary, 'tweettext':tweettext, 'tweettextinfogain':infogain1, 'titleinfogain':infogain2}
         response['title'] = self.title
         return json.dumps(response)
 def getrecommenderbasedresponse(self):
     response = {}
     r = Recommender(self.lambda1)
     r.creatematrix(self.items, self.tweets)
     r.calcaggregateratings()
     items = r.getrecommenderrateditems()
     if items == []:
         return self.geterrorresponse("Items could not be rated as per the recommender system")
     else:
         (summary, tweettext) = self.getsummary(items)
         blogcontent = [i.content for i in self.items]
         (infogain1, infogain2) = util.informationgaincompare(" ".join(blogcontent), tweettext, self.title)
         response['status'] = 200
         response['content'] = {'summary':summary, 'tweettext':tweettext, 'tweettextinfogain':infogain1, 'titleinfogain':infogain2}
         response['title'] = self.title
         return json.dumps(response)
     return response