MCPcopy Create free account
hub / github.com/Open-Quant/openquant / clean_pages

Function clean_pages

scripts/afml_semantic_index.py:127–144  ·  view source on GitHub ↗
(pages: list[dict[str, Any]], repeated_margin_lines: set[str])

Source from the content-addressed store, hash-verified

125
126
127def clean_pages(pages: list[dict[str, Any]], repeated_margin_lines: set[str]) -> list[dict[str, Any]]:
128 cleaned: list[dict[str, Any]] = []
129 for p in pages:
130 kept_lines: list[str] = []
131 for line in p["raw_text"].splitlines():
132 s = normalize_line(line)
133 if not s:
134 kept_lines.append("")
135 continue
136 if s in repeated_margin_lines:
137 continue
138 if RE_PAGE_ONLY.match(s):
139 continue
140 kept_lines.append(s)
141
142 text = normalize_text("\n".join(kept_lines))
143 cleaned.append({"page": p["page"], "text": text, "lines": kept_lines})
144 return cleaned
145
146
147def classify_heading(line: str) -> dict[str, str] | None:

Callers 1

build_indexFunction · 0.85

Calls 3

normalize_lineFunction · 0.85
normalize_textFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected