Jul-04-2018, 08:39 AM
Hello, (first of all sorry for my english, I'm french **biggrin** )
I have a database in MySQL with this table:
CREATE TABLE Tri(
id VARCHAR(200) PRIMARY KEY,
nom TEXT,
adresse TEXT,
CP TEXT,
ville TEXT,
details TEXT,
organisme_gest TEXT,
organisme_gest_associe TEXT,
tel TEXT,
web TEXT,
mail TEXT,
date_d TEXT,
horaire TEXT,
photo TEXT,
date_f TEXT,
handicap TEXT
);
This basicly is storing data for event in France. In details there is all the information about the event.
I actually use only the id and details in my program.
I want to sort the database using keywords. To do so i have an idea:
Creating the list of the keyword (already done):
The only problem is how to do it efficiently? I've tried this program here:
In the end i don't know if the program is running properly and/or if I do it right!
Do you have any suggestions?
Thank you so much in advance :)
I have a database in MySQL with this table:
CREATE TABLE Tri(
id VARCHAR(200) PRIMARY KEY,
nom TEXT,
adresse TEXT,
CP TEXT,
ville TEXT,
details TEXT,
organisme_gest TEXT,
organisme_gest_associe TEXT,
tel TEXT,
web TEXT,
mail TEXT,
date_d TEXT,
horaire TEXT,
photo TEXT,
date_f TEXT,
handicap TEXT
);
This basicly is storing data for event in France. In details there is all the information about the event.
I actually use only the id and details in my program.
I want to sort the database using keywords. To do so i have an idea:
Creating the list of the keyword (already done):
#MC = ['route','autoroute','éclairage','public','parking','couvert','non','stationnement','rue','habitat', # 'logement','transport','bus','metro','tramway','train','avion','piste','cyclable','aire','jeu','enfant', # 'crêche','parentale','haltes','garderies','jardin','d\éveil','assistante maternelle', # 'école maternelle','école élémentaire','collège','lycée professionel','lycée général','lycée technologi', # 'lycée polyvalent','université','fac','campus','étudiant','centre','formation','sport','scolaire', # 'loisir','école','centre','aéré','rythme','péri','extra','MDPH','CDAPH','IME','IEM','ITEP','SESSAD', # 'FAM','SAVS','SAMSAH','ESAT','maladie','mentale','soin','infirmier','CLIC','aidant','EHPAD','alzheimer', # 'pôle','accueil','familial','domicile','agé','CDD','senior','loisir','CHRS','hebergement','urgence','asile', # 'femme','batue','addictologie','desintoxication','insertion','remobilisation','aide','alimentaire','colis', # 'urgence','RSA','ASE','aide','socia','enfan','protection','enfance','CAF','allocation','famill','aide', # 'devoir','soutien','MJC','maison','jeune','majeur','accès','soin','APL','résidence','universitaire', # 'CLE','hebergement','scolaire','mission','locale','Crous','financ','bourse','pharmacie','médicament', # 'santé','hôpita','hospital','clinique','ambulance','formation','sanitaire','toilette','douche', # 'patrimoine','château','exposition','collection','musée','art','contemporain','cinéma','projection','film', # 'télévision','reportage','salsa','tango','danse','hip-hop','bourrée','farandole','rock-and-roll','twist', # 'valse','bal','musette','country','flamenco','concert','musique','hestiv\'oc','concert','musique','hestiv\'oc', # 'opéra','théatre','cirque','artifice','illumination','pyrotechnie','pyromusical','carnaval','urbain','défilé', # 'médiathèque','bibliothèque','livre','lecture','ludothèque','baseball','basket-ball','football', # 'football américain','handball','hockey','pétanque','boulodrome','rugby','volley-ball','athlétisme', # 'ball-trap','poing','billard','snooker','bowling','quille','echec','equitation','cheval','equestre', # 'ecrime','fleuret','epée','gymnastique','musculation','haltérophilie','culturisme','javelot','pentathlon', # 'roller','skate','roulette','pistolet','carabine','arc','triathlo','twirling','majorette','aikido','aikibudo', # 'budo','boxe','ring','savate','full contact','judo','kendo','jujitsu','karaté','martiaux','kick','boxing', # 'lutte','Muaythai','teakwondo','tai','chuan','gong','badminton','tambourin','paume','padel','pelote', # 'pala','squash','tennis','pong','ping','aviron','canöe','kayak','char','voile','plongée','apnée','sous', # 'marin','joute','sauvetage','nautique','motonautique','jetski','natation','nage','piscine','pêche','ski', # 'nautique','surf','voile','aéromodélisme','aéronautique','aérostation','camarguaise','landaise','toromachie', # 'cyclisme','cyclotourisme','giraviation','golf','escalade','motocyclisme','parachutisme','ULM','pédestre', # 'sauvetage','secourisme','ski','spéléologie','automobile','glace','patinage','traineau','pulka','parapente', # 'planeur','état','civil','fiscal','impôt','taxe','administation','numérique','démocratie','participative', # 'participatif','assainissement','ATMO','déchêt','collecte','traitement','déchetterie','recyclage', # 'gendarmerie','commisariat','police','municipale','sécurité','ASVP','SDIS','pompiers','parc','potager', # 'lac','étang','rivière','marais','site','naturel','biodiversité','ENS','forêt','bois','point de vue', # 'table d\'orientation','chemin','pédestre','propre','netto','énergie','chauffage','électricité', # 'écologie','renouvable','durable','environnement','économie','innovation','commerc','artisan', # 'fabication','tourisme','vin','gastronomie','emploi','chômage','job','recrute','entreprise','industrie', # 'entreupreun','création','agricult','agricole','coopération','international']And i want to count the occurence of every word in every details. Depending on the word that appears the most i will put the data in a new database(I can manage this part).
The only problem is how to do it efficiently? I've tried this program here:
QUERY="""SELECT details from Tri""" cur.execute(QUERY) #result est une liste contenant les détails result_details=cur.fetchall() QUERY="""SELECT id from Tri""" cur.execute(QUERY) #result est une liste contenant les id result_id=cur.fetchall() #On teste les mots clés un par un MC = ['route',...,'international'] #as writen above for i in result_details : #création d'un tableau: 1ère colonne: mot-clé 2ème colonne: nb d'occurence OCCUR=[0]*len(MC) for j in range(len(MC)-1): OCCUR[j] = i.count(MC[j]) #Distinction de tous les mots qui sont apparus un maximum de fois #Liste qui contient tous les mots apparus un maximum de fois MA=[] #Occurence du mot étant apparu un nombre maximal de fois occ=0 for k in range(len(MC)-1): if OCCUR[k] > occ: occ = OCCUR[k] MA = [MC[k]] elif OCCUR[k] == occ: MA.append(MC[k])But i tried to run the program for an entire night and it keep running....
In the end i don't know if the program is running properly and/or if I do it right!
Do you have any suggestions?
Thank you so much in advance :)