Skip to content

Commit

Permalink
Remove ending periods to speed up reading sentences, perhaps
Browse files Browse the repository at this point in the history
  • Loading branch information
hufman committed Apr 9, 2024
1 parent 6598a8b commit eac117c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/gestalt/java/io/bimmergestalt/reader/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object Utils {
*/
return article.replace(Regex("(\\S{3}[.?!])\\p{Blank}+?\n?"), "$1\n")
.lines()
.map { it.trim() }
.map { it.trim().trimEnd('.') }
.filter { it.isNotBlank() }
}

Expand Down
10 changes: 9 additions & 1 deletion app/src/testGestalt/java/io/bimmergestalt/reader/UtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UtilsTest {
fun testReadoutFormat() {
val input = "Line1 spoken by H. G. Wells and his Jr. son. But, maybe not? Same paragraph:\nLine2\n\nExcited line!\nVersion number 3.4.2 is unterminated\n\nReady? Go!\n\n\t\t\n"
val expected = listOf(
"Line1 spoken by H. G. Wells and his Jr. son.",
"Line1 spoken by H. G. Wells and his Jr. son",
"But, maybe not?",
"Same paragraph:",
"Line2",
Expand All @@ -18,5 +18,13 @@ class UtilsTest {
"Go!"
)
assertEquals(expected, Utils.formatForReadout(input))

val punctuationInput = "Spoken word. Pensive... Thoughts are explosive!"
val expectedPunctuation = listOf(
"Spoken word",
"Pensive",
"Thoughts are explosive!",
)
assertEquals(expectedPunctuation, Utils.formatForReadout(punctuationInput))
}
}

0 comments on commit eac117c

Please sign in to comment.