MCPcopy Create free account
hub / github.com/Qinbf/groundmap / find_section_by_title

Function find_section_by_title

scripts/section_parser.py:352–359  ·  view source on GitHub ↗

模糊:标题完全相等(去空白、忽略大小写)

(sections: list[Section], title: str)

Source from the content-addressed store, hash-verified

350
351
352def find_section_by_title(sections: list[Section], title: str) -> Optional[Section]:
353 """模糊:标题完全相等(去空白、忽略大小写)"""
354 norm = re.sub(r"\s+", " ", title.strip().lower())
355 for s in flatten_sections(sections):
356 s_norm = re.sub(r"\s+", " ", (s.title or "").strip().lower())
357 if s_norm == norm:
358 return s
359 return None

Calls 1

flatten_sectionsFunction · 0.85