Spaces:
Sleeping
Sleeping
Update modules/studentact/current_situation_interface.py
Browse files
modules/studentact/current_situation_interface.py
CHANGED
|
@@ -21,82 +21,41 @@ from .current_situation_analysis import (
|
|
| 21 |
)
|
| 22 |
|
| 23 |
logger = logging.getLogger(__name__)
|
| 24 |
-
|
| 25 |
-
def
|
| 26 |
"""
|
| 27 |
-
|
| 28 |
"""
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
st.session_state.text_input = ""
|
| 32 |
-
if 'show_results' not in st.session_state:
|
| 33 |
-
st.session_state.show_results = False
|
| 34 |
-
if 'current_doc' not in st.session_state:
|
| 35 |
-
st.session_state.current_doc = None
|
| 36 |
-
if 'current_metrics' not in st.session_state:
|
| 37 |
-
st.session_state.current_metrics = None
|
| 38 |
-
|
| 39 |
-
st.markdown("## An谩lisis Inicial de Escritura")
|
| 40 |
-
|
| 41 |
-
# Container principal con dos columnas
|
| 42 |
-
with st.container():
|
| 43 |
-
input_col, results_col = st.columns([1,2])
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
st.session_state.show_results = False # Resetear resultados cuando el texto cambia
|
| 52 |
-
|
| 53 |
-
# Text area con manejo de estado
|
| 54 |
-
text_input = st.text_area(
|
| 55 |
-
t.get('input_prompt', "Escribe o pega tu texto aqu铆:"),
|
| 56 |
-
height=400,
|
| 57 |
-
key="text_area",
|
| 58 |
-
value=st.session_state.text_input,
|
| 59 |
-
on_change=on_text_change,
|
| 60 |
-
help="Este texto ser谩 analizado para darte recomendaciones personalizadas"
|
| 61 |
-
)
|
| 62 |
-
|
| 63 |
-
# Bot贸n de an谩lisis
|
| 64 |
-
if st.button(
|
| 65 |
-
t.get('analyze_button', "Analizar mi escritura"),
|
| 66 |
-
type="primary",
|
| 67 |
-
disabled=not text_input.strip(),
|
| 68 |
-
use_container_width=True,
|
| 69 |
-
):
|
| 70 |
-
try:
|
| 71 |
-
with st.spinner(t.get('processing', "Analizando...")):
|
| 72 |
-
# Procesar texto y obtener m茅tricas
|
| 73 |
-
doc = nlp_models[lang_code](text_input)
|
| 74 |
-
metrics = analyze_text_dimensions(doc)
|
| 75 |
-
|
| 76 |
-
# Actualizar estado con nuevos resultados
|
| 77 |
-
st.session_state.current_doc = doc
|
| 78 |
-
st.session_state.current_metrics = metrics
|
| 79 |
-
st.session_state.show_results = True
|
| 80 |
-
|
| 81 |
-
# Mantener el texto en el estado
|
| 82 |
-
st.session_state.text_input = text_input
|
| 83 |
-
|
| 84 |
-
except Exception as e:
|
| 85 |
-
logger.error(f"Error en an谩lisis: {str(e)}")
|
| 86 |
-
st.error(t.get('analysis_error', "Error al analizar el texto"))
|
| 87 |
|
| 88 |
-
#
|
| 89 |
-
with
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
|
|
|
| 100 |
def display_recommendations(metrics, t):
|
| 101 |
"""
|
| 102 |
Muestra recomendaciones basadas en las m茅tricas del texto.
|
|
|
|
| 21 |
)
|
| 22 |
|
| 23 |
logger = logging.getLogger(__name__)
|
| 24 |
+
####################################
|
| 25 |
+
def display_current_situation_visual(doc, metrics):
|
| 26 |
"""
|
| 27 |
+
Muestra visualizaciones detalladas del an谩lisis.
|
| 28 |
"""
|
| 29 |
+
try:
|
| 30 |
+
st.markdown("### 馃搳 Visualizaciones Detalladas")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
# 1. Visualizaci贸n de vocabulario
|
| 33 |
+
with st.expander("An谩lisis de Vocabulario", expanded=True):
|
| 34 |
+
vocab_graph = create_vocabulary_network(doc)
|
| 35 |
+
if vocab_graph:
|
| 36 |
+
st.pyplot(vocab_graph)
|
| 37 |
+
plt.close(vocab_graph)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
# 2. Visualizaci贸n de estructura
|
| 40 |
+
with st.expander("An谩lisis de Estructura", expanded=True):
|
| 41 |
+
syntax_graph = create_syntax_complexity_graph(doc)
|
| 42 |
+
if syntax_graph:
|
| 43 |
+
st.pyplot(syntax_graph)
|
| 44 |
+
plt.close(syntax_graph)
|
| 45 |
+
|
| 46 |
+
# 3. Visualizaci贸n de cohesi贸n
|
| 47 |
+
with st.expander("An谩lisis de Cohesi贸n", expanded=True):
|
| 48 |
+
cohesion_graph = create_cohesion_heatmap(doc)
|
| 49 |
+
if cohesion_graph:
|
| 50 |
+
st.pyplot(cohesion_graph)
|
| 51 |
+
plt.close(cohesion_graph)
|
| 52 |
+
|
| 53 |
+
except Exception as e:
|
| 54 |
+
logger.error(f"Error en visualizaci贸n: {str(e)}")
|
| 55 |
+
st.error("Error al generar las visualizaciones")
|
| 56 |
+
|
| 57 |
|
| 58 |
+
####################################
|
| 59 |
def display_recommendations(metrics, t):
|
| 60 |
"""
|
| 61 |
Muestra recomendaciones basadas en las m茅tricas del texto.
|