Spaces:
Sleeping
Sleeping
Commit
·
8efdfea
1
Parent(s):
cde4985
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,4 +21,26 @@ if text:
|
|
| 21 |
top_n = 5
|
| 22 |
distances = cosine_similarity(doc_embedding, candidate_embeddings)
|
| 23 |
keywords = [candidates[index] for index in distances.argsort()[0][-top_n:]]
|
| 24 |
-
st.json(keywords)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
top_n = 5
|
| 22 |
distances = cosine_similarity(doc_embedding, candidate_embeddings)
|
| 23 |
keywords = [candidates[index] for index in distances.argsort()[0][-top_n:]]
|
| 24 |
+
st.json(keywords)
|
| 25 |
+
conn = sqlite3.connect('SU_CSV.db')
|
| 26 |
+
cursor = conn.cursor()
|
| 27 |
+
|
| 28 |
+
mots_cles_recherches = keywords
|
| 29 |
+
|
| 30 |
+
# Création de la requête SQL
|
| 31 |
+
query = f"SELECT title_s FROM BDD_Provisoire_SU WHERE {' OR '.join(['keyword_s LIKE ?'] * len(mots_cles_recherches))}"
|
| 32 |
+
params = ['%' + mot + '%' for mot in mots_cles_recherches]
|
| 33 |
+
|
| 34 |
+
cursor.execute(query, params)
|
| 35 |
+
resultats = cursor.fetchall()
|
| 36 |
+
|
| 37 |
+
# Affichage des titres d'articles trouvés
|
| 38 |
+
if resultats:
|
| 39 |
+
print("Titres d'articles correspondant aux mots-clés:")
|
| 40 |
+
for row in resultats:
|
| 41 |
+
print(row[0])
|
| 42 |
+
else:
|
| 43 |
+
print("Aucun article trouvé pour les mots-clés spécifiés.")
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
conn.close()
|