(text: str, *, limit: int, cues: Tuple[str, ...] = ())
| 3028 | |
| 3029 | def _pick_sentences(text: str, *, limit: int, cues: Tuple[str, ...] = ()) -> List[str]: |
| 3030 | sentences = _split_sentences(text) |
| 3031 | if not sentences: |
| 3032 | return [] |
| 3033 | |
| 3034 | ranked: List[str] = [] |
| 3035 | if cues: |
| 3036 | lowered_sentences = [(sentence, sentence.lower()) for sentence in sentences] |
| 3037 | for sentence, lowered in lowered_sentences: |
| 3038 | if any(cue in lowered for cue in cues): |
| 3039 | ranked.append(sentence) |
| 3040 | |
| 3041 | if len(ranked) < limit: |
| 3042 | ranked.extend(sentences) |
| 3043 | |
| 3044 | unique_ranked = _unique_preserve_order(ranked) |
| 3045 | return [_truncate_text(sentence, 180) for sentence in unique_ranked[:limit]] |
| 3046 | |
| 3047 | |
| 3048 | def _format_pdf_section_label(section: str) -> str: |
| 3049 | normalized = _clean_text(section).replace("_", " ").replace("-", " ") |
no test coverage detected