Whether a candidate abstract is meaningfully better than the current one.
(
current_abstract: Any,
candidate_abstract: Any,
*,
min_extra_chars: int = 40,
)
| 705 | |
| 706 | def _prefer_candidate_abstract( |
| 707 | current_abstract: Any, |
| 708 | candidate_abstract: Any, |
| 709 | *, |
| 710 | min_extra_chars: int = 40, |
| 711 | ) -> bool: |
| 712 | """Whether a candidate abstract is meaningfully better than the current one.""" |
| 713 | current_raw = current_abstract |
| 714 | current_clean = _clean_abstract_text(current_raw) |
| 715 | candidate_clean = _clean_abstract_text(candidate_abstract) |
| 716 | |
| 717 | if not candidate_clean: |
| 718 | return False |
| 719 | if not current_clean: |
| 720 | return True |
| 721 | if _looks_like_feed_metadata_abstract(current_raw): |
| 722 | return True |
| 723 | return len(candidate_clean) > len(current_clean) + min_extra_chars |
| 724 | |
| 725 | |
| 726 | def _truncate_text(text: Any, max_chars: int) -> str: |
| 727 | normalized = _clean_text(text) |
no test coverage detected