Skip to content

Commit

Permalink
More special charaters to split keyword when searching for related ti…
Browse files Browse the repository at this point in the history
…tles
  • Loading branch information
cuong-tran committed Apr 28, 2024
1 parent c0fe7df commit 9f321fd
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import uy.kohesive.injekt.api.get
import java.net.URI
import java.net.URISyntaxException
import java.security.MessageDigest
import java.util.Locale

/**
* A simple implementation for sources from a website.
Expand Down Expand Up @@ -322,15 +321,16 @@ abstract class HttpSource : CatalogueSource {
protected open suspend fun getRelatedMangaListBySearch(manga: SManga): List<SManga> {
fun String.stripKeyword(): List<String> {
val regexWhitespace = Regex("\\s+")
val regexSpecialCharacters = Regex("[\\[(!~@#$%^&*|,?:\"<>)\\]]")
val regexSpecialCharacters =
Regex("([!~#$%^&*+_|/\\\\,?:;'“”‘’\"<>(){}\\[\\]。・~:—!?、―«»《》〘〙【】「」|]|\\s-|-\\s|\\s\\.|\\.\\s)")
val regexNumberOnly = Regex("^\\d+$")

return replace(regexSpecialCharacters, " ")
.split(regexWhitespace)
.map {
// remove number only
it.replace(regexNumberOnly, "")
.lowercase(Locale.getDefault())
.lowercase()
}
// exclude single character
.filter { it.length > 1 }
Expand Down

0 comments on commit 9f321fd

Please sign in to comment.