示例#1
0
    def get_result(self, tid):
        self.tid = tid
        potato = Project(user_name=tid, SUPPORT=0.3)

        #potato.shoot_lazy()
        potato.shoot_eager()

        result = potato.ranked_recommendations
        sorted_list = sorted(result.items(), key= lambda (k,v) : v, reverse=True)
        
        """
            turn the dic into array of items, get its first set 
            and then its second value to get the high value in 
            the result map
        """
        highest_value =  sorted_list[0][1]
        self.top = []
        for key, value in result.items():
            if highest_value == value:
                self.top.append(key)

        data = Data([
            Bar(
                x = result.keys(),
                y = result.values()
                )
            ])
        self.unique_url = py.plot(data, filename='basic-bar', auto_open=False)
        self.html_url = self.unique_url + 'html'
        self.embed_url = self.unique_url + '.embed?width=750&height=550'
__author__ = 'samarthshah'
from project import Project
import json
ok_now = Project('karnav2014', support=0.3)
ok_now.shoot_eager()


# restaurantList = []
# with open('Files/restaurants_list.txt', 'r') as r:
#     for line in r.readlines():
#         restaurantList = json.loads(line)
#         print 'Res list = ',restaurantList
#
# for i in range(len(restaurantList)):
#     print restaurantList[i]
#
# restaurant_set = set()
# title_case = []
# with open('Files/restaurants.txt', 'r') as r:
#     for line in r.readlines():
#         for item in line.split(','):
#             print item.split(' '), len(item.split(' '))<4
#             if len(item)>4 and len(item.split(' '))<4:
#                 print 'true'
#                 restaurant_set.add(item.strip())
#
# print 'set', restaurant_set
# for word in restaurant_set:
#     title_case.append(word.title())
#
# writeit = sorted(title_case, key=len)