Spaces:
Sleeping
Sleeping
Update modules/studentact/current_situation_analysis.py
Browse files
modules/studentact/current_situation_analysis.py
CHANGED
|
@@ -70,81 +70,8 @@ def analyze_text_dimensions(doc):
|
|
| 70 |
}
|
| 71 |
|
| 72 |
####################################################################
|
| 73 |
-
def analyze_clarity(doc):
|
| 74 |
-
"""
|
| 75 |
-
Analiza la claridad del texto considerando múltiples factores.
|
| 76 |
-
"""
|
| 77 |
-
try:
|
| 78 |
-
# 1. Análisis de oraciones
|
| 79 |
-
sentences = list(doc.sents)
|
| 80 |
-
if not sentences:
|
| 81 |
-
return 0.0, {}
|
| 82 |
-
|
| 83 |
-
# Longitud de oraciones
|
| 84 |
-
sentence_lengths = [len(sent) for sent in sentences]
|
| 85 |
-
avg_length = sum(sentence_lengths) / len(sentences)
|
| 86 |
-
length_variation = np.std(sentence_lengths) if len(sentences) > 1 else 0
|
| 87 |
-
|
| 88 |
-
# Normalizar longitud
|
| 89 |
-
length_score = normalize_score(avg_length, optimal_length=20)
|
| 90 |
-
|
| 91 |
-
# 2. Análisis de conectores
|
| 92 |
-
connector_count = 0
|
| 93 |
-
connector_types = {
|
| 94 |
-
'CCONJ': 0.8,
|
| 95 |
-
'SCONJ': 1.0,
|
| 96 |
-
'ADV': 0.6
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
for token in doc:
|
| 100 |
-
if token.pos_ in connector_types and token.dep_ in ['cc', 'mark', 'advmod']:
|
| 101 |
-
connector_count += connector_types[token.pos_]
|
| 102 |
-
|
| 103 |
-
connector_score = min(1.0, connector_count / (len(sentences) * 0.8))
|
| 104 |
-
|
| 105 |
-
# 3. Complejidad estructural
|
| 106 |
-
clause_count = 0
|
| 107 |
-
for sent in sentences:
|
| 108 |
-
verbs = [token for token in sent if token.pos_ == 'VERB']
|
| 109 |
-
clause_count += len(verbs)
|
| 110 |
-
|
| 111 |
-
complexity_raw = clause_count / len(sentences) if len(sentences) > 0 else 0
|
| 112 |
-
complexity_score = normalize_score(complexity_raw, optimal_value=2.0)
|
| 113 |
-
|
| 114 |
-
# 4. Densidad léxica
|
| 115 |
-
content_words = len([token for token in doc if token.pos_ in ['NOUN', 'VERB', 'ADJ', 'ADV']])
|
| 116 |
-
total_words = len([token for token in doc])
|
| 117 |
-
density_score = normalize_score(
|
| 118 |
-
content_words / total_words if total_words > 0 else 0,
|
| 119 |
-
optimal_value=0.6
|
| 120 |
-
)
|
| 121 |
-
|
| 122 |
-
# Cálculo del score final
|
| 123 |
-
clarity_score = (
|
| 124 |
-
0.3 * length_score +
|
| 125 |
-
0.3 * connector_score +
|
| 126 |
-
0.2 * complexity_score +
|
| 127 |
-
0.2 * density_score
|
| 128 |
-
)
|
| 129 |
-
|
| 130 |
-
details = {
|
| 131 |
-
'length_score': length_score,
|
| 132 |
-
'connector_score': connector_score,
|
| 133 |
-
'complexity_score': complexity_score,
|
| 134 |
-
'density_score': density_score,
|
| 135 |
-
'avg_sentence_length': avg_length,
|
| 136 |
-
'length_variation': length_variation,
|
| 137 |
-
'connectors_per_sentence': connector_count / len(sentences) if len(sentences) > 0 else 0
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
-
return clarity_score, details
|
| 141 |
-
|
| 142 |
-
except Exception as e:
|
| 143 |
-
logger.error(f"Error en analyze_clarity: {str(e)}")
|
| 144 |
-
return 0.0, {}
|
| 145 |
|
| 146 |
-
|
| 147 |
-
def analyze_clarity(doc):
|
| 148 |
"""
|
| 149 |
Analiza la claridad del texto considerando múltiples factores.
|
| 150 |
"""
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
####################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
def analyze_reference_clarity'(doc):
|
|
|
|
| 75 |
"""
|
| 76 |
Analiza la claridad del texto considerando múltiples factores.
|
| 77 |
"""
|