AIdeaText commited on
Commit
13f4358
verified
1 Parent(s): b5d37fc

Update modules/text_analysis/morpho_analysis.py

Browse files
modules/text_analysis/morpho_analysis.py CHANGED
@@ -117,6 +117,14 @@ def highlight_repeated_words(doc, word_colors):
117
 
118
  #################################################################################################
119
  def generate_arc_diagram(doc):
 
 
 
 
 
 
 
 
120
  arc_diagrams = []
121
  for sent in doc.sents:
122
  words = [token.text for token in sent]
@@ -233,17 +241,24 @@ def get_sentence_structure_analysis(doc):
233
  return sentence_analysis
234
 
235
  #################################################################################################
236
- def perform_advanced_morphosyntactic_analysis(text, nlp):
237
  """
238
  Realiza un an谩lisis morfosint谩ctico avanzado del texto.
239
  """
240
- doc = nlp(text)
241
- return {
242
- 'pos_analysis': get_detailed_pos_analysis(doc),
243
- 'morphological_analysis': get_morphological_analysis(doc),
244
- 'sentence_structure': get_sentence_structure_analysis(doc),
245
- 'arc_diagram': generate_arc_diagram(doc, nlp.lang)
246
- }
 
 
 
 
 
 
 
247
 
248
  # Al final del archivo morph_analysis.py
249
  __all__ = ['get_repeated_words_colors', 'highlight_repeated_words', 'generate_arc_diagram', 'perform_advanced_morphosyntactic_analysis', 'POS_COLORS', 'POS_TRANSLATIONS']
 
117
 
118
  #################################################################################################
119
  def generate_arc_diagram(doc):
120
+ """
121
+ Genera diagramas de arco para cada oraci贸n en el documento.
122
+
123
+ Args:
124
+ doc: Documento procesado por spaCy
125
+ Returns:
126
+ list: Lista de diagramas en formato HTML
127
+ """
128
  arc_diagrams = []
129
  for sent in doc.sents:
130
  words = [token.text for token in sent]
 
241
  return sentence_analysis
242
 
243
  #################################################################################################
244
+ Copydef perform_advanced_morphosyntactic_analysis(text, nlp):
245
  """
246
  Realiza un an谩lisis morfosint谩ctico avanzado del texto.
247
  """
248
+ try:
249
+ doc = nlp(text)
250
+ return {
251
+ 'doc': doc,
252
+ 'pos_analysis': get_detailed_pos_analysis(doc),
253
+ 'morphological_analysis': get_morphological_analysis(doc),
254
+ 'sentence_structure': get_sentence_structure_analysis(doc),
255
+ 'arc_diagrams': generate_arc_diagram(doc), # Quitamos nlp.lang
256
+ 'repeated_words': get_repeated_words_colors(doc),
257
+ 'highlighted_text': highlight_repeated_words(doc, get_repeated_words_colors(doc))
258
+ }
259
+ except Exception as e:
260
+ logger.error(f"Error en an谩lisis morfosint谩ctico: {str(e)}")
261
+ return None
262
 
263
  # Al final del archivo morph_analysis.py
264
  __all__ = ['get_repeated_words_colors', 'highlight_repeated_words', 'generate_arc_diagram', 'perform_advanced_morphosyntactic_analysis', 'POS_COLORS', 'POS_TRANSLATIONS']