Skip to content

Commit

Permalink
[폐업추정] String 비교 알고리즘 변경 (#416)
Browse files Browse the repository at this point in the history
chore: update string similarity comparison algorithm
  • Loading branch information
jyoo0515 authored Nov 6, 2024
1 parent dd097eb commit 975e5c7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 124 deletions.
1 change: 1 addition & 0 deletions app-server/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ guavaVersion=31.1-jre
sentryVersion=6.7.0
logbackJsonVersion=0.1.5
firebaseAdminVersion=9.3.0
apacheCommonsVersion=1.11.0

# gradle config
org.gradle.jvmargs=-Xmx8g
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ plugins {
}

dependencies {
val awsSdkVersion: String by project
val apacheCommonsVersion: String by project

api(projects.apiSpecification.api)
api(projects.apiSpecification.domainEvent)
implementation(projects.crossCuttingConcern.infra.persistenceModel)
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("io.projectreactor.netty:reactor-netty")
implementation("org.springframework:spring-webflux")
implementation("org.apache.commons:commons-csv:1.11.0")

integrationTestImplementation(projects.crossCuttingConcern.test.springIt)

val awsSdkVersion: String by project
implementation("org.apache.commons:commons-csv:$apacheCommonsVersion")
implementation("software.amazon.awssdk:s3:$awsSdkVersion")
runtimeOnly("software.amazon.awssdk:sts:$awsSdkVersion") // IRSA를 사용하기 위해서 필요함

integrationTestImplementation(projects.crossCuttingConcern.test.springIt)
testImplementation(projects.boundedContext.externalAccessibility.application)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import club.staircrusher.place.application.port.out.web.OpenDataService
import club.staircrusher.place.domain.model.ClosedPlaceCandidate
import club.staircrusher.stdlib.persistence.TransactionManager
import club.staircrusher.stdlib.time.toStartOfDay
import club.staircrusher.stdlib.util.string.getSimilarityWith
import mu.KotlinLogging
import org.springframework.stereotype.Service
import java.util.UUID
Expand All @@ -26,7 +27,7 @@ class CreateClosedPlaceCandidatesUseCase(
if (nearbyPlaces.isEmpty()) return@mapNotNull null

val placeToSimilarity = nearbyPlaces
.associateWith { StringSimilarityComparator.getSimilarity(it.name, closedPlace.name) }
.associateWith { it.name.getSimilarityWith(closedPlace.name) }
val similarPlace = placeToSimilarity
.filter { it.value < SIMILARITY_THRESHOLD }
.minByOrNull { it.value }
Expand Down Expand Up @@ -58,6 +59,6 @@ class CreateClosedPlaceCandidatesUseCase(

companion object {
private const val SEARCH_RADIUS = 30
private const val SIMILARITY_THRESHOLD = 0.3
private const val SIMILARITY_THRESHOLD = 0.2
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ dependencies {
val jtsVersion: String by project
val proj4jVersion: String by project
val kopyKatVersion: String by project
val apacheCommonsVersion: String by project
implementation("org.geotools:gt-referencing:$geoToolsVersion")
implementation("org.locationtech.jts:jts-core:$jtsVersion")
implementation("org.locationtech.proj4j:proj4j:$proj4jVersion")
implementation("org.locationtech.proj4j:proj4j-epsg:$proj4jVersion")
implementation("com.auth0:java-jwt:3.18.1")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.11.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
implementation("org.apache.commons:commons-text:$apacheCommonsVersion")

api("jakarta.persistence:jakarta.persistence-api")
api("org.springframework.data:spring-data-commons")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package club.staircrusher.stdlib.util.string

import org.apache.commons.text.similarity.JaroWinklerDistance
import java.util.*

fun String.emptyToNull() = this.ifBlank { null }
Expand All @@ -11,6 +12,10 @@ fun String.isSimilarWith(pattern: String): Boolean {
)
}

fun String.getSimilarityWith(other: String): Double {
return JaroWinklerDistance().apply(this, other)
}

private fun simpleMatch(text: String, pattern: String): Boolean {
var patternIndex = 0
for (char in text) {
Expand Down

0 comments on commit 975e5c7

Please sign in to comment.