Skip to content

Commit

Permalink
NormalizePattern.Normalize()
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed Sep 11, 2014
1 parent a7431e1 commit 1c9cf8c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion myprofiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type NormalizePattern struct {
subs string
}

func (p *NormalizePattern) Normalize(q string) string {
return p.re.ReplaceAllString(q, p.subs)
}

var (
normalizePatterns []NormalizePattern = []NormalizePattern{
NormalizePattern{regexp.MustCompile(`[+\-]{0,1}\b\d+\b`), "N"},
Expand Down Expand Up @@ -67,7 +71,7 @@ func normalizeQuery(query string) string {
parts := strings.Split(query, " ")
query = strings.Join(parts, " ")
for _, pat := range normalizePatterns {
query = pat.re.ReplaceAllString(query, pat.subs)
query = pat.Normalize(query)
}
return query
}
Expand Down

0 comments on commit 1c9cf8c

Please sign in to comment.