(label: str, caption: str)
| 2112 | |
| 2113 | |
| 2114 | def caption_preference_score(label: str, caption: str) -> int: |
| 2115 | cleaned_caption = normalize_whitespace(caption) |
| 2116 | lowered_label = normalize_whitespace(label).lower() |
| 2117 | first_word_match = re.match(r"^([A-Za-z][A-Za-z-]*)\b", cleaned_caption) |
| 2118 | first_word = first_word_match.group(1).lower() if first_word_match else "" |
| 2119 | score = len(cleaned_caption) |
| 2120 | if lowered_label.startswith(("figure", "table")): |
| 2121 | score += 25 |
| 2122 | if first_word in CAPTION_REFERENCE_VERBS: |
| 2123 | score -= 80 |
| 2124 | if len(cleaned_caption) < 12: |
| 2125 | score -= 20 |
| 2126 | return score |
| 2127 | |
| 2128 | |
| 2129 | def extract_caption_lines(pdf_text: str, kind: str) -> list[dict[str, str]]: |
no test coverage detected