Commit 4885b0b0dd0412225f9c0bf766b0c0eedf9c16d5
1 parent
e7a33821
Exists in
master
and in
1 other branch
Fix KnnContentEset strategy.
Showing
1 changed file
with
4 additions
and
3 deletions
Show diff stats
src/strategy.py
| @@ -100,6 +100,7 @@ class ContentBased(RecommendationStrategy): | @@ -100,6 +100,7 @@ class ContentBased(RecommendationStrategy): | ||
| 100 | 100 | ||
| 101 | def get_sugestion_from_profile(self,rec,user,profile,recommendation_size): | 101 | def get_sugestion_from_profile(self,rec,user,profile,recommendation_size): |
| 102 | query = xapian.Query(xapian.Query.OP_OR,profile) | 102 | query = xapian.Query(xapian.Query.OP_OR,profile) |
| 103 | + print query | ||
| 103 | enquire = xapian.Enquire(rec.items_repository) | 104 | enquire = xapian.Enquire(rec.items_repository) |
| 104 | enquire.set_weighting_scheme(rec.weight) | 105 | enquire.set_weighting_scheme(rec.weight) |
| 105 | enquire.set_query(query) | 106 | enquire.set_query(query) |
| @@ -295,7 +296,7 @@ class KnnContent(Collaborative): | @@ -295,7 +296,7 @@ class KnnContent(Collaborative): | ||
| 295 | weights = data.tfidf_weighting(rec.users_repository,neighborhood, | 296 | weights = data.tfidf_weighting(rec.users_repository,neighborhood, |
| 296 | PkgExpandDecider(user.items())) | 297 | PkgExpandDecider(user.items())) |
| 297 | profile = [w[0] for w in weights][:rec.cfg.profile_size] | 298 | profile = [w[0] for w in weights][:rec.cfg.profile_size] |
| 298 | - result = ContentBased().get_sugestion_from_profile(rec,user,profile,recommendation_size) | 299 | + result = ContentBased("tag",rec.cfg.profile_size).get_sugestion_from_profile(rec,user,profile,recommendation_size) |
| 299 | return result | 300 | return result |
| 300 | 301 | ||
| 301 | class KnnContentEset(Collaborative): | 302 | class KnnContentEset(Collaborative): |
| @@ -313,10 +314,10 @@ class KnnContentEset(Collaborative): | @@ -313,10 +314,10 @@ class KnnContentEset(Collaborative): | ||
| 313 | neighbors_rset = self.get_neighborhood_rset(user,rec) | 314 | neighbors_rset = self.get_neighborhood_rset(user,rec) |
| 314 | enquire = self.get_enquire(rec) | 315 | enquire = self.get_enquire(rec) |
| 315 | # Retrieve relevant tags based on neighborhood profile expansion | 316 | # Retrieve relevant tags based on neighborhood profile expansion |
| 316 | - eset = enquire.get_eset(rec.cfg.profile_size,rset, | 317 | + eset = enquire.get_eset(rec.cfg.profile_size,neighbors_rset, |
| 317 | TagExpandDecider()) | 318 | TagExpandDecider()) |
| 318 | profile = [e.term for e in eset] | 319 | profile = [e.term for e in eset] |
| 319 | - result = ContentBased().get_sugestion_from_profile(rec,user,profile,recommendation_size) | 320 | + result = ContentBased("tag",rec.cfg.profile_size).get_sugestion_from_profile(rec,user,profile,recommendation_size) |
| 320 | return result | 321 | return result |
| 321 | 322 | ||
| 322 | class Demographic(RecommendationStrategy): | 323 | class Demographic(RecommendationStrategy): |