From db1548554c9501a10d683cd66befba2d8b1c1768 Mon Sep 17 00:00:00 2001 From: cherif Date: Tue, 1 Nov 2022 19:05:47 +0100 Subject: [PATCH] 01/11/2022 - 19h --- GlobalVariable.py | 2 +- class_mgt.py | 32 +++++++++++++++++++++++++------ data_indexees.csv | 6 +++--- ela_output_test_file_pandas_2.txt | 8 ++++---- wrapper.py | 2 +- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/GlobalVariable.py b/GlobalVariable.py index 13aa442..f1b3a5a 100644 --- a/GlobalVariable.py +++ b/GlobalVariable.py @@ -63,7 +63,7 @@ token_fr_pontuation = [] La taille maximal d'un champs à retourner. Au dela de 300 caractère, le système rame ''' -MAX_CARACT = 100 +MAX_CARACT = 300 MAX_CARACT_DEDUIT = 150 TOKEN_SIZE = 25 MAX_CARACT_DETAIL = 500 diff --git a/class_mgt.py b/class_mgt.py index 38e4e97..acadd7c 100644 --- a/class_mgt.py +++ b/class_mgt.py @@ -314,6 +314,8 @@ def add_class(diction): if diction['date_lieu']: tmp_str2 = str(diction['date_lieu']).lower().replace(",", ";").replace("\r\n", "") + #print(" ### tmp_str2 = "+str(tmp_str2)) + if (not tmp_str2.endswith(";")): tmp_str2 = tmp_str2 + ";" @@ -337,8 +339,9 @@ def add_class(diction): dl_cpt = 0 tab_dl = [] for tmp_dl in tmp_str: + #print(" ##### tmp_dl = "+str(tmp_dl)) if (len(str(tmp_dl)) > 0 and ("-" in tmp_dl)): - # print(" ###### DATE LIEU = "+tmp_dl) + #print(" ###### DATE LIEU = "+str(tmp_dl)) tab_date_lieu = tmp_dl.split('-') if (len(tab_date_lieu) != 5): return False, "Les Dates et Lieux de la formation " + str( @@ -363,7 +366,7 @@ 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])) + #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')): mycommon.myprint( @@ -395,10 +398,19 @@ def add_class(diction): session_id = mycommon.remove_non_ascii(session_id) session_id = re.sub(r'[^a-zA-Z0-9]', '', session_id) + ## Verifier si le CP n'est composé que de "0", au quel cas il s'agit d'une formation en ligne. + local_cp = str(tab_date_lieu[3]).replace("0", "").strip() + class_cp = "" + if (local_cp == ""): + class_cp = "0" + else: + class_cp = str(tab_date_lieu[3]).strip() + + val_dl = {'date_du': str(tab_date_lieu[0]).strip(), 'date_au': str(tab_date_lieu[1]).strip(), - 'ville': str(tab_date_lieu[2]).strip(), 'code_postal': str(tab_date_lieu[3]).strip(), + 'ville': str(tab_date_lieu[2]).strip(), 'code_postal': str(class_cp).strip(), 'adresse': str(tab_date_lieu[4]).strip(), 'session_id': str(session_id).strip()} - tab_dl.append(val_dl) + tab_dl.append(val_dl) # mydata['date_lieu'][dl_cpt] = {'date': str(tab_date_lieu[0]), 'ville': str(tab_date_lieu[1])} @@ -792,8 +804,16 @@ def update_class(diction): session_id = mycommon.remove_non_ascii(session_id) session_id = re.sub(r'[^a-zA-Z0-9]', '', session_id) + ## Verifier si le CP n'est composé que de "0", au quel cas il s'agit d'une formation en ligne. + local_cp = str(tab_date_lieu[3]).replace("0", "").strip() + class_cp = "" + if (local_cp == ""): + class_cp = "0" + else: + class_cp = str(tab_date_lieu[3]).strip() + val_dl = {'date_du': str(tab_date_lieu[0]).strip(), 'date_au': str(tab_date_lieu[1]).strip(), - 'ville': str(tab_date_lieu[2]).strip(), 'code_postal': str(tab_date_lieu[3]).strip(), + 'ville': str(tab_date_lieu[2]).strip(), 'code_postal': str(class_cp).strip(), 'adresse': str(tab_date_lieu[4]).strip(), 'session_id':str(session_id).strip()} tab_dl.append(val_dl) # mydata['date_lieu'][dl_cpt] = {'date': str(tab_date_lieu[0]), 'ville': str(tab_date_lieu[1])} @@ -1657,7 +1677,7 @@ def get_class(diction): retVal['pedagogie'] = tmp_str[:MYSY_GV.MAX_CARACT_DETAIL] + " ..." - #mycommon.myprint(str(retVal)) + #mycommon.myprint(" #### "+str(retVal)) user = retVal RetObject.append(JSONEncoder().encode(user)) diff --git a/data_indexees.csv b/data_indexees.csv index 78c5696..af36222 100644 --- a/data_indexees.csv +++ b/data_indexees.csv @@ -1,4 +1,4 @@ ,index,mots,occurence,moyenne,id_formation,source_field -0,0,effect,1,0.33,VP10619,title -1,1,effet,1,0.33,VP10619,title -2,2,after,1,0.33,VP10619,title +0,0,financiere,1,0.33,POT_CL20001,title +1,1,entreprise,1,0.33,POT_CL20001,title +2,2,analyse,1,0.33,POT_CL20001,title diff --git a/ela_output_test_file_pandas_2.txt b/ela_output_test_file_pandas_2.txt index 7783baa..b66da1b 100644 --- a/ela_output_test_file_pandas_2.txt +++ b/ela_output_test_file_pandas_2.txt @@ -1,4 +1,4 @@ - mots occurence moyenne id_formation source_field -0 effect 1 0.33 VP10619 title -1 effet 1 0.33 VP10619 title -2 after 1 0.33 VP10619 title \ No newline at end of file + mots occurence moyenne id_formation source_field +0 financiere 1 0.33 POT_CL20001 title +1 entreprise 1 0.33 POT_CL20001 title +2 analyse 1 0.33 POT_CL20001 title \ No newline at end of file diff --git a/wrapper.py b/wrapper.py index cc9b0f8..1d707a2 100644 --- a/wrapper.py +++ b/wrapper.py @@ -350,7 +350,7 @@ def get_training_in_user_zone(diction): - #print("AVANT ==> "+str(x['description'])) + #print("AVANT 2 ==> "+str(x['description'])+" taille = "+str( len(x['description']) )) val = x['description'] if( len(x['description']) > MYSY_GV.MAX_CARACT ): x['description'] = val[:MYSY_GV.MAX_CARACT]+" ..."