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