Beispiel #1
0
def nearest_ratings(user_id, count, address):
    """Get Nearest Recommended business to user's address """
    logger.debug("User %s rating requested for nearest address", user_id,
                 address)
    ratings = recommendationengine.get_nearest_businesses(
        user_id, count, address)
    return json.dumps(ratings)
Beispiel #2
0
def add_ratings(user_id):
    # get the ratings from the Flask POST request object http://<SERVER_IP>:5432/0/ratings/top/10
    ratings_list = request.form.keys()[0].strip().split("\n")
    ratings_list = map(lambda x: x.split(","), ratings_list)
    # create a list with the format required by the negine (user_id, movie_id, rating)
    ratings = map(lambda x: (user_id, int(x[0]), float(x[1])), ratings_list)
    # add them to the model using then engine API
    recommendationengine.add_ratings(ratings)

    return json.dumps(ratings)
 def data(self):
     s = extrapolate_statistics(logging.statistics)
     cherrypy.response.headers['Content-Type'] = 'application/json'
     return json.dumps(s, sort_keys=True, indent=4)
Beispiel #4
0
def get_user_Ids():
    logger.debug("Users")
    userIds = recommendationengine.get_User_Ids()
    return json.dumps(userIds)
Beispiel #5
0
def business_ratings(user_id, business_id):
    logger.debug("User %s rating requested for business %s", user_id,
                 business_id)
    ratings = recommendationengine.get_ratings_for_business_ids(
        user_id, [business_id])
    return json.dumps(ratings)
Beispiel #6
0
def ratings_within_category(user_id, count, category):
    """Get Top Recommendations within the category"""
    logger.debug("User %s rating requested for category %s", user_id, category)
    ratings = recommendationengine.get_business_in_categories(
        user_id, count, category)
    return json.dumps(ratings)
Beispiel #7
0
def ratings_within_state(user_id, count, state):
    """Get Top Recommendations within the state """
    logger.debug("User %s rating requested for state %s", user_id, state)
    ratings = recommendationengine.get_business_in_state(user_id, count, state)
    data = json.dumps(ratings)
    return data
Beispiel #8
0
def top_recommendation(user_id, count):
    """Get Top Recommendations """
    top_ratings = recommendationengine.get_top_ratings_with_business_info(
        user_id, count)
    return json.dumps(top_ratings)
Beispiel #9
0
 def data(self):
     s = extrapolate_statistics(logging.statistics)
     cherrypy.response.headers['Content-Type'] = 'application/json'
     return json.dumps(s, sort_keys=True, indent=4)