Commit 15667ffbb7e05745b884b996c07fa30a2fb71222
1 parent
b91dabaa
Exists in
master
and in
1 other branch
Added arch attribute to user.
Showing
1 changed file
with
13 additions
and
5 deletions
Show diff stats
src/user.py
@@ -111,7 +111,7 @@ class User: | @@ -111,7 +111,7 @@ class User: | ||
111 | """ | 111 | """ |
112 | Define a user of a recommender. | 112 | Define a user of a recommender. |
113 | """ | 113 | """ |
114 | - def __init__(self,item_score,user_id=0,demo_profiles_set=0): | 114 | + def __init__(self,item_score,user_id=0,arch=0,demo_profiles_set=0): |
115 | """ | 115 | """ |
116 | Set initial user attributes. pkg_profile gets the whole set of items, | 116 | Set initial user attributes. pkg_profile gets the whole set of items, |
117 | a random user_id is set if none was provided and the demographic | 117 | a random user_id is set if none was provided and the demographic |
@@ -119,6 +119,7 @@ class User: | @@ -119,6 +119,7 @@ class User: | ||
119 | """ | 119 | """ |
120 | self.item_score = item_score | 120 | self.item_score = item_score |
121 | self.pkg_profile = self.items() | 121 | self.pkg_profile = self.items() |
122 | + self.arch = arch | ||
122 | 123 | ||
123 | if user_id: | 124 | if user_id: |
124 | self.user_id = user_id | 125 | self.user_id = user_id |
@@ -272,21 +273,28 @@ class User: | @@ -272,21 +273,28 @@ class User: | ||
272 | return self.pkg_profile | 273 | return self.pkg_profile |
273 | 274 | ||
274 | class RandomPopcon(User): | 275 | class RandomPopcon(User): |
275 | - def __init__(self,submissions_dir,pkgs_filter=0): | 276 | + def __init__(self,submissions_dir,arch=0,pkgs_filter=0): |
276 | """ | 277 | """ |
277 | Set initial parameters. | 278 | Set initial parameters. |
278 | """ | 279 | """ |
279 | len_profile = 0 | 280 | len_profile = 0 |
280 | - while len_profile < 100: | 281 | + match_arch = False |
282 | + while len_profile < 100 or not match_arch: | ||
281 | path = random.choice([os.path.join(root, submission) for | 283 | path = random.choice([os.path.join(root, submission) for |
282 | root, dirs, files in os.walk(submissions_dir) | 284 | root, dirs, files in os.walk(submissions_dir) |
283 | for submission in files]) | 285 | for submission in files]) |
284 | user = PopconSystem(path) | 286 | user = PopconSystem(path) |
287 | + print arch | ||
288 | + print user.arch | ||
289 | + if arch and user.arch==arch: | ||
290 | + match_arch = True | ||
291 | + print "match" | ||
285 | if pkgs_filter: | 292 | if pkgs_filter: |
286 | user.filter_pkg_profile(pkgs_filter) | 293 | user.filter_pkg_profile(pkgs_filter) |
287 | len_profile = len(user.pkg_profile) | 294 | len_profile = len(user.pkg_profile) |
295 | + print "p",len_profile | ||
288 | submission = data.PopconSubmission(path) | 296 | submission = data.PopconSubmission(path) |
289 | - User.__init__(self,submission.packages,submission.user_id) | 297 | + User.__init__(self,submission.packages,submission.user_id,submission.arch) |
290 | 298 | ||
291 | class PopconSystem(User): | 299 | class PopconSystem(User): |
292 | def __init__(self,path,user_id=0): | 300 | def __init__(self,path,user_id=0): |
@@ -296,7 +304,7 @@ class PopconSystem(User): | @@ -296,7 +304,7 @@ class PopconSystem(User): | ||
296 | submission = data.PopconSubmission(path) | 304 | submission = data.PopconSubmission(path) |
297 | if not user_id: | 305 | if not user_id: |
298 | user_id = submission.user_id | 306 | user_id = submission.user_id |
299 | - User.__init__(self,submission.packages,user_id) | 307 | + User.__init__(self,submission.packages,user_id,submission.arch) |
300 | 308 | ||
301 | class PkgsListSystem(User): | 309 | class PkgsListSystem(User): |
302 | def __init__(self,pkgs_list_or_file,user_id=0): | 310 | def __init__(self,pkgs_list_or_file,user_id=0): |