MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / fix_messy_bullets

Function fix_messy_bullets

scripts/postprocess_fulltext.py:556–573  ·  view source on GitHub ↗

Cleans up docling's list bullets that include original PDF bullets like '•', '-', or 'o'. Converts '-  Text', '- - Text', etc. into '- Text'.

(content: str)

Source from the content-addressed store, hash-verified

554 return '\n'.join(out_lines), modified
555
556def fix_messy_bullets(content: str) -> tuple[str, int]:
557 """
558 Cleans up docling's list bullets that include original PDF bullets like '', '-', or 'o'.
559 Converts '-  Text', '- - Text', etc. into '- Text'.
560 """
561 lines = content.split('\n')
562 out = []
563 modified = 0
564 import re
565 bullet_pattern = re.compile(r'^(\s*-\s*)(?:-\s*|[•➢o]\s+)+(.*)$')
566 for line in lines:
567 m = bullet_pattern.match(line)
568 if m:
569 out.append(m.group(1) + m.group(2).strip())
570 modified += 1
571 else:
572 out.append(line)
573 return '\n'.join(out), modified
574
575def join_split_paragraphs(content: str) -> tuple[str, int]:
576 """

Callers 1

process_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected