Skip to content

Commit

Permalink
🐛 #1 예약어 재귀 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
allbegray committed Mar 30, 2023
1 parent d80b2dc commit 99b88fc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = 'herbaccara'
version = '0.0.4'
version = '0.0.5'
sourceCompatibility = '1.8'

publishing {
Expand Down
16 changes: 11 additions & 5 deletions src/main/kotlin/herbaccara/jusokr/JusoKrService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ class JusoKrService(

internal fun filteredKeyword(keyword: String): String {
var filteredKeyword = keyword
for (reservedWord in reservedWords) {
if (filteredKeyword.contains(reservedWord, true)) {
filteredKeyword = filteredKeyword.replace(reservedWord, "", true)
}
}
for (c in specialCharacters) {
filteredKeyword = filteredKeyword.replace(c, "")
}
var stop = false
while (stop.not()) {
var replace = false
for (reservedWord in reservedWords) {
if (filteredKeyword.contains(reservedWord, true)) {
filteredKeyword = filteredKeyword.replace(reservedWord, "", true)
replace = true
}
}
stop = replace.not()
}
return filteredKeyword.replace("\\s+".toRegex(), " ")
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/kotlin/herbaccara/jusokr/ReservedWordsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ class ReservedWordsTest {
val filteredKeyword = JusoKrService.filteredKeyword(keyword)
Assertions.assertEquals("aa bb", filteredKeyword)
}

@Test
fun test2() {
val keyword = "OO%RR123"
val filteredKeyword = JusoKrService.filteredKeyword(keyword)
println(filteredKeyword)
Assertions.assertEquals("123", filteredKeyword)
}
}

0 comments on commit 99b88fc

Please sign in to comment.