Update modules/studentact/current_situation_analysis.py
Browse files
modules/studentact/current_situation_analysis.py
CHANGED
@@ -95,9 +95,29 @@ def get_dependency_depths(token, depth=0):
|
|
95 |
depths.extend(get_dependency_depths(child, depth + 1))
|
96 |
return depths
|
97 |
|
98 |
-
def normalize_score(value, optimal_value=1.0, range_factor=2.0):
|
99 |
-
"""
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
|
103 |
# Funciones de generaci贸n de gr谩ficos
|
|
|
95 |
depths.extend(get_dependency_depths(child, depth + 1))
|
96 |
return depths
|
97 |
|
98 |
+
def normalize_score(value, optimal_value=1.0, range_factor=2.0, optimal_length=None):
|
99 |
+
"""
|
100 |
+
Normaliza un valor a una escala de 0-1.
|
101 |
+
Args:
|
102 |
+
value: Valor a normalizar
|
103 |
+
optimal_value: Valor 贸ptimo de referencia
|
104 |
+
range_factor: Factor para ajustar el rango
|
105 |
+
optimal_length: Longitud 贸ptima (opcional)
|
106 |
+
"""
|
107 |
+
try:
|
108 |
+
if optimal_length is not None:
|
109 |
+
# Usar optimal_length si est谩 definido
|
110 |
+
diff = abs(value - optimal_length)
|
111 |
+
max_diff = optimal_length * range_factor
|
112 |
+
return 1.0 - min(diff / max_diff, 1.0)
|
113 |
+
else:
|
114 |
+
# Usar optimal_value por defecto
|
115 |
+
diff = abs(value - optimal_value)
|
116 |
+
max_diff = optimal_value * range_factor
|
117 |
+
return 1.0 - min(diff / max_diff, 1.0)
|
118 |
+
except Exception as e:
|
119 |
+
logger.error(f"Error en normalize_score: {str(e)}")
|
120 |
+
return 0.0
|
121 |
|
122 |
|
123 |
# Funciones de generaci贸n de gr谩ficos
|