Commit d3b38af6458ff163af669a4687834ce194307898

Authored by Tássia Camões Araújo
2 parents 28fbf48b e70ddffd
Exists in master and in 1 other branch add_vagrant

Merge branch 'master' of github.com:tassia/AppRecommender

src/data.py
... ... @@ -271,11 +271,12 @@ class PopconXapianIndex(xapian.WritableDatabase):
271 271 class KMedoidsClustering(cluster.KMeansClustering):
272 272  
273 273 def __init__(self,data,distance,max_data=100):
274   - if len(data)<max_data:
275   - data_sample = data
276   - else:
277   - data_sample = random.sample(data,max_data)
278   - cluster.KMeansClustering.__init__(self, data_sample, distance)
  274 + # if len(data)<max_data:
  275 + # data_sample = data
  276 + # else:
  277 + # data_sample = random.sample(data,max_data)
  278 + # cluster.KMeansClustering.__init__(self, data_sample, distance)
  279 + cluster.KMeansClustering.__init__(self, data, distance)
279 280 self.distanceMatrix = {}
280 281 for submission in self._KMeansClustering__data:
281 282 self.distanceMatrix[submission.user_id] = {}
... ... @@ -332,7 +333,13 @@ class KMedoidsClustering(cluster.KMeansClustering):
332 333 """
333 334 Generate n clusters and return their medoids.
334 335 """
335   - medoids_distances = [self.getMedoid(cluster) for cluster in self.getclusters(n)]
  336 + #medoids_distances = [self.getMedoid(cluster) for cluster in self.getclusters(n)]
  337 + medoids_distances = []
  338 + for cluster in self.getclusters(n):
  339 + type(cluster)
  340 + print cluster
  341 + medoids_distances.append(self.getMedoid(cluster))
  342 + print medoids_distances
336 343 medoids = [m[0] for m in medoids_distances]
337 344 dispersion = sum([m[1] for m in medoids_distances])
338 345 logging.info("Clustering completed and the following medoids were found: %s" % [c.user_id for c in medoids])
... ...
src/examples/clustering.py
... ... @@ -36,7 +36,7 @@ if __name__ == &#39;__main__&#39;:
36 36 begin_time = datetime.datetime.now()
37 37 logging.info("Clustering computation started at %s" % begin_time)
38 38  
39   - cl = PopconClusteredData(cfg)
  39 + cl = PopconXapianIndex(cfg)
40 40  
41 41 end_time = datetime.datetime.now()
42 42 logging.info("Clustering computation completed at %s" % end_time)
... ...
src/web/static/coda-slider-2.0/javascripts/jquery.coda-slider-2.0.js
... ... @@ -99,9 +99,9 @@ $.fn.codaSlider = function(settings) {
99 99 $('#coda-nav-right-' + sliderCount + ' a').click(function(){
100 100 navClicks++;
101 101 if (currentPanel == panelCount) {
102   - this.style.display = 'none'; // Button display none;
103   - document.getElementById("controls-form").style.display = 'block'; // Show buttons controls;
104   - document.getElementById("coda-slider-1").style.display = 'none'; // Description hidden;
  102 + $(this).hide("fast"); // Button display none;
  103 + $(".show-end").show("fast"); // Show buttons controls;
  104 + $(".hide-end").hide("fast"); // Description hidden;
105 105 return false;
106 106 offset = 0;
107 107 currentPanel = 1;
... ...
src/web/static/css/survey.css
... ... @@ -38,6 +38,16 @@ display: block;
38 38 z-index: 3;
39 39 }
40 40  
  41 +#controls-form label#tip-finish .tip {
  42 +margin-top: -50px;
  43 +left: 90px;
  44 +}
  45 +
  46 +#controls-form label#tip-continue .tip {
  47 +margin-top: -80px;
  48 +right: -60px;
  49 +}
  50 +
41 51 .innertube {
42 52 margin: 30px;
43 53 }
... ... @@ -73,16 +83,13 @@ display: none;
73 83 }
74 84  
75 85 .screenshot {
76   -float: right;
  86 +float: left;
77 87 margin: 5px;
78 88 }
79 89  
80   -.content-pkg ul {
81   -list-style: none;
82   -}
83   -
84 90 .content-pkg ul li {
85 91 margin-bottom: 10px;
  92 +font-size:
86 93 }
87 94  
88 95 .radioButton,
... ... @@ -106,6 +113,10 @@ z-index: 2;
106 113 cursor: pointer;
107 114 }
108 115  
  116 +#continue-button {
  117 +float: right;
  118 +}
  119 +
109 120 .radioButton:hover,
110 121 #next-button:hover,
111 122 #controls-form input:hover {
... ... @@ -128,24 +139,30 @@ width: 180px;
128 139 float: right;
129 140 }
130 141  
131   -#controls-form,
132 142 #next-button {
133 143 text-align: center;
134 144 position: absolute;
135   -top: 120px;
  145 +top: 90px;
136 146 right: 65px;
137 147 width: 150px;
138 148 height: 20px;
  149 +float: right;
139 150 z-index: 3;
140 151 }
141 152  
142 153 #controls-form {
143   -top: 90px;
144   -right: 85px;
145   -height: auto;
  154 +position: absolute;
  155 +top: 390px;
  156 +width: 600px;
  157 +margin-right: auto;
  158 +margin-left: auto;
  159 +text-align: center;
  160 +height: 20px;
  161 +z-index: 3;
