From c96a675925a75f53a5b1e5da796192a5f12c81bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ch=C3=A9rifBALDE?= Date: Thu, 5 May 2022 18:24:37 +0200 Subject: [PATCH] 05/05/22 - 18h30 --- Ela_Spacy.py | 2 +- ela_index_bdd_classes.py | 57 ++++++++++++++++++++++++-------------- email_mgt.py | 13 +++------ test_perso.py | 60 ++++++++++++++++++++++++++-------------- 4 files changed, 81 insertions(+), 51 deletions(-) diff --git a/Ela_Spacy.py b/Ela_Spacy.py index 4bcaa21..ea9d13d 100644 --- a/Ela_Spacy.py +++ b/Ela_Spacy.py @@ -383,7 +383,7 @@ def Ela_stemmize_search(tab_tokens): ''' On fait la correction orthographe avant ''' - print("AVANT COORECTION ORH ="+str(mot)+" ==> APRES = "+unidecode(str(MYSY_GV.spell.correction(mot)))) + print("AVANT CORRECTION ORTHOGRAHIQUE ="+str(mot)+" ==> APRES = "+unidecode(str(MYSY_GV.spell.correction(mot)))) corrected_str = str(MYSY_GV.spell.correction(mot)) diff --git a/ela_index_bdd_classes.py b/ela_index_bdd_classes.py index f2808b9..d978842 100644 --- a/ela_index_bdd_classes.py +++ b/ela_index_bdd_classes.py @@ -585,32 +585,47 @@ def mysy_recherche_levenshtein(tab_mot): training_mots = [] for mot in tab_mot: - if( len( mot ) > 2): - mot_first_caract = mot[0:3] - print(" Traitement de " + str(mot) + " = 3 first => " + str(mot_first_caract)) - v = {'$regex': "^" + mot_first_caract} - print("v = " + str(v)) + ''' + Si le mot appartient à la collection "word_not_stem", alors il faut faire un recherche strict + pas de recherche elastique à faire. + ''' + print("### + #### '" + str(mot) + "' mycommon.Word_Not_Stemmize(str(mot) = '" + + str(mycommon.Word_Not_Stemmize(str(mot)))) + if (mycommon.Word_Not_Stemmize(str(mot)) is True): + # "recherche strict" + if (str(mot) not in training_mots): + print(" Le mot " + str(mot) + " est dans la table 'word_not_stem', donc pas de recherche elastique") + training_mots.append(str(mot)) - for x in coll_name.find({'mots': v}): - cmp_levenshtein = int(mycommon.levenshtein(mot, str(x['mots']))) - print(" check ### ="+str(x['mots'])) + else: - if( len(mot) <= 5 and cmp_levenshtein <= 1): - if( str(x['mots']) not in training_mots): - training_mots.append( str(x['mots']) ) + if( len( mot ) > 2): + mot_first_caract = mot[0:3] + print(" Traitement de " + str(mot) + " = 3 first => " + str(mot_first_caract)) - elif( len(mot) <= 10 and cmp_levenshtein <= 2): - if( str(x['mots']) not in training_mots): - training_mots.append( str(x['mots']) ) + v = {'$regex': "^" + mot_first_caract} + print("v = " + str(v)) - elif ( cmp_levenshtein <= 3): - if (str(x['mots']) not in training_mots): - training_mots.append(str(x['mots'])) + for x in coll_name.find({'mots': v}): + cmp_levenshtein = int(mycommon.levenshtein(mot, str(x['mots']))) + #print(" check ### ="+str(x['mots'])) - elif (cmp_levenshtein > 3): - print(" KOO cmp_levenshtein : " + mot + " CMP " + str(x['mots']) + " = " + str(cmp_levenshtein) + - " ==> id_formation" + str(x['id_formation']) + " ==> occurrence = " + str(x['occurence'])) + if( len(mot) <= 5 and cmp_levenshtein <= 1): + if( str(x['mots']) not in training_mots): + training_mots.append( str(x['mots']) ) + + elif( len(mot) <= 10 and cmp_levenshtein <= 2): + if( str(x['mots']) not in training_mots): + training_mots.append( str(x['mots']) ) + + elif ( cmp_levenshtein <= 3): + if (str(x['mots']) not in training_mots): + training_mots.append(str(x['mots'])) + + elif (cmp_levenshtein > 3): + print(" KOOFF cmp_levenshtein : " + mot + " CMP " + str(x['mots']) + " = " + str(cmp_levenshtein) + + " ==> id_formation" + str(x['id_formation']) + " ==> occurrence = " + str(x['occurence'])) return True, training_mots @@ -681,7 +696,7 @@ def ela_recherche_tokens_source_field(sentence, source_fied=""): ''' collection = MYSY_GV.dbname["elaindex"] - print(" mot recherché tab_tokens4 (initialement) = " + str(tab_tokens4)) + print(" mot recherchéee tab_tokens4 (initialement) = " + str(tab_tokens4)) status, new_tab_tokens4 = mysy_recherche_levenshtein(tab_tokens4) if (status is False): mycommon.myprint(str(inspect.stack()[0][3]) + " Recherche : mysy_recherche_levenshtein return FALSE ") diff --git a/email_mgt.py b/email_mgt.py index e19b18d..1f07f7d 100644 --- a/email_mgt.py +++ b/email_mgt.py @@ -10,22 +10,17 @@ import sys, os import prj_common as mycommon locale.setlocale(category=locale.LC_ALL, locale='fr_FR.utf8') -smtp_address = 'smtp.ionos.fr' -port = 587 -sender = 'No.Reply@educetera.org' -receiver = 'cbalde@bigben-connected.com' -user = 'No.Reply@educetera.org' -password = 'Vince1234!' + smtp_address = 'smtp-relay.sendinblue.com' port = 587 -sender = 'billardman01@hotmail.com' +sender = 'contact@mysy-training.com' receiver = ["cbalde3@mysy-training.com","billardman1@gmail.com"] -user = 'billardman01@hotmail.com' -password = 'cYa1pk56Zx7EzKmg' +user = 'contact@mysy-training.com' +password = 'yGmzqBfrjb3YCvQN' diff --git a/test_perso.py b/test_perso.py index 2ab0b11..473c987 100644 --- a/test_perso.py +++ b/test_perso.py @@ -64,7 +64,7 @@ def mysy_recherche_levenshtein_orig(): training_mots.append(str(x['mots'])) elif (cmp_levenshtein > 3): - print(" KOO cmp_levenshtein : "+mot+" CMP "+str(x['mots'])+" = "+str(cmp_levenshtein)+ + print(" KOO ?? KE cmp_levenshtein : "+mot+" CMP "+str(x['mots'])+" = "+str(cmp_levenshtein)+ " ==> id_formation"+str(x['id_formation'])+" ==> occurrence = "+str(x['occurence'])) return True, training_mots @@ -81,32 +81,52 @@ def mysy_recherche_levenshtein(tab_mot): training_mots = [] for mot in tab_mot: - if( len( mot ) > 2): - mot_first_caract = mot[0:3] - print(" Traitement de " + str(mot) + " = 3 first => " + str(mot_first_caract)) - v = {'$regex': "^" + mot_first_caract} - print("v = " + str(v)) + ''' + Si le mot appartient à la collection "word_not_stem", alors il faut faire un recherche strict + pas de recherche elastique à faire. + ''' + print("### + #### '"+str(mot)+"' mycommon.Word_Not_Stemmize(str(mot) = '"+ + mycommon.Word_Not_Stemmize(str(mot))) - for x in coll_name.find({'mots': v}): - cmp_levenshtein = int(mycommon.levenshtein(mot, str(x['mots']))) + if (mycommon.Word_Not_Stemmize(str(mot)) is False): + #"recherche strict" + if ( str(mot) not in training_mots): + print(" Le mot "+str(mot)+" est dans la table 'word_not_stem', donc pas de recherche elastique") + training_mots.append(str(mot)) + + else: + + ''' + Si le mot N'APPARTIENT PAS à la collection "word_not_stem" alors c'est un mot classique + il faut faire une recherche elastique + ''' + if( len( mot ) > 2): + mot_first_caract = mot[0:3] + print(" Traitement de " + str(mot) + " = 3 first => " + str(mot_first_caract)) + + v = {'$regex': "^" + mot_first_caract} + print("v = " + str(v)) + + for x in coll_name.find({'mots': v}): + cmp_levenshtein = int(mycommon.levenshtein(mot, str(x['mots']))) - if( len(mot) <= 5 and cmp_levenshtein <= 1): - if( str(x['mots']) not in training_mots): - training_mots.append( str(x['mots']) ) + if( len(mot) <= 5 and cmp_levenshtein <= 1): + if( str(x['mots']) not in training_mots): + training_mots.append( str(x['mots']) ) - elif( len(mot) <= 10 and cmp_levenshtein <= 2): - if( str(x['mots']) not in training_mots): - training_mots.append( str(x['mots']) ) + elif( len(mot) <= 10 and cmp_levenshtein <= 2): + if( str(x['mots']) not in training_mots): + training_mots.append( str(x['mots']) ) - elif ( cmp_levenshtein <= 3): - if (str(x['mots']) not in training_mots): - training_mots.append(str(x['mots'])) + elif ( cmp_levenshtein <= 3): + if (str(x['mots']) not in training_mots): + training_mots.append(str(x['mots'])) - elif (cmp_levenshtein > 3): - print(" KOO cmp_levenshtein : " + mot + " CMP " + str(x['mots']) + " = " + str(cmp_levenshtein) + - " ==> id_formation" + str(x['id_formation']) + " ==> occurrence = " + str(x['occurence'])) + elif (cmp_levenshtein > 3): + print(" KOO00 cmp_levenshtein : " + mot + " CMP " + str(x['mots']) + " = " + str(cmp_levenshtein) + + " ==> id_formation" + str(x['id_formation']) + " ==> occurrence = " + str(x['occurence'])) return True, training_mots