MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / extract_sections

Function extract_sections

skills/pdf-parser/scripts/parse_pdf.py:517–538  ·  view source on GitHub ↗

提取章节内容

(text: str)

Source from the content-addressed store, hash-verified

515
516
517def extract_sections(text: str) -> Dict[str, str]:
518 """提取章节内容"""
519 sections = {}
520
521 for section_name, pattern in SECTION_PATTERNS.items():
522 match = re.search(pattern, text, re.IGNORECASE)
523 if match:
524 start = match.end()
525 next_section = None
526 for other_name, other_pattern in SECTION_PATTERNS.items():
527 if other_name != section_name:
528 other_match = re.search(other_pattern, text[start:], re.IGNORECASE)
529 if other_match:
530 if next_section is None or other_match.start() < next_section:
531 next_section = other_match.start()
532
533 if next_section:
534 sections[section_name] = text[start:start + next_section].strip()
535 else:
536 sections[section_name] = text[start:].strip()
537
538 return sections
539
540
541def score_direction_confidence(match_count: int, keyword_count: int) -> float:

Callers 1

parse_pdfFunction · 0.85

Calls 1

startMethod · 0.80

Tested by

no test coverage detected