Spaces:
Running
Running
Commit
·
133976c
1
Parent(s):
eb41b9a
progress more (3.6)
Browse files
app.py
CHANGED
@@ -18,6 +18,45 @@ import pdfkit
|
|
18 |
from jinja2 import Template
|
19 |
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
def display_sentiment_results(row, sentiment, impact=None, reasoning=None):
|
23 |
if sentiment == "Negative":
|
@@ -304,10 +343,20 @@ def process_file(uploaded_file):
|
|
304 |
# Generate PDF at the end of processing
|
305 |
save_streamlit_output_to_pdf(output_capture.texts)
|
306 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
return df
|
308 |
|
309 |
-
|
310 |
-
|
|
|
311 |
|
312 |
def create_analysis_data(df):
|
313 |
analysis_data = []
|
@@ -402,6 +451,14 @@ def create_output_file(df, uploaded_file):
|
|
402 |
return output
|
403 |
|
404 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
st.markdown(
|
406 |
"""
|
407 |
<style>
|
@@ -420,7 +477,7 @@ def main():
|
|
420 |
unsafe_allow_html=True
|
421 |
)
|
422 |
|
423 |
-
st.title("::: анализ мониторинга новостей СКАН-ИНТЕРФАКС (v.3.
|
424 |
|
425 |
if 'processed_df' not in st.session_state:
|
426 |
st.session_state.processed_df = None
|
|
|
18 |
from jinja2 import Template
|
19 |
|
20 |
|
21 |
+
def create_download_section(excel_data, pdf_data):
|
22 |
+
st.markdown("""
|
23 |
+
<style>
|
24 |
+
.download-container {
|
25 |
+
padding: 20px;
|
26 |
+
background-color: #f0f2f6;
|
27 |
+
border-radius: 10px;
|
28 |
+
margin: 20px 0;
|
29 |
+
}
|
30 |
+
.download-header {
|
31 |
+
color: #0066cc;
|
32 |
+
font-size: 18px;
|
33 |
+
font-weight: bold;
|
34 |
+
margin-bottom: 10px;
|
35 |
+
}
|
36 |
+
</style>
|
37 |
+
<div class="download-container">
|
38 |
+
<div class="download-header">📥 Результаты анализа готовы к скачиванию:</div>
|
39 |
+
</div>
|
40 |
+
""", unsafe_allow_html=True)
|
41 |
+
|
42 |
+
col1, col2 = st.columns(2)
|
43 |
+
with col1:
|
44 |
+
st.download_button(
|
45 |
+
label="📊 Скачать Excel отчет",
|
46 |
+
data=excel_data,
|
47 |
+
file_name="результат_анализа.xlsx",
|
48 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
49 |
+
key="excel_download"
|
50 |
+
)
|
51 |
+
with col2:
|
52 |
+
st.download_button(
|
53 |
+
label="📄 Скачать PDF протокол",
|
54 |
+
data=pdf_data,
|
55 |
+
file_name="протокол_анализа.pdf",
|
56 |
+
mime="application/pdf",
|
57 |
+
key="pdf_download"
|
58 |
+
)
|
59 |
+
|
60 |
|
61 |
def display_sentiment_results(row, sentiment, impact=None, reasoning=None):
|
62 |
if sentiment == "Negative":
|
|
|
343 |
# Generate PDF at the end of processing
|
344 |
save_streamlit_output_to_pdf(output_capture.texts)
|
345 |
|
346 |
+
# Prepare both files
|
347 |
+
excel_output = create_output_file(df, uploaded_file)
|
348 |
+
pdf_data = save_streamlit_output_to_pdf(output_capture.texts)
|
349 |
+
|
350 |
+
# Show success message
|
351 |
+
st.success(f"✅ Обработка и анализ завершены за {formatted_time}.")
|
352 |
+
|
353 |
+
# Create download section
|
354 |
+
create_download_section(excel_output, pdf_data)
|
355 |
return df
|
356 |
|
357 |
+
except Exception as e:
|
358 |
+
st.error(f"❌ Ошибка при обработке файла: {str(e)}")
|
359 |
+
raise e
|
360 |
|
361 |
def create_analysis_data(df):
|
362 |
analysis_data = []
|
|
|
451 |
return output
|
452 |
|
453 |
def main():
|
454 |
+
|
455 |
+
with st.expander("ℹ️ Как пользоваться"):
|
456 |
+
st.markdown("""
|
457 |
+
1. Загрузите Excel файл с новостями
|
458 |
+
2. Дождитесь завершения анализа
|
459 |
+
3. Скачайте результаты анализа в нужном формате (Excel и/или PDF)
|
460 |
+
""")
|
461 |
+
|
462 |
st.markdown(
|
463 |
"""
|
464 |
<style>
|
|
|
477 |
unsafe_allow_html=True
|
478 |
)
|
479 |
|
480 |
+
st.title("::: анализ мониторинга новостей СКАН-ИНТЕРФАКС (v.3.6):::")
|
481 |
|
482 |
if 'processed_df' not in st.session_state:
|
483 |
st.session_state.processed_df = None
|