优化
This commit is contained in:
@@ -2,6 +2,7 @@ package io.legado.app.utils
|
|||||||
|
|
||||||
import com.github.liuyueyi.quick.transfer.ChineseUtils
|
import com.github.liuyueyi.quick.transfer.ChineseUtils
|
||||||
import com.github.liuyueyi.quick.transfer.constants.TransType
|
import com.github.liuyueyi.quick.transfer.constants.TransType
|
||||||
|
import com.github.liuyueyi.quick.transfer.dictionary.BasicDictionary
|
||||||
import com.github.liuyueyi.quick.transfer.dictionary.DictionaryContainer
|
import com.github.liuyueyi.quick.transfer.dictionary.DictionaryContainer
|
||||||
|
|
||||||
object ChineseUtils {
|
object ChineseUtils {
|
||||||
@@ -30,16 +31,21 @@ object ChineseUtils {
|
|||||||
|
|
||||||
fun fixT2sDict() {
|
fun fixT2sDict() {
|
||||||
val dict = DictionaryContainer.getInstance().getDictionary(TransType.TRADITIONAL_TO_SIMPLE)
|
val dict = DictionaryContainer.getInstance().getDictionary(TransType.TRADITIONAL_TO_SIMPLE)
|
||||||
dict.chars.run {
|
dict.run {
|
||||||
remove('劈')
|
remove("劈")
|
||||||
remove('脊')
|
remove("脊")
|
||||||
}
|
|
||||||
kotlin.runCatching {
|
|
||||||
dict.dict.run {
|
|
||||||
remove("支援")
|
remove("支援")
|
||||||
|
remove("沈默")
|
||||||
remove("路易斯")
|
remove("路易斯")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun BasicDictionary.remove(key: String) {
|
||||||
|
if (key.length == 1) {
|
||||||
|
chars.remove(key[0])
|
||||||
|
} else {
|
||||||
|
dict.remove(key)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ fun <T> TrieNode<T>.getChildren(): HashMap<Char, TrieNode<T>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Trie<T>.remove(value: String) {
|
fun <T> Trie<T>.remove(value: String) {
|
||||||
|
kotlin.runCatching {
|
||||||
var node = getRoot()
|
var node = getRoot()
|
||||||
val nodes = arrayListOf<TrieNode<T>>()
|
val nodes = arrayListOf<TrieNode<T>>()
|
||||||
val chars = value.toCharArray()
|
val chars = value.toCharArray()
|
||||||
@@ -37,3 +38,4 @@ fun <T> Trie<T>.remove(value: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user