File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
feature/record/src/main/kotlin/com/ninecraft/booket/feature/record/ocr Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -52,11 +52,10 @@ class OcrPresenter @AssistedInject constructor(
5252 isTextDetectionFailed = true
5353 } else {
5454 isTextDetectionFailed = false
55- val sentences = recognizedText
56- .split(" \n " )
57- .map { it.trim() }
58- .filter { it.isNotEmpty() }
59- sentenceList = persistentListOf(* sentences.toTypedArray())
55+
56+ val parsedSentences = parseSentences(recognizedText)
57+ sentenceList = parsedSentences.toPersistentList()
58+
6059 currentUi = OcrUi .RESULT
6160 }
6261 }
@@ -107,3 +106,18 @@ class OcrPresenter @AssistedInject constructor(
107106 fun create (navigator : Navigator ): OcrPresenter
108107 }
109108}
109+
110+ fun parseSentences (text : String ): List <String > {
111+ val containsPunctuation = text.contains(Regex (" [.!?]" ))
112+
113+ return if (containsPunctuation) {
114+ text.replace(" \n " , " " )
115+ .split(Regex (" (?<=[.!?])\\ s+" ))
116+ .map { it.trim() }
117+ .filter { it.isNotEmpty() }
118+ } else {
119+ text.split(" \n " )
120+ .map { it.trim() }
121+ .filter { it.isNotEmpty() }
122+ }
123+ }
You can’t perform that action at this time.
0 commit comments