MCPcopy Create free account
hub / github.com/astercloud/aster / extractSectionTitle

Method extractSectionTitle

pkg/compression/service.go:445–457  ·  view source on GitHub ↗

extractSectionTitle 提取段落标题

(section string)

Source from the content-addressed store, hash-verified

443
444// extractSectionTitle 提取段落标题
445func (s *DefaultCompressionService) extractSectionTitle(section string) string {
446 lines := strings.Split(section, "\n")
447 if len(lines) > 0 {
448 firstLine := strings.TrimSpace(lines[0])
449 if strings.HasPrefix(firstLine, "##") {
450 return strings.TrimSpace(strings.TrimLeft(firstLine, "#"))
451 }
452 if strings.HasPrefix(firstLine, "#") {
453 return strings.TrimSpace(strings.TrimLeft(firstLine, "#"))
454 }
455 }
456 return ""
457}
458
459// shouldPreserve 判断是否应该保留该段落
460func (s *DefaultCompressionService) shouldPreserve(title string, preserveSections []string) bool {

Callers 2

TestExtractSectionTitleFunction · 0.95
scoreSectionsMethod · 0.95

Calls

no outgoing calls

Tested by 1

TestExtractSectionTitleFunction · 0.76