feat(0035e): manifest auto_group_threshold override + propagacion a Python
Manifest YAML puede declarar 'auto_group_threshold: <int>' a nivel top-level. enrichers.cpp lo parsea y lo guarda en EnricherSpec. jobs.cpp lo inyecta como campo opcional 'auto_group_threshold' en el JSON stdin del subprocess. Los enrichers Python que crean Groups (web_search, split_words, split_sentences, extract_iocs_text) leen el campo y, si viene > 0, lo usan en lugar de su DEFAULT_GROUP_THRESHOLD. Helper _coerce_threshold tolera int / str / None / 0 cayendo al default.
This commit is contained in:
@@ -39,6 +39,17 @@ from datetime import datetime, timezone
|
||||
DEFAULT_GROUP_THRESHOLD = 50
|
||||
GROUP_PREVIEW_K = 10
|
||||
|
||||
|
||||
def _coerce_threshold(raw, default: int) -> int:
|
||||
"""Acepta int / str numerico / None, devuelve >0 o el default (issue 0035e)."""
|
||||
if raw is None or raw == "":
|
||||
return default
|
||||
try:
|
||||
v = int(raw)
|
||||
except (TypeError, ValueError):
|
||||
return default
|
||||
return v if v > 0 else default
|
||||
|
||||
# Tokenizer: secuencias de letras (incluye acentos espanyoles + apostrofo
|
||||
# interno tipo "don't"). Mas robusto que split por espacios para texto
|
||||
# real con puntuacion adyacente. Numeros se ignoran — pensado para
|
||||
@@ -264,7 +275,9 @@ def main() -> int:
|
||||
try:
|
||||
has_group_col = has_group_id_column(conn)
|
||||
n_total = len(words)
|
||||
threshold = DEFAULT_GROUP_THRESHOLD
|
||||
# Issue 0035e: respeta override del manifest si viene en ctx.
|
||||
threshold = _coerce_threshold(ctx.get("auto_group_threshold"),
|
||||
DEFAULT_GROUP_THRESHOLD)
|
||||
|
||||
if n_total >= threshold and has_group_col:
|
||||
group_id = insert_group_entity(
|
||||
|
||||
Reference in New Issue
Block a user