Commit bc5f760c46a4faa41be722d0596082a005d7597b
1 parent
a1a2598b
Exists in
master
and in
1 other branch
Added new options 'filters' and 'pkgs_filter' to config and fixed bug with log o…
…utput (mixed variable name).
Showing
2 changed files
with
69 additions
and
18 deletions
Show diff stats
... | ... | @@ -0,0 +1,41 @@ |
1 | +# Config file for AppRecommender | |
2 | + | |
3 | +[general] | |
4 | +# logging level | |
5 | +debug = 0 | |
6 | +verbose = 0 | |
7 | +# output file | |
8 | +#output = /dev/null | |
9 | +output = log-apprec | |
10 | + | |
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/DesktopAxi | |
17 | +# DDE url | |
18 | +dde_url = http://dde.debian.net/dde/q/udd/packages/all/%s?t=json | |
19 | +# old, reindex, cluster, recluster | |
20 | +index_mode = old | |
21 | +# path to popcon index | |
22 | +popcon_index = ~/.app-recommender/popcon-index_desktop_1000 | |
23 | +# path to popcon submissions dir | |
24 | +#popcon_dir = ~/.app-recommender/popcon_dir | |
25 | +popcon_dir = ~/org/popcon.debian.org/popcon-mail/popcon-entries/ | |
26 | +# path to valid_pkgs file | |
27 | +pkgs_filter = program | |
28 | +# path to popcon clusters dir | |
29 | +clusters_dir = ~/.app-recommender/clusters_dir_full | |
30 | +# number of medoids for clustering | |
31 | +k_medoids = 100 | |
32 | +# number of popcon submission for indexing | |
33 | +max_popcon = 1000 | |
34 | + | |
35 | +[recommender] | |
36 | +# recommendation strategy | |
37 | +strategy = cb | |
38 | +# search weighting scheme ('trad' or 'bm25') | |
39 | +weight = bm25 | |
40 | +# user profile size | |
41 | +profile_size = 50 | ... | ... |
src/config.py
... | ... | @@ -38,13 +38,15 @@ class Config(): |
38 | 38 | self.debug = 0 |
39 | 39 | self.verbose = 0 |
40 | 40 | self.output = "/dev/null" |
41 | - self.survey_mode = 1 | |
42 | - self.axi = "/var/lib/apt-xapian-index/index" | |
41 | + self.filters = os.path.expanduser("~/.app-recommender/filters") | |
42 | + #self.axi = "/var/lib/apt-xapian-index/index" | |
43 | + self.axi = os.path.expanduser("~/.app-recommender/DesktopAxi") | |
43 | 44 | #self.dde_url = "http://dde.debian.net/dde/q/udd/packs/all/%s?t=json" |
44 | 45 | self.dde_url = "http://46.4.235.200:8000/q/udd/packages/all/%s?t=json" |
45 | - self.popcon_index = os.path.expanduser("~/.app-recommender/popcon_index") | |
46 | - self.popcon_dir = os.path.expanduser("~/.app-recommender/popcon_dir") | |
47 | - self.clusters_dir = os.path.expanduser("~/.app-recommender/clusters_dir") | |
46 | + self.popcon_index = os.path.expanduser("~/.app-recommender/popcon-index") | |
47 | + self.popcon_dir = os.path.expanduser("~/.app-recommender/popcon-entries") | |
48 | + self.pkgs_filter = "program" | |
49 | + self.clusters_dir = os.path.expanduser("~/.app-recommender/clusters-dir") | |
48 | 50 | self.k_medoids = 100 |
49 | 51 | self.max_popcon = 1000 |
50 | 52 | self.index_mode = "old" |
... | ... | @@ -52,7 +54,7 @@ class Config(): |
52 | 54 | self.weight = "bm25" |
53 | 55 | self.profile_size = 50 |
54 | 56 | # options: maximal, voted, desktop |
55 | - self.profiling = "maximal" | |
57 | + self.profiling = ["maximal"] | |
56 | 58 | self.k_neighbors = 100 |
57 | 59 | self.load_options() |
58 | 60 | self.set_logger() |
... | ... | @@ -68,11 +70,13 @@ class Config(): |
68 | 70 | print " -o, --output=PATH Path to file to save output" |
69 | 71 | print "" |
70 | 72 | print " [ data sources ]" |
73 | + print " -f, --filters=PATH Path to filters directory" | |
74 | + print " -b, --pkgsfilter=FILTER File containing packages to be considered for recommendations" | |
71 | 75 | print " -a, --axi=PATH Path to apt-xapian-index" |
72 | 76 | print " -e, --dde=URL DDE url" |
73 | 77 | print " -p, --popconindex=PATH Path to popcon index" |
74 | 78 | print " -m, --popcondir=PATH Path to popcon submissions dir" |
75 | - print " -u, --indexmode= 'old'|'reindex'|'cluster'|'recluster'" | |
79 | + print " -u, --indexmode=MODE 'old'|'reindex'|'cluster'|'recluster'" | |
76 | 80 | print " -l, --clustersdir=PATH Path to popcon clusters dir" |
77 | 81 | print " -c, --medoids=k Number of medoids for clustering" |
78 | 82 | print " -x, --maxpopcon=k Number of submissions to be considered" |
... | ... | @@ -81,7 +85,7 @@ class Config(): |
81 | 85 | print " -w, --weight=OPTION Search weighting scheme" |
82 | 86 | print " -s, --strategy=OPTION Recommendation strategy" |
83 | 87 | print " -z, --profilesize=k Size of user profile" |
84 | - print " -f, --profiling=OPTION Profile filter strategy" | |
88 | + print " -i, --profiling=OPTION Profile filter strategy" | |
85 | 89 | print " -n, --neighbors=k Size of neighborhood for collaboration" |
86 | 90 | print "" |
87 | 91 | print " [ weight options ] " |
... | ... | @@ -121,10 +125,11 @@ class Config(): |
121 | 125 | |
122 | 126 | self.debug = int(self.read_option('general', 'debug')) |
123 | 127 | self.debug = int(self.read_option('general', 'verbose')) |
124 | - self.output_filename = self.read_option('general', 'output') | |
125 | - self.survey_mode = self.read_option('general', 'survey_mode') | |
128 | + self.output = self.read_option('general', 'output') | |
126 | 129 | |
127 | - self.axi = self.read_option('data_sources', 'axi') | |
130 | + self.filters = os.path.expanduser(self.read_option('data_sources','filters')) | |
131 | + self.pkgs_filter = self.read_option('data_sources', 'pkgs_filter') | |
132 | + self.axi = os.path.expanduser(self.read_option('data_sources', 'axi')) | |
128 | 133 | self.dde_url = self.read_option('data_sources', 'dde_url') |
129 | 134 | self.popcon_index = os.path.expanduser(self.read_option('data_sources','popcon_index')) |
130 | 135 | self.popcon_dir = os.path.expanduser(self.read_option('data_sources', 'popcon_dir')) |
... | ... | @@ -141,11 +146,12 @@ class Config(): |
141 | 146 | self.k_neighbors = int(self.read_option('recommender', |
142 | 147 | 'k_neighbors')) |
143 | 148 | |
144 | - short_options = "hdvo:a:e:p:m:ul:c:x:w:s:z:f:n:" | |
145 | - long_options = ["help", "debug", "verbose", "output=", | |
146 | - "axi=", "dde=", "popconindex=", "popcondir=", "indexmode=", | |
147 | - "clustersdir=", "kmedoids=", "maxpopcon=", "weight=", "strategy=", | |
148 | - "profile_size=", "profiling=", "neighbors="] | |
149 | + short_options = "hdvo:f:b:a:e:p:m:u:l:c:x:w:s:z:i:n:" | |
150 | + long_options = ["help", "debug", "verbose", "output=", "filters=", | |
151 | + "pkgsfilter=", "axi=", "dde=", "popconindex=", | |
152 | + "popcondir=", "indexmode=", "clustersdir=", "kmedoids=", | |
153 | + "maxpopcon=", "weight=", "strategy=", "profile_size=", | |
154 | + "profiling=", "neighbors="] | |
149 | 155 | try: |
150 | 156 | opts, args = getopt.getopt(sys.argv[1:], short_options, |
151 | 157 | long_options) |
... | ... | @@ -165,6 +171,10 @@ class Config(): |
165 | 171 | self.verbose = 1 |
166 | 172 | elif o in ("-o", "--output"): |
167 | 173 | self.output = p |
174 | + elif o in ("-f", "--filters"): | |
175 | + self.filters = p | |
176 | + elif o in ("-b", "--pkgsfilter"): | |
177 | + self.pkgs_filter = p | |
168 | 178 | elif o in ("-a", "--axi"): |
169 | 179 | self.axi = p + "/index" |
170 | 180 | elif o in ("-e", "--dde"): |
... | ... | @@ -211,10 +221,10 @@ class Config(): |
211 | 221 | console_handler = logging.StreamHandler(sys.stdout) |
212 | 222 | console_handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s')) |
213 | 223 | console_handler.setLevel(log_level) |
214 | - self.logger.addHandler(console_handler) | |
224 | + #self.logger.addHandler(console_handler) | |
215 | 225 | |
216 | 226 | file_handler = logging.handlers.RotatingFileHandler(self.output, |
217 | - maxBytes=5000, | |
227 | + maxBytes=50000000, | |
218 | 228 | backupCount=5) |
219 | 229 | log_format = '%(asctime)s AppRecommender %(levelname)-8s %(message)s' |
220 | 230 | file_handler.setFormatter(logging.Formatter(log_format)) | ... | ... |