Commit 78a934e47fa4b4688a6973ae503ad4795024bc69
1 parent
f1b691fb
Exists in
master
and in
1 other branch
Fixed bug with popcon instantiation. Only programs repository was active, even f…
…or desktop filtered strategies.
Showing
1 changed file
with
8 additions
and
6 deletions
Show diff stats
src/recommender.py
| @@ -109,18 +109,20 @@ class Recommender: | @@ -109,18 +109,20 @@ class Recommender: | ||
| 109 | Set the recommendation strategy. | 109 | Set the recommendation strategy. |
| 110 | """ | 110 | """ |
| 111 | logging.info("Setting recommender strategy to \'%s\'" % strategy_str) | 111 | logging.info("Setting recommender strategy to \'%s\'" % strategy_str) |
| 112 | + # Check if collaborative strategies can be instanciated | ||
| 113 | + if "knn" in strategy_str: | ||
| 114 | + if not self.cfg.popcon: | ||
| 115 | + logging.info("Cannot perform collaborative strategy") | ||
| 116 | + return 1 | ||
| 112 | if self.cfg.pkgs_filter.split("/")[-1] == "desktopapps": | 117 | if self.cfg.pkgs_filter.split("/")[-1] == "desktopapps": |
| 113 | self.items_repository = self.axi_desktopapps | 118 | self.items_repository = self.axi_desktopapps |
| 114 | self.valid_pkgs = self.valid_desktopapps | 119 | self.valid_pkgs = self.valid_desktopapps |
| 120 | + if "knn" in strategy_str: | ||
| 121 | + self.users_repository = self.popcon_desktopapps | ||
| 115 | else: | 122 | else: |
| 116 | self.items_repository = self.axi_programs | 123 | self.items_repository = self.axi_programs |
| 117 | self.valid_pkgs = self.valid_programs | 124 | self.valid_pkgs = self.valid_programs |
| 118 | - # Check if collaborative strategies can be instanciated | ||
| 119 | - if ("col" in strategy_str) or ("knn" in strategy_str): | ||
| 120 | - if not self.cfg.popcon: | ||
| 121 | - logging.info("Cannot perform collaborative strategy") | ||
| 122 | - return 1 | ||
| 123 | - else: | 125 | + if "knn" in strategy_str: |
| 124 | self.users_repository = self.popcon_programs | 126 | self.users_repository = self.popcon_programs |
| 125 | # Set strategy based on strategy_str | 127 | # Set strategy based on strategy_str |
| 126 | if strategy_str == "cb": | 128 | if strategy_str == "cb": |