Skip to content

Commit

Permalink
remove Levenshtein
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffy-melli committed Jan 14, 2025
1 parent e36c90a commit 2a06e1c
Showing 1 changed file with 55 additions and 30 deletions.
85 changes: 55 additions & 30 deletions korcen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package korcen

import (
"strings"
"unicode"

"github.com/fluffy-melli/korcen-go/cache"
)
Expand Down Expand Up @@ -105,9 +106,33 @@ func ChangeUnicode(unicode string) string {
unicode = strings.ReplaceAll(unicode, "C", "C")
unicode = strings.ReplaceAll(unicode, "U", "U")
unicode = strings.ToLower(unicode)
unicode = Duplicate(unicode)
unicode = SpecialChar(unicode)
return unicode
}

func Duplicate(input string) string {
var result strings.Builder
var prevRune rune
for i, currentRune := range input {
if i == 0 || currentRune != prevRune {
result.WriteRune(currentRune)
}
prevRune = currentRune
}
return result.String()
}

func SpecialChar(input string) string {
var result []rune
for _, r := range input {
if unicode.IsLetter(r) || unicode.IsDigit(r) {
result = append(result, r)
}
}
return string(result)
}

// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 일반적인 비속어 감지 및 결과 반환 함수
// 입력:
Expand Down Expand Up @@ -487,9 +512,9 @@ func General(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}

return false, ""
Expand Down Expand Up @@ -532,9 +557,9 @@ func Minor(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}

return false, ""
Expand Down Expand Up @@ -723,9 +748,9 @@ func Sexual(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}

return false, ""
Expand Down Expand Up @@ -780,9 +805,9 @@ func Belittle(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}

return false, ""
Expand All @@ -805,9 +830,9 @@ func Race(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}

return false, ""
Expand Down Expand Up @@ -838,9 +863,9 @@ func Parent(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}

return false, ""
Expand Down Expand Up @@ -882,9 +907,9 @@ func Politics(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}
return false, ""
}
Expand All @@ -905,9 +930,9 @@ func Japanese(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}

return false, ""
Expand All @@ -929,9 +954,9 @@ func Chinese(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}

return false, ""
Expand All @@ -952,9 +977,9 @@ func Special(input string) (bool, string) {
if strings.Contains(input, item) {
return true, item
}
if Levenshtein(input, item) <= 3 {
return true, item
}
//if Levenshtein(input, item) <= 3 {
// return true, item
//}
}

return false, ""
Expand Down

0 comments on commit 2a06e1c

Please sign in to comment.