Commit 089fe5afb918f0322024f5d753f4744e71ad0f20
1 parent
19f1de42
Exists in
master
and in
1 other branch
Updated config options. Still pending to fix config options by comand line and help.
Showing
2 changed files
with
126 additions
and
57 deletions
Show diff stats
src/bin/app_recommender.cfg
| ... | ... | @@ -3,39 +3,52 @@ |
| 3 | 3 | [general] |
| 4 | 4 | # logging level |
| 5 | 5 | debug = 0 |
| 6 | -verbose = 1 | |
| 6 | +verbose = 0 | |
| 7 | 7 | # output file |
| 8 | -#output = /dev/null | |
| 9 | -output = log-popindex-desktop-full | |
| 8 | +output = apprec.log | |
| 9 | +# output = /dev/null | |
| 10 | 10 | |
| 11 | 11 | [data_sources] |
| 12 | -# path to recommender filters | |
| 13 | -filters = ~/.app-recommender/filters | |
| 14 | -# path to apt-xapian-index | |
| 15 | -#axi = /var/lib/apt-xapian-index/index | |
| 16 | -axi = /root/.app-recommender/axi_desktop | |
| 17 | -# DDE url | |
| 18 | -#dde_url = http://dde.debian.net/dde/q/udd/packages/all/%s?t=json | |
| 19 | -dde_url = http://46.4.235.200:8000/q/udd/packages/all/%s?t=json | |
| 12 | +base_dir = ~/.app-recommender/ | |
| 13 | +# filters for valid packages | |
| 14 | +filters_dir = filters | |
| 15 | +pkgs_filter = programs | |
| 16 | +# package information indexes | |
| 17 | +axi = /var/lib/apt-xapian-index/index | |
| 18 | +axi_programs = axi_programs | |
| 19 | +axi_desktopapps = axi_desktopapps | |
| 20 | 20 | # old, reindex, cluster, recluster |
| 21 | -index_mode = old | |
| 22 | -# path to popcon index | |
| 23 | -popcon_index = ~/.app-recommender/popcon-index_desktop | |
| 24 | -# path to popcon submissions dir | |
| 25 | -popcon_dir = ~/.app-recommender/popcon-entries | |
| 26 | -# path to valid_pkgs file | |
| 27 | -pkgs_filter = desktop | |
| 28 | -# path to popcon clusters dir | |
| 29 | -clusters_dir = ~/.app-recommender/clusters_dir_full | |
| 30 | -# number of medoids for clustering | |
| 31 | -k_medoids = 100 | |
| 21 | +#index_mode = old | |
| 22 | +# popcon indexes | |
| 23 | +# check if there are popcon indexes available | |
| 24 | +popcon = 1 | |
| 25 | +popcon_programs = popcon_programs | |
| 26 | +popcon_desktopapps = popcon_desktopapps | |
| 27 | +popcon_index = popcon_programs | |
| 28 | +popcon_dir = popcon-entries | |
| 32 | 29 | # number of popcon submission for indexing |
| 33 | 30 | max_popcon = 100000000 |
| 31 | +# popcon clustering | |
| 32 | +clusters_dir = clusters_dir_full | |
| 33 | +k_medoids = 100 | |
| 34 | +# Connection to DDE | |
| 35 | +dde_url = http://46.4.235.200:8000/q/udd/packages/all/%s?t=json | |
| 36 | +self.dde_server = 46.4.235.200 | |
| 37 | +self.dde_port = 8000 | |
| 34 | 38 | |
| 35 | 39 | [recommender] |
| 36 | -# recommendation strategy | |
| 37 | -strategy = cb | |
| 38 | 40 | # search weighting scheme ('trad' or 'bm25') |
| 39 | 41 | weight = bm25 |
| 40 | -# user profile size | |
| 42 | +# bm25 parameters | |
| 43 | +bm25_k1 = 1.2 | |
| 44 | +bm25_k2 = 0 | |
| 45 | +bm25_k3 = 7 | |
| 46 | +bm25_b = 0.75 | |
| 47 | +bm25_nl = 0.5 | |
| 48 | +# recommendation strategy | |
| 49 | +strategy = cb | |
| 50 | +# user content profile size | |
| 41 | 51 | profile_size = 50 |
| 52 | +# neighborhood size | |
| 53 | +k_neighbors = 50 | |
| 54 | +popcon_profiling = full | ... | ... |
src/config.py
| ... | ... | @@ -37,28 +37,52 @@ class Config(Singleton): |
| 37 | 37 | Set default configuration options. |
| 38 | 38 | """ |
| 39 | 39 | if not hasattr(self, 'initialized'): |
| 40 | + ## general options | |
| 40 | 41 | self.debug = 0 |
| 41 | 42 | self.verbose = 1 |
| 42 | - #self.output = "/dev/null" | |
| 43 | 43 | self.output = "log" |
| 44 | - self.filters = os.path.expanduser("~/.app-recommender/filters") | |
| 45 | - #self.axi = "/var/lib/apt-xapian-index/index" | |
| 46 | - self.axi = os.path.expanduser("~/.app-recommender/ProgramAxi") | |
| 47 | - #self.dde_url = "http://dde.debian.net/dde/q/udd/packs/all/%s?t=json" | |
| 48 | - self.dde_url = "http://46.4.235.200:8000/q/udd/packages/all/%s?t=json" | |
| 49 | - self.popcon_index = os.path.expanduser("~/.app-recommender/popcon-index") | |
| 50 | - self.popcon_dir = os.path.expanduser("~/.app-recommender/popcon-entries") | |
| 51 | - self.pkgs_filter = "program" | |
| 52 | - self.clusters_dir = os.path.expanduser("~/.app-recommender/clusters-dir") | |
| 53 | - self.k_medoids = 100 | |
| 54 | - self.max_popcon = 1000 | |
| 44 | + | |
| 45 | + ## data_source options | |
| 46 | + self.base_dir = os.path.expanduser("~/.app-recommender/") | |
| 47 | + # filters for valid packages | |
| 48 | + self.filters_dir = os.path.join(self.base_dir,"filters") | |
| 49 | + self.pkgs_filter = os.path.join(self.filters_dir,"programs") | |
| 50 | + # package information packages | |
| 51 | + self.axi = "/var/lib/apt-xapian-index/index" | |
| 52 | + self.axi_programs = os.path.join(self.base_dir,"axi_programs") | |
| 53 | + self.axi_desktopapps = os.path.join(self.base_dir,"axi_desktopapps") | |
| 54 | + # popcon indexes | |
| 55 | 55 | self.index_mode = "old" |
| 56 | + # check if there are popcon indexes available | |
| 57 | + self.popcon = 1 | |
| 58 | + self.popcon_programs = os.path.join(self.base_dir,"popcon_programs") | |
| 59 | + self.popcon_desktopapps = os.path.join(self.base_dir,"popcon_desktopapps") | |
| 60 | + self.popcon_index = self.popcon_programs | |
| 61 | + self.popcon_dir = os.path.join(self.base_dir,"popcon-entries") | |
| 62 | + self.max_popcon = 1000 | |
| 63 | + # popcon clustering | |
| 64 | + self.clusters_dir = os.path.join(self.base_dir,"clusters-dir") | |
| 65 | + self.k_medoids = 100 | |
| 66 | + # self.dde_url = "http://dde.debian.net/dde/q/udd/packs/all/%s?t=json" | |
| 67 | + self.dde_url = "http://46.4.235.200:8000/q/udd/packages/all/%s?t=json" | |
| 68 | + self.dde_server = "46.4.235.200" | |
| 69 | + self.dde_port = "8000" | |
| 70 | + | |
| 71 | + ## recomender options | |
| 56 | 72 | self.strategy = "cb" |
| 57 | 73 | self.weight = "bm25" |
| 74 | + self.bm25_k1 = 1.2 | |
| 75 | + self.bm25_k2 = 0 | |
| 76 | + self.bm25_k3 = 7 | |
| 77 | + self.bm25_b = 0.75 | |
| 78 | + self.bm25_nl = 0.5 | |
| 79 | + # user content profile size | |
| 58 | 80 | self.profile_size = 50 |
| 59 | - # options: maximal, voted, desktop | |
| 60 | - self.profiling = ["maximal"] | |
| 61 | - self.k_neighbors = 100 | |
| 81 | + # neighborhood size | |
| 82 | + self.k_neighbors = 50 | |
| 83 | + # popcon profiling method: full, voted | |
| 84 | + self.popcon_profiling = "full" | |
| 85 | + | |
| 62 | 86 | self.load_options() |
| 63 | 87 | self.set_logger() |
| 64 | 88 | self.initialized = 1 |
| ... | ... | @@ -68,6 +92,7 @@ class Config(Singleton): |
| 68 | 92 | """ |
| 69 | 93 | Print usage help. |
| 70 | 94 | """ |
| 95 | + print "[FIXME: deprecated help]" | |
| 71 | 96 | print "\n [ general ]" |
| 72 | 97 | print " -h, --help Print this help" |
| 73 | 98 | print " -d, --debug Set logging level to debug" |
| ... | ... | @@ -75,7 +100,7 @@ class Config(Singleton): |
| 75 | 100 | print " -o, --output=PATH Path to file to save output" |
| 76 | 101 | print "" |
| 77 | 102 | print " [ data sources ]" |
| 78 | - print " -f, --filters=PATH Path to filters directory" | |
| 103 | + print " -f, --filtersdir=PATH Path to filters directory" | |
| 79 | 104 | print " -b, --pkgsfilter=FILTER File containing packages to be considered for recommendations" |
| 80 | 105 | print " -a, --axi=PATH Path to apt-xapian-index" |
| 81 | 106 | print " -e, --dde=URL DDE url" |
| ... | ... | @@ -130,29 +155,60 @@ class Config(Singleton): |
| 130 | 155 | |
| 131 | 156 | self.debug = int(self.read_option('general', 'debug')) |
| 132 | 157 | self.debug = int(self.read_option('general', 'verbose')) |
| 133 | - self.output = self.read_option('general', 'output') | |
| 134 | - | |
| 135 | - self.filters = os.path.expanduser(self.read_option('data_sources','filters')) | |
| 136 | - self.pkgs_filter = self.read_option('data_sources', 'pkgs_filter') | |
| 137 | - self.axi = os.path.expanduser(self.read_option('data_sources', 'axi')) | |
| 138 | - self.dde_url = self.read_option('data_sources', 'dde_url') | |
| 139 | - self.popcon_index = os.path.expanduser(self.read_option('data_sources','popcon_index')) | |
| 140 | - self.popcon_dir = os.path.expanduser(self.read_option('data_sources', 'popcon_dir')) | |
| 141 | - self.index_mode = self.read_option('data_sources', 'index_mode') | |
| 142 | - self.clusters_dir = os.path.expanduser(self.read_option('data_sources', 'clusters_dir')) | |
| 143 | - self.k_medoids = int(self.read_option('data_sources', 'k_medoids')) | |
| 158 | + self.output = os.path.join(self.base_dir, | |
| 159 | + self.read_option('general','output')) | |
| 160 | + self.filters_dir = os.path.join(self.base_dir, | |
| 161 | + self.read_option('data_sources', | |
| 162 | + 'filters_dir')) | |
| 163 | + self.pkgs_filter = os.path.join(self.filters_dir, | |
| 164 | + self.read_option('data_sources', | |
| 165 | + 'pkgs_filter')) | |
| 166 | + self.axi = self.read_option('data_sources', 'axi') | |
| 167 | + self.axi_programs = os.path.join(self.base_dir, | |
| 168 | + self.read_option('data_sources', | |
| 169 | + 'axi_programs')) | |
| 170 | + self.axi_desktopapps = os.path.join(self.base_dir, | |
| 171 | + self.read_option('data_sources', | |
| 172 | + 'axi_desktopapps')) | |
| 173 | + #self.index_mode = self.read_option('data_sources', 'index_mode') | |
| 174 | + self.popcon = int(self.read_option('data_sources', 'popcon')) | |
| 175 | + self.popcon_programs = os.path.join(self.base_dir, | |
| 176 | + self.read_option('data_sources', | |
| 177 | + 'popcon_programs')) | |
| 178 | + self.popcon_desktopapps = os.path.join(self.base_dir, | |
| 179 | + self.read_option('data_sources', | |
| 180 | + 'popcon_desktopapps')) | |
| 181 | + self.popcon_index = os.path.join(self.base_dir, | |
| 182 | + self.read_option('data_sources', | |
| 183 | + 'popcon_index')) | |
| 184 | + self.popcon_dir = os.path.join(self.base_dir, | |
| 185 | + self.read_option('data_sources', | |
| 186 | + 'popcon_dir')) | |
| 144 | 187 | self.max_popcon = int(self.read_option('data_sources', 'max_popcon')) |
| 188 | + self.clusters_dir = os.path.join(self.base_dir, | |
| 189 | + self.read_option('data_sources', | |
| 190 | + 'clusters_dir')) | |
| 191 | + self.k_medoids = int(self.read_option('data_sources', 'k_medoids')) | |
| 192 | + self.dde_url = self.read_option('data_sources', 'dde_url') | |
| 193 | + self.dde_server = self.read_option('data_sources', 'dde_server') | |
| 194 | + self.dde_port = self.read_option('data_sources', 'dde_port') | |
| 145 | 195 | |
| 146 | 196 | self.weight = self.read_option('recommender', 'weight') |
| 197 | + self.bm25_k1 = float(self.read_option('recommender', 'bm25_k1')) | |
| 198 | + self.bm25_k2 = float(self.read_option('recommender', 'bm25_k2')) | |
| 199 | + self.bm25_k3 = float(self.read_option('recommender', 'bm25_k3')) | |
| 200 | + self.bm25_b = float(self.read_option('recommender', 'bm25_b')) | |
| 201 | + self.bm25_nl = float(self.read_option('recommender', 'bm25_nl')) | |
| 147 | 202 | self.strategy = self.read_option('recommender', 'strategy') |
| 148 | 203 | self.profile_size = int(self.read_option('recommender', |
| 149 | 204 | 'profile_size')) |
| 150 | - self.profiling = self.read_option('recommender', 'profiling') | |
| 151 | 205 | self.k_neighbors = int(self.read_option('recommender', |
| 152 | - 'k_neighbors')) | |
| 206 | + 'k_neighbors')) | |
| 207 | + self.popcon_profiling = self.read_option('recommender', | |
| 208 | + 'popcon_profiling') | |
| 153 | 209 | |
| 154 | 210 | short_options = "hdvo:f:b:a:e:p:m:u:l:c:x:w:s:z:i:n:" |
| 155 | - long_options = ["help", "debug", "verbose", "output=", "filters=", | |
| 211 | + long_options = ["help", "debug", "verbose", "output=", "filtersdir=", | |
| 156 | 212 | "pkgsfilter=", "axi=", "dde=", "popconindex=", |
| 157 | 213 | "popcondir=", "indexmode=", "clustersdir=", "kmedoids=", |
| 158 | 214 | "maxpopcon=", "weight=", "strategy=", "profile_size=", |
| ... | ... | @@ -176,8 +232,8 @@ class Config(Singleton): |
| 176 | 232 | self.verbose = 1 |
| 177 | 233 | elif o in ("-o", "--output"): |
| 178 | 234 | self.output = p |
| 179 | - elif o in ("-f", "--filters"): | |
| 180 | - self.filters = p | |
| 235 | + elif o in ("-f", "--filtersdir"): | |
| 236 | + self.filters_dir = p | |
| 181 | 237 | elif o in ("-b", "--pkgsfilter"): |
| 182 | 238 | self.pkgs_filter = p |
| 183 | 239 | elif o in ("-a", "--axi"): | ... | ... |