From c52902e72e446ba20faaf3a8d03f7a8db9226e5a Mon Sep 17 00:00:00 2001 From: cherif Date: Tue, 8 Nov 2022 21:49:51 +0100 Subject: [PATCH] 08/11/22 - 21H --- class_mgt.py | 15 +++++++++------ data_indexees.csv | 4 ++-- ela_index_bdd_classes.py | 2 +- ela_output_test_file_pandas_2.txt | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/class_mgt.py b/class_mgt.py index 6a73f13..0105034 100644 --- a/class_mgt.py +++ b/class_mgt.py @@ -375,9 +375,11 @@ def add_class(diction): diction['external_code']) + " sont incorrectes. Le format attendu : " \ "jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse;jj/mm/aaaa-jj/mm/aaaa-ville-code_postale-adresse 2" - #print("### isdate = " + str(tab_date_lieu[0]) + " CM isdate_au = " + str(tab_date_lieu[1])) - if (datetime.strptime(str(tab_date_lieu[0]), '%d/%m/%Y') >= datetime.strptime( - str(tab_date_lieu[1]), '%d/%m/%Y')): + #print("### isdate = '" + str(tab_date_lieu[0]) + "' CM isdate_au = '" + str(tab_date_lieu[1])+"' ") + + + if (datetime.strptime(str(tab_date_lieu[0]).strip(), '%d/%m/%Y') > datetime.strptime( + str(tab_date_lieu[1]).strip(), '%d/%m/%Y')): mycommon.myprint( str(inspect.stack()[0][ 3]) + " - la date debut est posterieure à la date de fin pour la formation : " + str( @@ -386,7 +388,7 @@ def add_class(diction): diction['external_code']) + " " mytoday = datetime.today().strftime("%d/%m/%Y") - if (datetime.strptime(str(tab_date_lieu[0]), '%d/%m/%Y') < datetime.strptime(str(mytoday), + if (datetime.strptime(str(tab_date_lieu[0]).strip(), '%d/%m/%Y') < datetime.strptime(str(mytoday).strip(), '%d/%m/%Y')): mycommon.myprint( str(inspect.stack()[0][ @@ -766,7 +768,8 @@ def update_class(diction): #print(" ### tmp_dl = "+str(tmp_dl)) if (len(str(tmp_dl)) > 0 and ("-" in tmp_dl)): # print(" ###### DATE LIEU = "+tmp_dl) - tab_date_lieu = tmp_dl.split('-') + #tab_date_lieu = tmp_dl.split('-') + tab_date_lieu = [x.strip() for x in tmp_dl.split('-')] if (len(tab_date_lieu) != 5): return False, "Les Dates et Lieux de la formation " + str( diction['external_code']) + " sont incorrectes. Le format attendu : " \ @@ -792,7 +795,7 @@ def update_class(diction): #print("### isdate = " + str(tab_date_lieu[0]) + " CM isdate_au = " + str(tab_date_lieu[1])) - if (datetime.strptime(str(tab_date_lieu[0]), '%d/%m/%Y') >= datetime.strptime(str(tab_date_lieu[1]), '%d/%m/%Y')): + if (datetime.strptime(str(tab_date_lieu[0]).strip(), '%d/%m/%Y') > datetime.strptime(str(tab_date_lieu[1]).strip(), '%d/%m/%Y')): mycommon.myprint( str(inspect.stack()[0][ 3]) + " - la date debut est posterieure à la date de fin pour la formation : " + str( diff --git a/data_indexees.csv b/data_indexees.csv index 958bb1c..020a1c2 100644 --- a/data_indexees.csv +++ b/data_indexees.csv @@ -1,3 +1,3 @@ ,index,mots,occurence,moyenne,id_formation,source_field -0,0,sociale,1,0.5,POT_191206,title -1,1,actualite,1,0.5,POT_191206,title +0,0,formation,1,0.5,POT_191236,title +1,1,tuteur,1,0.5,POT_191236,title diff --git a/ela_index_bdd_classes.py b/ela_index_bdd_classes.py index 50457f1..d3af2cf 100644 --- a/ela_index_bdd_classes.py +++ b/ela_index_bdd_classes.py @@ -752,7 +752,7 @@ def ela_recherche_tokens(sentence): 'sum_occurence': {'$sum': '$occurence'} } }, - {'$sort': {'count_class': -1, 'sum_occurence': -1}}, + {'$sort': { 'sum_occurence': -1, 'count_class': -1,}}, {'$limit': MYSY_GV.QUERY_LIMIT_ROW} ] diff --git a/ela_output_test_file_pandas_2.txt b/ela_output_test_file_pandas_2.txt index 9667650..a4fa970 100644 --- a/ela_output_test_file_pandas_2.txt +++ b/ela_output_test_file_pandas_2.txt @@ -1,3 +1,3 @@ mots occurence moyenne id_formation source_field -0 sociale 1 0.5 POT_191206 title -1 actualite 1 0.5 POT_191206 title \ No newline at end of file +0 formation 1 0.5 POT_191236 title +1 tuteur 1 0.5 POT_191236 title \ No newline at end of file