diff --git a/simplify/words.go b/simplify/words.go index 4d511ce..9cc05e8 100644 --- a/simplify/words.go +++ b/simplify/words.go @@ -1,7 +1,6 @@ package simplify import ( - "slices" "strings" "unicode" ) @@ -70,7 +69,7 @@ func (w *Words) Simplify() []string { filteredWhole := make([]string, 0) for keyword, times := range repetition { if times == 1 { - if slices.Contains(w.input, keyword) { + if w.contains(w.input, keyword) { filteredInput = append(filteredInput, keyword) } else { filteredWhole = append(filteredWhole, keyword) @@ -84,6 +83,15 @@ func (w *Words) Simplify() []string { return result } +func (w *Words) contains(arr []string, str string) bool { + for _, v := range arr { + if v == str { + return true + } + } + return false +} + // isChineseOrSpace 判断给定的rune字符是否为中文或空格 func (w *Words) isChineseOrSpace(r rune) bool { return r == ' ' || unicode.Is(unicode.Scripts["Han"], r)