146 162 }
147 163  
148 164  
  165 +
149 166 /*
150 167 * Package Box
151 168 */
... ...
src/web/survey.py
... ... @@ -79,12 +79,13 @@ class Package:
79 79 class Request:
80 80 def __init__(self,web_input,submissions_dir,user_id=0,pkgs_list=0):
81 81 self.strategy = ""
  82 + print "Request from user",user_id
82 83 if user_id:
83 84 self.user_id = user_id
84 85 self.outputdir = os.path.join(submissions_dir,user_id)
85 86 else:
86 87 self.outputdir = tempfile.mkdtemp(prefix='',dir=submissions_dir)
87   - print "created dir %s",self.outputdir
  88 + print ("created dir %s" % self.outputdir)
88 89 self.user_id = self.outputdir.lstrip(submissions_dir)
89 90  
90 91 if pkgs_list:
... ... @@ -169,6 +170,7 @@ class Survey:
169 170 request = Request(web_input,self.submissions_dir)
170 171 else:
171 172 user_id = web_input['user_id'].encode('utf8')
  173 + print "Continue", user_id
172 174 with open("./submissions/%s/packages_list" % user_id) as packages_list:
173 175 pkgs_list = [line.strip() for line in packages_list.readlines()]
174 176 request = Request(web_input,self.submissions_dir,user_id,pkgs_list)
... ... @@ -181,9 +183,14 @@ class Survey:
181 183 old_strategies = [dirs for root, dirs, files in
182 184 os.walk(os.path.join(self.submissions_dir,
183 185 request.user_id))]
184   - print "OLD Strategies", old_strategies[0]
185   - strategies = [s for s in self.strategies if s not in old_strategies[0]]
  186 + if old_strategies:
  187 + strategies = [s for s in self.strategies if s not in old_strategies[0]]
  188 + print "OLD Strategies", old_strategies[0]
  189 + else:
  190 + strategies = self.strategies
186 191 print "LEFT",strategies
  192 + if not strategies:
  193 + return render.thanks(user_id)
187 194 request.strategy = random.choice(strategies)
188 195 print "selected",request.strategy
189 196 self.rec.set_strategy(request.strategy)
... ...
src/web/templates/survey.html
... ... @@ -25,18 +25,26 @@ $var jsfiles: static/coda-slider-2.0/javascripts/jquery-1.3.2.min.js static/coda
25 25  
26 26 <h1>AppRecommender Survey</h1>
27 27  
  28 +<div class="show-end" style="display: none;">
  29 +
  30 +<p>
  31 +A class <b>show-end</b> ou <b>hide-end</b> mostra um elemento ou esconde um elemento ao final do último Next.
  32 +</p>
  33 +
  34 +</div>
  35 +
  36 +
28 37 <form action="/save" method="post" enctype="multipart/form-data" name="surveyform">
29 38  
30 39 <input type="hidden" name="user_id" value=$request.user_id>
31 40 <input type="hidden" name="strategy" value=$request.strategy>
32   -<div id="controls-form" style="display: none;"><!-- display show in the end form -->
  41 +<div id="controls-form" style="display: none;" class="show-end"><!-- display show in the end form -->
33 42 <label for="finish_button" id="tip-finish">
34 43 <!--<div class="tip important">
35 44 <p>Conclude your participation in this survey</p>
36 45 </div>-->
37 46 <input id="finish-button" name="finish_button" type="submit" value="Finish" class="glass" />
38 47 </label>
39   -<br />
40 48 <label for="strategy_button" id="tip-continue">
41 49 <!--<div class="tip tip">
42 50 <p>Evaluate more suggestions </p>
... ... @@ -45,7 +53,7 @@ $var jsfiles: static/coda-slider-2.0/javascripts/jquery-1.3.2.min.js static/coda
45 53 </label>
46 54 </div><!-- id="controls-form" -->
47 55  
48   -<div class="coda-slider-wrapper">
  56 +<div class="coda-slider-wrapper hide-end">
49 57 <div class="coda-slider preload" id="coda-slider-1">
50 58 $for pkg in pkg_details:
51 59 <div class="panel">
... ... @@ -79,6 +87,10 @@ $for pkg in pkg_details:
79 87 </div>-->
80 88 </label>
81 89 <br style="clear: both;" />
  90 + </div><!-- #panel-controls -->
  91 + <div class="content-pkg">
  92 + <ul>
  93 + <li><b>Description</b>:
82 94 <div class="screenshot">
83 95 <a class="link-thumb" rel="facebox"
84 96 href="http://screenshots.debian.net/screenshot/$pkg['package']?.jpg"
... ... @@ -86,9 +98,7 @@ $for pkg in pkg_details:
86 98 <img src="http://screenshots.debian.net/thumbnail/$pkg['package']"
87 99 alt="Screenshot $pkg['package']" /></a>
88 100 </div><!-- screenshot -->
89   - </div><!-- #panel-controls -->
90   - <div class="content-pkg">
91   - <li><b>Description</b>: <br />$:pkg['long_description']</li>
  101 + <br />$:pkg['long_description']</li>
92 102 $if pkg['homepage']:
93 103 <li><b>Homepage</b>: $pkg['homepage']</li>
94 104 $if pkg['task']:
... ...