(sections: list[dict[str, Any]], *, max_items: int = 200)
| 234 | |
| 235 | |
| 236 | def math_index(sections: list[dict[str, Any]], *, max_items: int = 200) -> list[dict[str, Any]]: |
| 237 | items: list[dict[str, Any]] = [] |
| 238 | for section in sections: |
| 239 | for line in str(section.get("text", "")).splitlines(): |
| 240 | cleaned = normalize_whitespace(line) |
| 241 | if not cleaned or len(cleaned) > 240 or not MATH_SIGNAL_RE.search(cleaned): |
| 242 | continue |
| 243 | items.append( |
| 244 | { |
| 245 | "text": cleaned, |
| 246 | "section_id": section.get("section_id", ""), |
| 247 | "page_start": section.get("page_start"), |
| 248 | "page_end": section.get("page_end"), |
| 249 | } |
| 250 | ) |
| 251 | if len(items) >= max_items: |
| 252 | return items |
| 253 | return items |
| 254 | |
| 255 | |
| 256 | def write_jsonl(records: list[dict[str, Any]], output_path: str) -> None: |
no test coverage detected