Fixed bug in manage-terms-top-set + added auto sorting in important-paste-by-module

This commit is contained in:
Mokaddem 2016-08-22 14:54:37 +02:00
parent e144e8e1c6
commit 2466f355ab
4 changed files with 11 additions and 7 deletions

View file

@ -113,7 +113,7 @@ if __name__ == "__main__":
temp = filename.split('/') temp = filename.split('/')
date = temp[-4] + temp[-3] + temp[-2] date = temp[-4] + temp[-3] + temp[-2]
timestamp = calendar.timegm((int(temp[-4]), int(temp[-3]), int(temp[-2]), 0, 0, 0)) timestamp = calendar.timegm((int(temp[-4]), int(temp[-3]), int(temp[-2]), 0, 0, 0))
top_termFreq_setName_day[0] += timestamp top_termFreq_setName_day[0] += str(timestamp)
low_word = word.lower() low_word = word.lower()

View file

@ -50,10 +50,12 @@ def manage_top_set():
dico = {} dico = {}
# Retreive top data (2*max_card) from days sets # Retreive top data (2*max_card) from days sets
for timestamp in range(startDate, startDate - num_day_month*oneDay, -oneDay): for timestamp in range(startDate, startDate - top_termFreq_setName_month[1]*oneDay, -oneDay):
top_termFreq_setName_day[0] += str(timestamp) curr_set = top_termFreq_setName_day[0] + str(timestamp)
array_top_day = server_term.zrangebyscore(top_termFreq_setName_day[0], '-inf', '+inf', withscores=True, start=0, num=top_term_freq_max_set_cardinality*2) print top_termFreq_setName_day[0]
array_top_day = server_term.zrangebyscore(curr_set, '-inf', '+inf', withscores=True, start=0, num=top_term_freq_max_set_cardinality*2)
print array_top_day
for word, value in array_top_day: for word, value in array_top_day:
if word in dico.keys(): if word in dico.keys():
dico[word] += value dico[word] += value
@ -68,12 +70,16 @@ def manage_top_set():
for w, v in dico.iteritems(): for w, v in dico.iteritems():
array_month.append((w, v)) array_month.append((w, v))
array_month.sort(key=lambda tup: -tup[1]) array_month.sort(key=lambda tup: -tup[1])
array_month = array_month[0:20]
array_week = [] array_week = []
for w, v in dico_week.iteritems(): for w, v in dico_week.iteritems():
array_week.append((w, v)) array_week.append((w, v))
array_week.sort(key=lambda tup: -tup[1]) array_week.sort(key=lambda tup: -tup[1])
array_week = array_week[0:20]
print array_month
print array_week
# suppress every terms in top sets # suppress every terms in top sets
for curr_set, curr_num_day in top_termFreq_set_array[1:3]: for curr_set, curr_num_day in top_termFreq_set_array[1:3]:

View file

@ -28,7 +28,7 @@
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
$('#myTable').dataTable(); $('#myTable').dataTable({ "order": [[ 2, "desc" ]] });
}); });
</script> </script>

View file

@ -463,11 +463,9 @@ function hide_or_show() {
var curr_term = $(this).attr('data-term'); var curr_term = $(this).attr('data-term');
var graph = $(this).attr('data-graph'); var graph = $(this).attr('data-graph');
var checked = $(this).prop('checked') var checked = $(this).prop('checked')
console.log(curr_term + ' ' + graph + ' ' + checked);
if(graph == "today") { if(graph == "today") {
var graphData = plot_today.getData(); var graphData = plot_today.getData();
console.log(graphData);
var index; var index;
for(i=0; i<graphData.length; i++){ for(i=0; i<graphData.length; i++){
if(graphData[i].label == curr_term){ if(graphData[i].label == curr_term){