From b28661bf9b71a7bd7f0c9b56e413777de3c34675 Mon Sep 17 00:00:00 2001 From: songqingqing <18520276036@163.com> Date: Wed, 11 Dec 2024 17:10:11 +0800 Subject: [PATCH] =?UTF-8?q?Simplify=E5=8C=85=EF=BC=9A=20=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?ES=E9=83=A8=E5=88=86=E5=88=86=E8=AF=8D=E8=A7=84=E5=88=99?= =?UTF-8?q?=EF=BC=8C=E5=AF=B9=E6=9F=A5=E8=AF=A2=E5=85=B3=E9=94=AE=E5=AD=97?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=8E=BB=E9=87=8D=EF=BC=9A=E4=B8=8D=E4=BE=9D?= =?UTF-8?q?=E8=B5=96slices=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simplify/words.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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)