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

Function caption_preference_score

scripts/common.py:2114–2126  ·  view source on GitHub ↗
(label: str, caption: str)

Source from the content-addressed store, hash-verified

2112
2113
2114def 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
2129def extract_caption_lines(pdf_text: str, kind: str) -> list[dict[str, str]]:

Callers 3

build_figure_itemsFunction · 0.90
caption_itemsFunction · 0.90
extract_caption_linesFunction · 0.85

Calls 1

normalize_whitespaceFunction · 0.85

Tested by

no test coverage detected