Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,15 +33,25 @@ with tab1:
|
|
33 |
pdf_path = 'data/07-VF2_UDM_Oneframe_A4-2023.pdf'
|
34 |
json_output_path = 'data/extracted_text.json'
|
35 |
|
36 |
-
if
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
# Onglet 2 - Questions Chatbot
|
47 |
with tab2:
|
|
|
33 |
pdf_path = 'data/07-VF2_UDM_Oneframe_A4-2023.pdf'
|
34 |
json_output_path = 'data/extracted_text.json'
|
35 |
|
36 |
+
if not os.path.exists(json_output_path):
|
37 |
+
if st.button('Extraire le texte du PDF et sauvegarder en JSON'):
|
38 |
+
pdf_text = extract_text_from_pdf(pdf_path)
|
39 |
+
save_text_to_json(pdf_text, json_output_path)
|
40 |
+
st.success("Le texte a été extrait et sauvegardé.")
|
41 |
+
else:
|
42 |
+
st.success(f"Le fichier {json_output_path} existe déjà. Aucune extraction nécessaire.")
|
43 |
+
|
44 |
+
try:
|
45 |
+
with open(json_output_path, 'r', encoding='utf-8') as f:
|
46 |
+
st.download_button(
|
47 |
+
label="Télécharger le JSON",
|
48 |
+
data=f,
|
49 |
+
file_name="extracted_text.json",
|
50 |
+
mime="application/json"
|
51 |
+
)
|
52 |
+
except FileNotFoundError:
|
53 |
+
st.error(f"Le fichier {json_output_path} n'est pas disponible pour téléchargement.")
|
54 |
+
|
55 |
|
56 |
# Onglet 2 - Questions Chatbot
|
57 |
with tab2:
|