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 | 111 | """ |
| 112 | 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 | 116 | Set initial user attributes. pkg_profile gets the whole set of items, |
| 117 | 117 | a random user_id is set if none was provided and the demographic |
| ... | ... | @@ -119,6 +119,7 @@ class User: |
| 119 | 119 | """ |
| 120 | 120 | self.item_score = item_score |
| 121 | 121 | self.pkg_profile = self.items() |
| 122 | + self.arch = arch | |
| 122 | 123 | |
| 123 | 124 | if user_id: |
| 124 | 125 | self.user_id = user_id |
| ... | ... | @@ -272,21 +273,28 @@ class User: |
| 272 | 273 | return self.pkg_profile |
| 273 | 274 | |
| 274 | 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 | 278 | Set initial parameters. |
| 278 | 279 | """ |
| 279 | 280 | len_profile = 0 |
| 280 | - while len_profile < 100: | |
| 281 | + match_arch = False | |
| 282 | + while len_profile < 100 or not match_arch: | |
| 281 | 283 | path = random.choice([os.path.join(root, submission) for |
| 282 | 284 | root, dirs, files in os.walk(submissions_dir) |
| 283 | 285 | for submission in files]) |
| 284 | 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 | 292 | if pkgs_filter: |
| 286 | 293 | user.filter_pkg_profile(pkgs_filter) |
| 287 | 294 | len_profile = len(user.pkg_profile) |
| 295 | + print "p",len_profile | |
| 288 | 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 | 299 | class PopconSystem(User): |
| 292 | 300 | def __init__(self,path,user_id=0): |
| ... | ... | @@ -296,7 +304,7 @@ class PopconSystem(User): |
| 296 | 304 | submission = data.PopconSubmission(path) |
| 297 | 305 | if not user_id: |
| 298 | 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 | 309 | class PkgsListSystem(User): |
| 302 | 310 | def __init__(self,pkgs_list_or_file,user_id=0): | ... | ... |