def generate_all_terms_tfidf():
    global user_tfidf_weights

    axipath = os.path.expanduser("~/.app-recommender/axi_desktopapps/")
    axi_index = xapian.Database(axipath)

    dpkg_output = commands.getoutput('apt-mark showmanual')
    pkgs = [pkg for pkg in dpkg_output.splitlines()
            if not pkg.startswith('lib')]

    docs = data.axi_search_pkgs(axi_index, pkgs)

    tags_weights = data.tfidf_weighting(axi_index, docs,
                                        FilterTag(0), time_context=0)
    description_weights = (data.tfidf_weighting(axi_index, docs,
                           FilterDescription(), time_context=0))

    user_tfidf_weights = dict(tags_weights + description_weights)
Exemplo n.º 2
0
 def tfidf_profile(self,items_repository,size,content_filter):
     """
     Return the most relevant tags for the user list of packages based on
     the sublinear tfidf weight of packages' tags.
     """
     docs = data.axi_search_pkgs(items_repository,self.pkg_profile)
     #weights = data.tfidf_plus(items_repository,docs,content_filter)
     weights = data.tfidf_weighting(items_repository,docs,content_filter)
     # Eliminate duplicated stemmed term
     profile = self._eliminate_duplicated([w[0] for w in weights],size)
     return profile
Exemplo n.º 3
0
 def run(self, rec, user, recommendation_size):
     """
     Perform recommendation strategy.
     """
     neighborhood = self.get_neighborhood(user, rec)
     weights = data.tfidf_weighting(rec.users_repository, neighborhood, PkgExpandDecider(user.items()))
     profile = [w[0] for w in weights][: rec.cfg.profile_size]
     result = ContentBased("tag", rec.cfg.profile_size).get_sugestion_from_profile(
         rec, user, profile, recommendation_size
     )
     return result
Exemplo n.º 4
0
    def run(self, rec, user, recommendation_size):
        """
        Perform recommendation strategy.
        """
        neighborhood = self.get_neighborhood(user, rec)
        weights = data.tfidf_weighting(rec.users_repository, neighborhood,
                                       PkgExpandDecider(user.items()))
        profile = [w[0] for w in weights][:rec.cfg.profile_size]

        result = ContentBased("tag", rec.cfg.profile_size)
        result = result.get_sugestion_from_profile(rec, user, profile,
                                                   recommendation_size)
        return result
Exemplo n.º 5
0
 def run(self, rec, user, recommendation_size):
     """
     Perform recommendation strategy.
     """
     neighborhood = self.get_neighborhood(user, rec)
     weights = data.tfidf_weighting(rec.users_repository, neighborhood, PkgExpandDecider(user.items()))
     item_score = {}
     ranking = []
     for pkg in weights[:recommendation_size]:
         package = pkg[0].lstrip("XP")
         item_score[package] = pkg[1]
         ranking.append(package)
     result = recommender.RecommendationResult(item_score, ranking)
     return result
Exemplo n.º 6
0
 def run(self, rec, user, recommendation_size):
     """
     Perform recommendation strategy.
     """
     neighborhood = self.get_neighborhood(user, rec)
     weights = data.tfidf_weighting(rec.users_repository, neighborhood,
                                    PkgExpandDecider(user.items()))
     item_score = {}
     ranking = []
     for pkg in weights[:recommendation_size]:
         package = pkg[0].lstrip("XP")
         item_score[package] = pkg[1]
         ranking.append(package)
     result = recommender.RecommendationResult(item_score, ranking)
     return result