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
|
2 |
+
|
3 |
+
import streamlit as st
|
4 |
+
import logging
|
5 |
+
from ..utils.widget_utils import generate_unique_key
|
6 |
+
import matplotlib.pyplot as plt
|
7 |
+
import numpy as np
|
8 |
+
from ..database.current_situation_mongo_db import store_current_situation_result
|
9 |
+
|
10 |
+
# Importaciones locales
|
11 |
+
from translations import get_translations
|
12 |
+
|
13 |
+
from .current_situation_analysis import (
|
14 |
+
analyze_text_dimensions,
|
15 |
+
analyze_clarity,
|
16 |
+
analyze_vocabulary_diversity,
|
17 |
+
analyze_cohesion,
|
18 |
+
analyze_structure,
|
19 |
+
get_dependency_depths,
|
20 |
+
normalize_score,
|
21 |
+
generate_sentence_graphs,
|
22 |
+
generate_word_connections,
|
23 |
+
generate_connection_paths,
|
24 |
+
create_vocabulary_network,
|
25 |
+
create_syntax_complexity_graph,
|
26 |
+
create_cohesion_heatmap,
|
27 |
+
generate_recommendations
|
28 |
+
)
|
29 |
+
|
30 |
+
# Configuración del estilo de matplotlib para el gráfico de radar
|
31 |
+
plt.rcParams['font.family'] = 'sans-serif'
|
32 |
+
plt.rcParams['axes.grid'] = True
|
33 |
+
plt.rcParams['axes.spines.top'] = False
|
34 |
+
plt.rcParams['axes.spines.right'] = False
|
35 |
+
|
36 |
+
logger = logging.getLogger(__name__)
|
37 |
+
####################################
|
38 |
+
|
39 |
+
TEXT_TYPES = {
|
40 |
+
'academic_article': {
|
41 |
+
'name': 'Artículo Académico',
|
42 |
+
'thresholds': {
|
43 |
+
'vocabulary': {'min': 0.70, 'target': 0.85},
|
44 |
+
'structure': {'min': 0.75, 'target': 0.90},
|
45 |
+
'cohesion': {'min': 0.65, 'target': 0.80},
|
46 |
+
'clarity': {'min': 0.70, 'target': 0.85}
|
47 |
+
}
|
48 |
+
},
|
49 |
+
'student_essay': {
|
50 |
+
'name': 'Trabajo Universitario',
|
51 |
+
'thresholds': {
|
52 |
+
'vocabulary': {'min': 0.60, 'target': 0.75},
|
53 |
+
'structure': {'min': 0.65, 'target': 0.80},
|
54 |
+
'cohesion': {'min': 0.55, 'target': 0.70},
|
55 |
+
'clarity': {'min': 0.60, 'target': 0.75}
|
56 |
+
}
|
57 |
+
},
|
58 |
+
'general_communication': {
|
59 |
+
'name': 'Comunicación General',
|
60 |
+
'thresholds': {
|
61 |
+
'vocabulary': {'min': 0.50, 'target': 0.65},
|
62 |
+
'structure': {'min': 0.55, 'target': 0.70},
|
63 |
+
'cohesion': {'min': 0.45, 'target': 0.60},
|
64 |
+
'clarity': {'min': 0.50, 'target': 0.65}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
####################################
|
69 |
+
|
70 |
+
def display_current_situation_interface(lang_code, nlp_models, t):
|
71 |
+
"""
|
72 |
+
Interfaz simplificada con gráfico de radar para visualizar métricas.
|
73 |
+
"""
|
74 |
+
# Inicializar estados si no existen
|
75 |
+
if 'text_input' not in st.session_state:
|
76 |
+
st.session_state.text_input = ""
|
77 |
+
if 'text_area' not in st.session_state: # Añadir inicialización de text_area
|
78 |
+
st.session_state.text_area = ""
|
79 |
+
if 'show_results' not in st.session_state:
|
80 |
+
st.session_state.show_results = False
|
81 |
+
if 'current_doc' not in st.session_state:
|
82 |
+
st.session_state.current_doc = None
|
83 |
+
if 'current_metrics' not in st.session_state:
|
84 |
+
st.session_state.current_metrics = None
|
85 |
+
if 'current_recommendations' not in st.session_state:
|
86 |
+
st.session_state.current_recommendations = None
|
87 |
+
|
88 |
+
try:
|
89 |
+
# Container principal con dos columnas
|
90 |
+
with st.container():
|
91 |
+
input_col, results_col = st.columns([1,2])
|
92 |
+
|
93 |
+
with input_col:
|
94 |
+
# Text area con manejo de estado
|
95 |
+
text_input = st.text_area(
|
96 |
+
t.get('input_prompt', "Escribe o pega tu texto aquí:"),
|
97 |
+
height=400,
|
98 |
+
key="text_area",
|
99 |
+
value=st.session_state.text_input,
|
100 |
+
help="Este texto será analizado para darte recomendaciones personalizadas"
|
101 |
+
)
|
102 |
+
|
103 |
+
# Función para manejar cambios de texto
|
104 |
+
if text_input != st.session_state.text_input:
|
105 |
+
st.session_state.text_input = text_input
|
106 |
+
st.session_state.show_results = False
|
107 |
+
|
108 |
+
if st.button(
|
109 |
+
t.get('analyze_button', "Analizar mi escritura"),
|
110 |
+
type="primary",
|
111 |
+
disabled=not text_input.strip(),
|
112 |
+
use_container_width=True,
|
113 |
+
):
|
114 |
+
try:
|
115 |
+
with st.spinner(t.get('processing', "Analizando...")):
|
116 |
+
doc = nlp_models[lang_code](text_input)
|
117 |
+
metrics = analyze_text_dimensions(doc)
|
118 |
+
|
119 |
+
storage_success = store_current_situation_result(
|
120 |
+
username=st.session_state.username,
|
121 |
+
text=text_input,
|
122 |
+
metrics=metrics,
|
123 |
+
feedback=None
|
124 |
+
)
|
125 |
+
|
126 |
+
if not storage_success:
|
127 |
+
logger.warning("No se pudo guardar el análisis en la base de datos")
|
128 |
+
|
129 |
+
st.session_state.current_doc = doc
|
130 |
+
st.session_state.current_metrics = metrics
|
131 |
+
st.session_state.show_results = True
|
132 |
+
|
133 |
+
except Exception as e:
|
134 |
+
logger.error(f"Error en análisis: {str(e)}")
|
135 |
+
st.error(t.get('analysis_error', "Error al analizar el texto"))
|
136 |
+
|
137 |
+
# Mostrar resultados en la columna derecha
|
138 |
+
with results_col:
|
139 |
+
if st.session_state.show_results and st.session_state.current_metrics is not None:
|
140 |
+
# Primero los radio buttons para tipo de texto
|
141 |
+
st.markdown("### Tipo de texto")
|
142 |
+
text_type = st.radio(
|
143 |
+
"",
|
144 |
+
options=list(TEXT_TYPES.keys()),
|
145 |
+
format_func=lambda x: TEXT_TYPES[x]['name'],
|
146 |
+
horizontal=True,
|
147 |
+
key="text_type_radio",
|
148 |
+
help="Selecciona el tipo de texto para ajustar los criterios de evaluación"
|
149 |
+
)
|
150 |
+
|
151 |
+
st.session_state.current_text_type = text_type
|
152 |
+
|
153 |
+
# Crear subtabs
|
154 |
+
subtab1, subtab2 = st.tabs(["Diagnóstico", "Recomendaciones"])
|
155 |
+
|
156 |
+
# Mostrar resultados en el primer subtab
|
157 |
+
with subtab1:
|
158 |
+
display_diagnosis(
|
159 |
+
metrics=st.session_state.current_metrics,
|
160 |
+
text_type=text_type
|
161 |
+
)
|
162 |
+
|
163 |
+
# Mostrar recomendaciones en el segundo subtab
|
164 |
+
with subtab2:
|
165 |
+
# Generar recomendaciones si no existen o si cambió el tipo de texto
|
166 |
+
if (st.session_state.current_recommendations is None or
|
167 |
+
st.session_state.current_recommendations.get('text_type') != text_type):
|
168 |
+
|
169 |
+
recommendations = generate_recommendations(
|
170 |
+
metrics=st.session_state.current_metrics,
|
171 |
+
text_type=text_type,
|
172 |
+
lang_code=lang_code
|
173 |
+
)
|
174 |
+
recommendations['text_type'] = text_type
|
175 |
+
st.session_state.current_recommendations = recommendations
|
176 |
+
|
177 |
+
display_recommendations_with_actions(
|
178 |
+
st.session_state.current_recommendations,
|
179 |
+
lang_code,
|
180 |
+
t
|
181 |
+
)
|
182 |
+
|
183 |
+
except Exception as e:
|
184 |
+
logger.error(f"Error en interfaz principal: {str(e)}")
|
185 |
+
st.error("Ocurrió un error al cargar la interfaz")
|
186 |
+
|
187 |
+
###################################3333
|
188 |
+
|
189 |
+
def display_diagnosis(metrics, text_type=None):
|
190 |
+
"""
|
191 |
+
Muestra los resultados del análisis: métricas verticalmente y gráfico radar.
|
192 |
+
"""
|
193 |
+
try:
|
194 |
+
# Usar valor por defecto si no se especifica tipo
|
195 |
+
text_type = text_type or 'student_essay'
|
196 |
+
|
197 |
+
# Obtener umbrales según el tipo de texto
|
198 |
+
thresholds = TEXT_TYPES[text_type]['thresholds']
|
199 |
+
|
200 |
+
# Crear dos columnas para las métricas y el gráfico
|
201 |
+
metrics_col, graph_col = st.columns([1, 1.5])
|
202 |
+
|
203 |
+
# Columna de métricas
|
204 |
+
with metrics_col:
|
205 |
+
metrics_config = [
|
206 |
+
{
|
207 |
+
'label': "Vocabulario",
|
208 |
+
'key': 'vocabulary',
|
209 |
+
'value': metrics['vocabulary']['normalized_score'],
|
210 |
+
'help': "Riqueza y variedad del vocabulario",
|
211 |
+
'thresholds': thresholds['vocabulary']
|
212 |
+
},
|
213 |
+
{
|
214 |
+
'label': "Estructura",
|
215 |
+
'key': 'structure',
|
216 |
+
'value': metrics['structure']['normalized_score'],
|
217 |
+
'help': "Organización y complejidad de oraciones",
|
218 |
+
'thresholds': thresholds['structure']
|
219 |
+
},
|
220 |
+
{
|
221 |
+
'label': "Cohesión",
|
222 |
+
'key': 'cohesion',
|
223 |
+
'value': metrics['cohesion']['normalized_score'],
|
224 |
+
'help': "Conexión y fluidez entre ideas",
|
225 |
+
'thresholds': thresholds['cohesion']
|
226 |
+
},
|
227 |
+
{
|
228 |
+
'label': "Claridad",
|
229 |
+
'key': 'clarity',
|
230 |
+
'value': metrics['clarity']['normalized_score'],
|
231 |
+
'help': "Facilidad de comprensión del texto",
|
232 |
+
'thresholds': thresholds['clarity']
|
233 |
+
}
|
234 |
+
]
|
235 |
+
|
236 |
+
# Mostrar métricas
|
237 |
+
for metric in metrics_config:
|
238 |
+
value = metric['value']
|
239 |
+
if value < metric['thresholds']['min']:
|
240 |
+
status = "⚠️ Por mejorar"
|
241 |
+
color = "inverse"
|
242 |
+
elif value < metric['thresholds']['target']:
|
243 |
+
status = "📈 Aceptable"
|
244 |
+
color = "off"
|
245 |
+
else:
|
246 |
+
status = "✅ Óptimo"
|
247 |
+
color = "normal"
|
248 |
+
|
249 |
+
st.metric(
|
250 |
+
metric['label'],
|
251 |
+
f"{value:.2f}",
|
252 |
+
f"{status} (Meta: {metric['thresholds']['target']:.2f})",
|
253 |
+
delta_color=color,
|
254 |
+
help=metric['help']
|
255 |
+
)
|
256 |
+
st.markdown("<div style='margin-bottom: 0.5rem;'></div>", unsafe_allow_html=True)
|
257 |
+
|
258 |
+
# Gráfico radar en la columna derecha
|
259 |
+
with graph_col:
|
260 |
+
display_radar_chart(metrics_config, thresholds)
|
261 |
+
|
262 |
+
except Exception as e:
|
263 |
+
logger.error(f"Error mostrando resultados: {str(e)}")
|
264 |
+
st.error("Error al mostrar los resultados")
|
265 |
+
|
266 |
+
|
267 |
+
######################################
|
268 |
+
def display_radar_chart(metrics_config, thresholds):
|
269 |
+
"""
|
270 |
+
Muestra el gráfico radar con los resultados.
|
271 |
+
"""
|
272 |
+
try:
|
273 |
+
# Preparar datos para el gráfico
|
274 |
+
categories = [m['label'] for m in metrics_config]
|
275 |
+
values_user = [m['value'] for m in metrics_config]
|
276 |
+
min_values = [m['thresholds']['min'] for m in metrics_config]
|
277 |
+
target_values = [m['thresholds']['target'] for m in metrics_config]
|
278 |
+
|
279 |
+
# Crear y configurar gráfico
|
280 |
+
fig = plt.figure(figsize=(8, 8))
|
281 |
+
ax = fig.add_subplot(111, projection='polar')
|
282 |
+
|
283 |
+
# Configurar radar
|
284 |
+
angles = [n / float(len(categories)) * 2 * np.pi for n in range(len(categories))]
|
285 |
+
angles += angles[:1]
|
286 |
+
values_user += values_user[:1]
|
287 |
+
min_values += min_values[:1]
|
288 |
+
target_values += target_values[:1]
|
289 |
+
|
290 |
+
# Configurar ejes
|
291 |
+
ax.set_xticks(angles[:-1])
|
292 |
+
ax.set_xticklabels(categories, fontsize=10)
|
293 |
+
circle_ticks = np.arange(0, 1.1, 0.2)
|
294 |
+
ax.set_yticks(circle_ticks)
|
295 |
+
ax.set_yticklabels([f'{tick:.1f}' for tick in circle_ticks], fontsize=8)
|
296 |
+
ax.set_ylim(0, 1)
|
297 |
+
|
298 |
+
# Dibujar áreas de umbrales
|
299 |
+
ax.plot(angles, min_values, '#e74c3c', linestyle='--', linewidth=1, label='Mínimo', alpha=0.5)
|
300 |
+
ax.plot(angles, target_values, '#2ecc71', linestyle='--', linewidth=1, label='Meta', alpha=0.5)
|
301 |
+
ax.fill_between(angles, target_values, [1]*len(angles), color='#2ecc71', alpha=0.1)
|
302 |
+
ax.fill_between(angles, [0]*len(angles), min_values, color='#e74c3c', alpha=0.1)
|
303 |
+
|
304 |
+
# Dibujar valores del usuario
|
305 |
+
ax.plot(angles, values_user, '#3498db', linewidth=2, label='Tu escritura')
|
306 |
+
ax.fill(angles, values_user, '#3498db', alpha=0.2)
|
307 |
+
|
308 |
+
# Ajustar leyenda
|
309 |
+
ax.legend(
|
310 |
+
loc='upper right',
|
311 |
+
bbox_to_anchor=(1.3, 1.1),
|
312 |
+
fontsize=10,
|
313 |
+
frameon=True,
|
314 |
+
facecolor='white',
|
315 |
+
edgecolor='none',
|
316 |
+
shadow=True
|
317 |
+
)
|
318 |
+
|
319 |
+
plt.tight_layout()
|
320 |
+
st.pyplot(fig)
|
321 |
+
plt.close()
|
322 |
+
|
323 |
+
except Exception as e:
|
324 |
+
logger.error(f"Error mostrando gráfico radar: {str(e)}")
|
325 |
+
st.error("Error al mostrar el gráfico")
|
326 |
+
|
327 |
+
#####################################################
|
328 |
+
def display_recommendations_with_actions(recommendations, lang_code, t):
|
329 |
+
"""
|
330 |
+
Muestra las recomendaciones con un diseño de tarjetas y opciones para acciones específicas.
|
331 |
+
"""
|
332 |
+
# Definir colores para cada categoría
|
333 |
+
colors = {
|
334 |
+
'vocabulary': '#2E86C1', # Azul
|
335 |
+
'structure': '#28B463', # Verde
|
336 |
+
'cohesion': '#F39C12', # Naranja
|
337 |
+
'clarity': '#9B59B6', # Púrpura
|
338 |
+
'priority': '#E74C3C' # Rojo para la categoría prioritaria
|
339 |
+
}
|
340 |
+
|
341 |
+
# Iconos para cada categoría
|
342 |
+
icons = {
|
343 |
+
'vocabulary': '📚',
|
344 |
+
'structure': '🏗️',
|
345 |
+
'cohesion': '🔄',
|
346 |
+
'clarity': '💡',
|
347 |
+
'priority': '⭐'
|
348 |
+
}
|
349 |
+
|
350 |
+
# Mapeo de dimensiones a funcionalidades de la aplicación
|
351 |
+
dimension_to_tool = {
|
352 |
+
'vocabulary': {'tool': 'Análisis Semántico', 'description': 'Examina el vocabulario y las relaciones entre conceptos en tu texto'},
|
353 |
+
'structure': {'tool': 'Análisis Morfosintáctico', 'description': 'Analiza la estructura gramatical y sintáctica de tus oraciones'},
|
354 |
+
'cohesion': {'tool': 'Análisis del Discurso', 'description': 'Evalúa la cohesión y coherencia entre diferentes partes de tu texto'},
|
355 |
+
'clarity': {'tool': 'Análisis Morfosintáctico', 'description': 'Mejora la claridad identificando la complejidad de tus oraciones'},
|
356 |
+
}
|
357 |
+
|
358 |
+
# Obtener traducciones para cada dimensión
|
359 |
+
dimension_names = {
|
360 |
+
'vocabulary': t.get('SITUATION_ANALYSIS', {}).get('vocabulary', "Vocabulario"),
|
361 |
+
'structure': t.get('SITUATION_ANALYSIS', {}).get('structure', "Estructura"),
|
362 |
+
'cohesion': t.get('SITUATION_ANALYSIS', {}).get('cohesion', "Cohesión"),
|
363 |
+
'clarity': t.get('SITUATION_ANALYSIS', {}).get('clarity', "Claridad"),
|
364 |
+
'priority': t.get('SITUATION_ANALYSIS', {}).get('priority', "Prioridad")
|
365 |
+
}
|
366 |
+
|
367 |
+
# Título de la sección prioritaria
|
368 |
+
priority_focus = t.get('SITUATION_ANALYSIS', {}).get('priority_focus', 'Área prioritaria para mejorar')
|
369 |
+
st.markdown(f"### {icons['priority']} {priority_focus}")
|
370 |
+
|
371 |
+
# Determinar área prioritaria (la que tiene menor puntuación)
|
372 |
+
priority_area = recommendations.get('priority', {}).get('area', 'vocabulary')
|
373 |
+
priority_title = dimension_names.get(priority_area, "Área prioritaria")
|
374 |
+
|
375 |
+
# Determinar el contenido para mostrar
|
376 |
+
priority_content = recommendations.get('priority', {}).get('tips', [])
|
377 |
+
if isinstance(priority_content, list):
|
378 |
+
priority_content = "<br>".join([f"• {tip}" for tip in priority_content])
|
379 |
+
|
380 |
+
# Mostrar la recomendación prioritaria con un estilo destacado
|
381 |
+
with st.container():
|
382 |
+
st.markdown(
|
383 |
+
f"""
|
384 |
+
<div style="border:2px solid {colors['priority']}; border-radius:5px; padding:15px; margin-bottom:20px;">
|
385 |
+
<h4 style="color:{colors['priority']};">{priority_title}</h4>
|
386 |
+
<p>{priority_content}</p>
|
387 |
+
<p><strong>Herramienta recomendada:</strong> {dimension_to_tool.get(priority_area, {}).get('tool', 'Análisis completo')}</p>
|
388 |
+
<p>{dimension_to_tool.get(priority_area, {}).get('description', '')}</p>
|
389 |
+
</div>
|
390 |
+
""",
|
391 |
+
unsafe_allow_html=True
|
392 |
+
)
|
393 |
+
|
394 |
+
# Botón para ir directamente a la herramienta recomendada
|
395 |
+
recommendation_tool = dimension_to_tool.get(priority_area, {}).get('tool')
|
396 |
+
if recommendation_tool:
|
397 |
+
if st.button(f"Ir a {recommendation_tool}", key=f"goto_{priority_area}", type="primary"):
|
398 |
+
# Lógica para cambiar a la herramienta recomendada
|
399 |
+
if recommendation_tool == "Análisis Morfosintáctico":
|
400 |
+
st.session_state.page = 'morpho'
|
401 |
+
st.session_state.selected_tab = 0
|
402 |
+
elif recommendation_tool == "Análisis Semántico":
|
403 |
+
st.session_state.page = 'semantic'
|
404 |
+
st.session_state.selected_tab = 1
|
405 |
+
elif recommendation_tool == "Análisis del Discurso":
|
406 |
+
st.session_state.page = 'discourse'
|
407 |
+
st.session_state.selected_tab = 2
|
408 |
+
st.rerun()
|
409 |
+
|
410 |
+
# Crear dos columnas para las tarjetas de recomendaciones restantes
|
411 |
+
col1, col2 = st.columns(2)
|
412 |
+
|
413 |
+
# Distribuir las recomendaciones en las columnas
|
414 |
+
categories = ['vocabulary', 'structure', 'cohesion', 'clarity']
|
415 |
+
for i, category in enumerate(categories):
|
416 |
+
# Saltar si esta categoría ya es la prioritaria
|
417 |
+
if category == priority_area:
|
418 |
+
continue
|
419 |
+
|
420 |
+
# Obtener las recomendaciones para esta categoría
|
421 |
+
category_content = recommendations.get(category, [])
|
422 |
+
if isinstance(category_content, list):
|
423 |
+
category_content = "<br>".join([f"• {tip}" for tip in category_content])
|
424 |
+
|
425 |
+
category_title = dimension_names.get(category, category)
|
426 |
+
|
427 |
+
# Alternar entre columnas
|
428 |
+
with col1 if i % 2 == 0 else col2:
|
429 |
+
# Crear tarjeta para cada recomendación
|
430 |
+
st.markdown(
|
431 |
+
f"""
|
432 |
+
<div style="border:1px solid {colors[category]}; border-radius:5px; padding:10px; margin-bottom:15px;">
|
433 |
+
<h4 style="color:{colors[category]};">{icons[category]} {category_title}</h4>
|
434 |
+
<p>{category_content}</p>
|
435 |
+
<p><strong>Herramienta:</strong> {dimension_to_tool.get(category, {}).get('tool', '')}</p>
|
436 |
+
</div>
|
437 |
+
""",
|
438 |
+
unsafe_allow_html=True
|
439 |
+
)
|
440 |
+
|
441 |
+
# Botón para ir a la herramienta específica
|
442 |
+
tool = dimension_to_tool.get(category, {}).get('tool')
|
443 |
+
if tool:
|
444 |
+
if st.button(f"Ir a {tool}", key=f"goto_{category}", type="secondary", use_container_width=True):
|
445 |
+
if tool == "Análisis Morfosintáctico":
|
446 |
+
st.session_state.page = 'morpho'
|
447 |
+
st.session_state.selected_tab = 0
|
448 |
+
elif tool == "Análisis Semántico":
|
449 |
+
st.session_state.page = 'semantic'
|
450 |
+
st.session_state.selected_tab = 1
|
451 |
+
elif tool == "Análisis del Discurso":
|
452 |
+
st.session_state.page = 'discourse'
|
453 |
+
st.session_state.selected_tab = 2
|
454 |
+
st.rerun()
|
455 |
+
|
456 |
+
# Agregar una sección para recursos adicionales
|
457 |
+
st.markdown("---")
|
458 |
+
st.markdown("### 📖 Recursos adicionales")
|
459 |
+
|
460 |
+
with st.expander("Ver recursos de aprendizaje"):
|
461 |
+
st.markdown("""
|
462 |
+
### Recursos por área
|
463 |
+
|
464 |
+
#### Vocabulario
|
465 |
+
- **Diccionario de la Real Academia Española**: [www.rae.es](https://www.rae.es)
|
466 |
+
- **Fundación del Español Urgente**: [www.fundeu.es](https://www.fundeu.es)
|
467 |
+
|
468 |
+
#### Estructura
|
469 |
+
- **Manual de gramática**: [Gramática y ortografía para dummies](https://www.planetadelibros.com/libro-gramatica-y-ortografia-para-dummies/248265)
|
470 |
+
- **Ortografía de la RAE**: [Ortografía básica de la lengua española](https://www.rae.es/obras-academicas/ortografia/ortografia-basica-de-la-lengua-espanola)
|
471 |
+
|
472 |
+
#### Cohesión
|
473 |
+
- **Centro Virtual Cervantes**: [Diccionario de términos clave de ELE](https://cvc.cervantes.es/ensenanza/biblioteca_ele/diccio_ele/indice.htm)
|
474 |
+
- **Curso de cohesión textual**: [Centro de Escritura Javeriano](https://www2.javerianacali.edu.co/sites/ujc/files/normas_apa_revisada_y_actualizada_mayo_2019.pdf)
|
475 |
+
|
476 |
+
#### Claridad
|
477 |
+
- **Curso de escritura científica**: [Cómo escribir y publicar trabajos científicos](https://www.conacyt.gov.py/sites/default/files/upload_editores/u38/CONI-NOR-113.pdf)
|
478 |
+
- **Manual de estilo**: [Manual de estilo de la lengua española](https://www.planetadelibros.com/libro-manual-de-estilo-de-la-lengua-espanola/17811)
|
479 |
+
""")
|
480 |
+
|
481 |
+
# Boletines o actualizaciones del sistema
|
482 |
+
with st.expander("📬 Actualizaciones de AIdeaText"):
|
483 |
+
st.markdown("""
|
484 |
+
## Próximas actualizaciones
|
485 |
+
|
486 |
+
- **Nueva funcionalidad**: Análisis comparativo entre textos propios
|
487 |
+
- **Mejora**: Recomendaciones más detalladas y personalizadas
|
488 |
+
- **Próximamente**: Tutorial interactivo para mejorar la escritura
|
489 |
+
|
490 |
+
> Estamos trabajando continuamente para mejorar tus herramientas de escritura.
|
491 |
+
""")
|