AIdeaText commited on
Commit
46c149e
·
verified ·
1 Parent(s): e25570d

Update modules/text_analysis/discourse_analysis.py

Browse files
modules/text_analysis/discourse_analysis.py CHANGED
@@ -50,18 +50,42 @@ def perform_discourse_analysis(text1, text2, nlp, lang):
50
  """
51
  Realiza el análisis completo del discurso
52
  """
53
- graph1, graph2, key_concepts1, key_concepts2 = compare_semantic_analysis(text1, text2, nlp, lang)
54
-
55
- # Crear tablas de conceptos clave
56
- table1 = create_concept_table(key_concepts1)
57
- table2 = create_concept_table(key_concepts2)
58
 
59
- return {
60
- 'graph1': graph1,
61
- 'graph2': graph2,
62
- 'key_concepts1': key_concepts1,
63
- 'key_concepts2': key_concepts2,
64
- 'table1': table1,
65
- 'table2': table2,
66
- 'success': True
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  """
51
  Realiza el análisis completo del discurso
52
  """
53
+ try:
54
+ # Procesar documentos
55
+ doc1 = nlp(text1)
56
+ doc2 = nlp(text2)
 
57
 
58
+ # Identificar conceptos clave
59
+ key_concepts1 = identify_key_concepts(doc1)
60
+ key_concepts2 = identify_key_concepts(doc2)
61
+
62
+ # Crear grafos de conceptos
63
+ G1 = create_concept_graph(doc1, key_concepts1)
64
+ G2 = create_concept_graph(doc2, key_concepts2)
65
+
66
+ # Visualizar grafos
67
+ fig1 = visualize_concept_graph(G1, lang)
68
+ fig2 = visualize_concept_graph(G2, lang)
69
+ fig1.suptitle("")
70
+ fig2.suptitle("")
71
+
72
+ # Crear tablas
73
+ table1 = create_concept_table(key_concepts1)
74
+ table2 = create_concept_table(key_concepts2)
75
+
76
+ return {
77
+ 'graph1': fig1,
78
+ 'graph2': fig2,
79
+ 'key_concepts1': key_concepts1,
80
+ 'key_concepts2': key_concepts2,
81
+ 'table1': table1,
82
+ 'table2': table2,
83
+ 'success': True
84
+ }
85
+
86
+ except Exception as e:
87
+ logger.error(f"Error en análisis del discurso: {str(e)}")
88
+ return {
89
+ 'success': False,
90
+ 'error': str(e)
91
+ }