MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / caption_manifest

Function caption_manifest

scripts/extract_source_text.py:215–233  ·  view source on GitHub ↗
(
    page_texts: list[dict[str, Any]],
    sections: list[dict[str, Any]],
)

Source from the content-addressed store, hash-verified

213
214
215def caption_manifest(
216 page_texts: list[dict[str, Any]],
217 sections: list[dict[str, Any]],
218) -> dict[str, list[dict[str, Any]]]:
219 captions = {"figures": [], "tables": []}
220 for page in page_texts:
221 page_number = int(page["page"])
222 section = primary_section_for_page(sections, page_number)
223 for key, kind in (("figures", "figure"), ("tables", "table")):
224 for item in extract_caption_lines(str(page.get("text", "")), kind):
225 captions[key].append(
226 {
227 **item,
228 "page": page_number,
229 "pages": [page_number],
230 "section_id": section,
231 }
232 )
233 return captions
234
235
236def math_index(sections: list[dict[str, Any]], *, max_items: int = 200) -> list[dict[str, Any]]:

Callers 1

build_manifestFunction · 0.85

Calls 2

extract_caption_linesFunction · 0.90
primary_section_for_pageFunction · 0.85

Tested by

no test coverage detected