Skip to content

Commit

Permalink
feat: AutoTextCorrector 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
yonghanJu committed Nov 14, 2023
1 parent e47c439 commit b1bd753
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions feat/capture/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ android {

dependencies {
implementation(project(":common"))
implementation(project(":autotextcorrection"))

// Android
implementation(AndroidX.CORE_KTX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.graphics.Bitmap
import android.net.Uri
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import com.konkuk.autotextcorrection.AutoTextCorrector
import com.konkuk.common.data.FoodInfo
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -40,11 +41,14 @@ class EnrollTextInputViewModel @Inject constructor(

init {
savesStateHandle.get<String>(OCR_RESULT_KEY)?.let { text ->
val result = text.replace(" ", "")
.replace(",", ".")
.replace(")", "")
val correctedText =
AutoTextCorrector(nutritionNameList, 2).correctText(text.replace("%", "% "))

setFoodInfo(result)
setFoodInfo(
correctedText.replace(" ", "")
.replace(",", ".")
.replace(")", ""),
)
}
savesStateHandle.get<FoodInfo?>(API_RESULT_KEY)?.let {
setFoodInfo(it)
Expand Down Expand Up @@ -123,6 +127,18 @@ class EnrollTextInputViewModel @Inject constructor(
const val API_RESULT_KEY = "API_RESULT_KEY"
const val BITMAP_PICTURE_KEY = "BITMAP_PICTURE_KEY"
const val URI_PICTURE_KEY = "URI_PICTURE_KEY"

val nutritionNameList = listOf(
"칼로리",
"탄수화물",
"단백질",
"당류",
"지방",
"포화지빙",
"트랜스지방",
"콜레스트롤",
"나트륨",
)
}
}

Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ include ':feat:personal'
include ':feat:history'
include ':feat:capture'
include ':common'
include ':autotextcorrection'

0 comments on commit b1bd753

Please sign in to comment.