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

Method shouldPreserve

pkg/compression/service.go:460–481  ·  view source on GitHub ↗

shouldPreserve 判断是否应该保留该段落

(title string, preserveSections []string)

Source from the content-addressed store, hash-verified

458
459// shouldPreserve 判断是否应该保留该段落
460func (s *DefaultCompressionService) shouldPreserve(title string, preserveSections []string) bool {
461 if title == "" {
462 return false
463 }
464
465 lowerTitle := strings.ToLower(title)
466 for _, preserve := range preserveSections {
467 if strings.Contains(lowerTitle, strings.ToLower(preserve)) {
468 return true
469 }
470 }
471
472 // 默认保留的关键段落
473 defaultPreserve := []string{"tools manual", "security", "permission", "工具手册", "安全", "权限"}
474 for _, dp := range defaultPreserve {
475 if strings.Contains(lowerTitle, dp) {
476 return true
477 }
478 }
479
480 return false
481}
482
483// removeDuplicateEmptyLines 移除重复空行
484func (s *DefaultCompressionService) removeDuplicateEmptyLines(prompt string) string {

Callers 2

TestShouldPreserveFunction · 0.95
scoreSectionsMethod · 0.95

Calls

no outgoing calls

Tested by 1

TestShouldPreserveFunction · 0.76