MCPcopy Index your code
hub / github.com/apache/answer / parseVotes

Method parseVotes

internal/service/search_parser/search_parser.go:180–196  ·  view source on GitHub ↗

parseVotes return the votes of search query

(query *string)

Source from the content-addressed store, hash-verified

178
179// parseVotes return the votes of search query
180func (sp *SearchParser) parseVotes(query *string) (votes int) {
181 var (
182 expr = `score:(\d+)`
183 q = *query
184 )
185 votes = -1
186
187 re := regexp.MustCompile(expr)
188 res := re.FindStringSubmatch(q)
189 if len(res) > 1 {
190 votes = converter.StringToInt(res[1])
191 q = re.ReplaceAllString(q, "")
192 }
193
194 *query = strings.TrimSpace(q)
195 return
196}
197
198// parseWithin parse quotes within words like: "hello world"
199func (sp *SearchParser) parseWithin(query *string) (words []string) {

Callers 1

ParseStructureMethod · 0.95

Calls 1

StringToIntFunction · 0.92

Tested by

no test coverage detected