Esempio n. 1
0
    def get_category_like_fraction(self, uid, category):
        #how many posts has user liked for this category
        numerator = defaultdict_util.get_value(self.category_user_count_map, category, uid)

        #how many total posts were made with this category in all the blogs read by user
        denominator = 0
        for blog in self.user_liked_blogs_map[uid]:
            denominator += defaultdict_util.get_value(self.category_blog_count_map, category, blog)

#        if denominator == 0:
#            return 0

        denominator += 1

        return 1.0 * numerator / denominator
Esempio n. 2
0
    def get_tag_like_fraction(self, uid, tag):
        #how many posts has user liked for this tag
        numerator = defaultdict_util.get_value(self.tag_user_count_map, tag, uid)
        
        #how many total posts were made with this tag in all the blogs read by user
        denominator = 0
        for blog in self.user_liked_blogs_map[uid]:
            #denominator += self.tag_blog_count_map[tag][blog]
            denominator += defaultdict_util.get_value(self.tag_blog_count_map, tag, blog)

#        if denominator == 0:
#            return 0

        denominator += 1

        return 1.0 * numerator / denominator
Esempio n. 3
0
    def get_category_like_fraction(self, uid, category):
        #how many posts has user liked for this category
        numerator = defaultdict_util.get_value(self.category_user_count_map,
                                               category, uid)

        #how many total posts were made with this category in all the blogs read by user
        denominator = 0
        for blog in self.user_liked_blogs_map[uid]:
            denominator += defaultdict_util.get_value(
                self.category_blog_count_map, category, blog)

#        if denominator == 0:
#            return 0

        denominator += 1

        return 1.0 * numerator / denominator
Esempio n. 4
0
    def get_tag_like_fraction(self, uid, tag):
        #how many posts has user liked for this tag
        numerator = defaultdict_util.get_value(self.tag_user_count_map, tag,
                                               uid)

        #how many total posts were made with this tag in all the blogs read by user
        denominator = 0
        for blog in self.user_liked_blogs_map[uid]:
            #denominator += self.tag_blog_count_map[tag][blog]
            denominator += defaultdict_util.get_value(self.tag_blog_count_map,
                                                      tag, blog)

#        if denominator == 0:
#            return 0

        denominator += 1

        return 1.0 * numerator / denominator