Spaces:
Sleeping
Sleeping
Update modules/studentact/current_situation_interface.py
Browse files
modules/studentact/current_situation_interface.py
CHANGED
|
@@ -62,7 +62,6 @@ TEXT_TYPES = {
|
|
| 62 |
}
|
| 63 |
}
|
| 64 |
####################################
|
| 65 |
-
|
| 66 |
def display_current_situation_interface(lang_code, nlp_models, current_situation_t):
|
| 67 |
"""
|
| 68 |
Interfaz simplificada con gráfico de radar para visualizar métricas.
|
|
@@ -87,7 +86,7 @@ def display_current_situation_interface(lang_code, nlp_models, current_situation
|
|
| 87 |
with input_col:
|
| 88 |
# Text area con manejo de estado
|
| 89 |
text_input = st.text_area(
|
| 90 |
-
current_situation_t.get('input_prompt', 'Escribe tu texto aquí'),
|
| 91 |
height=400,
|
| 92 |
key="text_area",
|
| 93 |
value=st.session_state.text_input,
|
|
@@ -100,13 +99,13 @@ def display_current_situation_interface(lang_code, nlp_models, current_situation
|
|
| 100 |
st.session_state.show_results = False
|
| 101 |
|
| 102 |
if st.button(
|
| 103 |
-
current_situation_t.get('analyze_button', 'Analizar texto'),
|
| 104 |
type="primary",
|
| 105 |
disabled=not text_input.strip(),
|
| 106 |
use_container_width=True,
|
| 107 |
):
|
| 108 |
try:
|
| 109 |
-
with st.spinner(current_situation_t.get('processing', 'Analizando...')):
|
| 110 |
doc = nlp_models[lang_code](text_input)
|
| 111 |
metrics = analyze_text_dimensions(doc)
|
| 112 |
|
|
@@ -126,34 +125,74 @@ def display_current_situation_interface(lang_code, nlp_models, current_situation
|
|
| 126 |
|
| 127 |
except Exception as e:
|
| 128 |
logger.error(f"Error en análisis: {str(e)}")
|
| 129 |
-
st.error(current_situation_t.get('analysis_error', 'Error analyzing text'))
|
| 130 |
|
| 131 |
# Mostrar resultados en la columna derecha
|
| 132 |
with results_col:
|
| 133 |
if st.session_state.show_results and st.session_state.current_metrics is not None:
|
| 134 |
# Primero los radio buttons para tipo de texto
|
| 135 |
-
st.markdown(f"### {current_situation_t
|
| 136 |
text_type = st.radio(
|
| 137 |
"Selecciona el tipo de texto",
|
| 138 |
options=list(TEXT_TYPES.keys()),
|
| 139 |
format_func=lambda x: TEXT_TYPES[x]['name'],
|
| 140 |
horizontal=True,
|
| 141 |
key="text_type_radio",
|
| 142 |
-
help=current_situation_t.get('text_type_help', 'Select the type of text to adjust the evaluation criteria')
|
| 143 |
)
|
| 144 |
|
| 145 |
st.session_state.current_text_type = text_type
|
| 146 |
|
| 147 |
-
#
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
current_situation_t=current_situation_t
|
| 152 |
)
|
| 153 |
|
| 154 |
except Exception as e:
|
| 155 |
logger.error(f"Error en interfaz principal: {str(e)}")
|
| 156 |
-
st.error(current_situation_t.get('error_interface', 'Interface error'))
|
|
|
|
| 157 |
|
| 158 |
######################################
|
| 159 |
def display_radar_chart(metrics_config, thresholds, current_situation_t):
|
|
|
|
| 62 |
}
|
| 63 |
}
|
| 64 |
####################################
|
|
|
|
| 65 |
def display_current_situation_interface(lang_code, nlp_models, current_situation_t):
|
| 66 |
"""
|
| 67 |
Interfaz simplificada con gráfico de radar para visualizar métricas.
|
|
|
|
| 86 |
with input_col:
|
| 87 |
# Text area con manejo de estado
|
| 88 |
text_input = st.text_area(
|
| 89 |
+
current_situation_t.get('input_prompt', 'Escribe tu texto aquí'),
|
| 90 |
height=400,
|
| 91 |
key="text_area",
|
| 92 |
value=st.session_state.text_input,
|
|
|
|
| 99 |
st.session_state.show_results = False
|
| 100 |
|
| 101 |
if st.button(
|
| 102 |
+
current_situation_t.get('analyze_button', 'Analizar texto'),
|
| 103 |
type="primary",
|
| 104 |
disabled=not text_input.strip(),
|
| 105 |
use_container_width=True,
|
| 106 |
):
|
| 107 |
try:
|
| 108 |
+
with st.spinner(current_situation_t.get('processing', 'Analizando...')):
|
| 109 |
doc = nlp_models[lang_code](text_input)
|
| 110 |
metrics = analyze_text_dimensions(doc)
|
| 111 |
|
|
|
|
| 125 |
|
| 126 |
except Exception as e:
|
| 127 |
logger.error(f"Error en análisis: {str(e)}")
|
| 128 |
+
st.error(current_situation_t.get('analysis_error', 'Error analyzing text'))
|
| 129 |
|
| 130 |
# Mostrar resultados en la columna derecha
|
| 131 |
with results_col:
|
| 132 |
if st.session_state.show_results and st.session_state.current_metrics is not None:
|
| 133 |
# Primero los radio buttons para tipo de texto
|
| 134 |
+
st.markdown(f"### {current_situation_t.get('text_type_header', 'Tipo de texto')}")
|
| 135 |
text_type = st.radio(
|
| 136 |
"Selecciona el tipo de texto",
|
| 137 |
options=list(TEXT_TYPES.keys()),
|
| 138 |
format_func=lambda x: TEXT_TYPES[x]['name'],
|
| 139 |
horizontal=True,
|
| 140 |
key="text_type_radio",
|
| 141 |
+
help=current_situation_t.get('text_type_help', 'Select the type of text to adjust the evaluation criteria')
|
| 142 |
)
|
| 143 |
|
| 144 |
st.session_state.current_text_type = text_type
|
| 145 |
|
| 146 |
+
# Obtener umbrales basados en el tipo de texto
|
| 147 |
+
thresholds = TEXT_TYPES[text_type]['thresholds']
|
| 148 |
+
|
| 149 |
+
# Preparar configuración de métricas para el gráfico de radar
|
| 150 |
+
metrics_config = [
|
| 151 |
+
{
|
| 152 |
+
'label': current_situation_t.get('vocabulary_label', 'Vocabulario'),
|
| 153 |
+
'value': st.session_state.current_metrics['vocabulary'],
|
| 154 |
+
'thresholds': {
|
| 155 |
+
'min': thresholds['vocabulary']['min'],
|
| 156 |
+
'target': thresholds['vocabulary']['target']
|
| 157 |
+
}
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
'label': current_situation_t.get('structure_label', 'Estructura'),
|
| 161 |
+
'value': st.session_state.current_metrics['structure'],
|
| 162 |
+
'thresholds': {
|
| 163 |
+
'min': thresholds['structure']['min'],
|
| 164 |
+
'target': thresholds['structure']['target']
|
| 165 |
+
}
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
'label': current_situation_t.get('cohesion_label', 'Cohesión'),
|
| 169 |
+
'value': st.session_state.current_metrics['cohesion'],
|
| 170 |
+
'thresholds': {
|
| 171 |
+
'min': thresholds['cohesion']['min'],
|
| 172 |
+
'target': thresholds['cohesion']['target']
|
| 173 |
+
}
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
'label': current_situation_t.get('clarity_label', 'Claridad'),
|
| 177 |
+
'value': st.session_state.current_metrics['clarity'],
|
| 178 |
+
'thresholds': {
|
| 179 |
+
'min': thresholds['clarity']['min'],
|
| 180 |
+
'target': thresholds['clarity']['target']
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
]
|
| 184 |
+
|
| 185 |
+
# Usar la función display_radar_chart que ya existe
|
| 186 |
+
display_radar_chart(
|
| 187 |
+
metrics_config=metrics_config,
|
| 188 |
+
thresholds=thresholds,
|
| 189 |
current_situation_t=current_situation_t
|
| 190 |
)
|
| 191 |
|
| 192 |
except Exception as e:
|
| 193 |
logger.error(f"Error en interfaz principal: {str(e)}")
|
| 194 |
+
st.error(current_situation_t.get('error_interface', 'Interface error'))
|
| 195 |
+
|
| 196 |
|
| 197 |
######################################
|
| 198 |
def display_radar_chart(metrics_config, thresholds, current_situation_t):
|