MCPcopy Create free account
hub / github.com/bytebase/bytebase / extractKeywords

Function extractKeywords

backend/api/mcp/openapi_index.go:216–245  ·  view source on GitHub ↗
(texts ...string)

Source from the content-addressed store, hash-verified

214}
215
216func extractKeywords(texts ...string) []string {
217 keywordSet := make(map[string]bool)
218
219 for _, text := range texts {
220 // Split camelCase and PascalCase
221 words := splitCamelCase(text)
222 for _, word := range words {
223 word = strings.ToLower(word)
224 if len(word) >= 2 && !isStopWord(word) {
225 keywordSet[word] = true
226 }
227 }
228
229 // Also split by spaces and punctuation
230 for _, word := range strings.FieldsFunc(text, func(r rune) bool {
231 return !unicode.IsLetter(r) && !unicode.IsDigit(r)
232 }) {
233 word = strings.ToLower(word)
234 if len(word) >= 2 && !isStopWord(word) {
235 keywordSet[word] = true
236 }
237 }
238 }
239
240 var result []string
241 for kw := range keywordSet {
242 result = append(result, kw)
243 }
244 return result
245}
246
247func splitCamelCase(s string) []string {
248 var words []string

Callers 2

indexKeywordsMethod · 0.85
SearchMethod · 0.85

Calls 2

splitCamelCaseFunction · 0.85
isStopWordFunction · 0.85

Tested by

no test coverage detected