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

Function fuzzyMatch

pkg/session/search.go:214–228  ·  view source on GitHub ↗

fuzzyMatch 模糊匹配

(content, query string)

Source from the content-addressed store, hash-verified

212
213// fuzzyMatch 模糊匹配
214func fuzzyMatch(content, query string) float64 {
215 queryWords := strings.Fields(query)
216 if len(queryWords) == 0 {
217 return 0.0
218 }
219
220 matchedWords := 0
221 for _, word := range queryWords {
222 if strings.Contains(content, word) {
223 matchedWords++
224 }
225 }
226
227 return float64(matchedWords) / float64(len(queryWords))
228}
229
230// generateSnippet 生成摘要片段
231func generateSnippet(content, query string, maxLen int) string {

Callers 1

SearchHistoryMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected