MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / truncate

Function truncate

experiments/benchmark/export_human_audit_subset.py:51–56  ·  view source on GitHub ↗
(value: Any, limit: int)

Source from the content-addressed store, hash-verified

49
50
51def truncate(value: Any, limit: int) -> str:
52 text = json.dumps(value, ensure_ascii=False) if isinstance(value, (list, dict)) else str(value or "")
53 text = " ".join(text.split())
54 if len(text) <= limit:
55 return text
56 return text[: max(0, limit - 3)] + "..."
57
58
59def balanced_sample(rows: List[Dict[str, Any]], sample_size: int, seed: int) -> List[Dict[str, Any]]:

Callers 1

normalize_for_auditFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected