(text: str)
| 157 | |
| 158 | |
| 159 | def measure(text: str) -> Metrics: |
| 160 | clean = strip_markdown(text) |
| 161 | paragraphs = [ |
| 162 | paragraph |
| 163 | for paragraph in re.split(r"\n\s*\n+", clean) |
| 164 | if meaningful_chars(paragraph) >= MIN_PARAGRAPH_CHARS |
| 165 | ] |
| 166 | sentences = [ |
| 167 | sentence |
| 168 | for sentence in re.split(r"[。!?!?;;\n]+", clean) |
| 169 | if meaningful_chars(sentence) >= 8 |
| 170 | ] |
| 171 | return Metrics( |
| 172 | chars=meaningful_chars(clean), |
| 173 | paragraphs=len(paragraphs), |
| 174 | sentences=len(sentences), |
| 175 | ) |
| 176 | |
| 177 | |
| 178 | def line_number(text: str, offset: int) -> int: |
no test coverage detected