diff --git a/app/build.gradle b/app/build.gradle index b4a071e38..5889ed763 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -209,8 +209,7 @@ dependencies { implementation 'io.noties.markwon:html:4.6.0' //转换繁体 - implementation 'com.hankcs:hanlp:portable-1.7.8' - + implementation 'com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.1.3' //epub implementation('com.positiondev.epublib:epublib-core:3.1') { exclude group: 'org.slf4j' diff --git a/app/src/main/java/io/legado/app/help/ContentProcessor.kt b/app/src/main/java/io/legado/app/help/ContentProcessor.kt index f0c44273a..af19c11ca 100644 --- a/app/src/main/java/io/legado/app/help/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/ContentProcessor.kt @@ -1,6 +1,6 @@ package io.legado.app.help -import com.hankcs.hanlp.HanLP +import com.github.liuyueyi.quick.transfer.ChineseUtils import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.data.entities.ReplaceRule @@ -51,8 +51,8 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str } try { when (AppConfig.chineseConverterType) { - 1 -> content1 = HanLP.convertToSimplifiedChinese(content1) - 2 -> content1 = HanLP.convertToTraditionalChinese(content1) + 1 -> content1 = ChineseUtils.t2s(content1) + 2 -> content1 = ChineseUtils.s2t(content1) } } catch (e: Exception) { appCtx.toastOnUi("简繁转换出错") diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 63d892374..f1f33f4ed 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -1,7 +1,7 @@ package io.legado.app.service.help import androidx.lifecycle.MutableLiveData -import com.hankcs.hanlp.HanLP +import com.github.liuyueyi.quick.transfer.ChineseUtils import io.legado.app.constant.BookType import io.legado.app.data.appDb import io.legado.app.data.entities.* @@ -407,8 +407,8 @@ object ReadBook { ImageProvider.clearOut(durChapterIndex) if (chapter.index in durChapterIndex - 1..durChapterIndex + 1) { chapter.title = when (AppConfig.chineseConverterType) { - 1 -> HanLP.convertToSimplifiedChinese(chapter.title) - 2 -> HanLP.convertToTraditionalChinese(chapter.title) + 1 -> ChineseUtils.t2s(chapter.title) + 2 -> ChineseUtils.s2t(chapter.title) else -> chapter.title } val contents = contentProcessor!!.getContent(book, chapter.title, content) diff --git a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt index aa433c6c8..4d89a1c64 100644 --- a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt @@ -5,7 +5,7 @@ import android.content.Intent import android.os.Bundle import androidx.activity.viewModels import androidx.appcompat.widget.SearchView -import com.hankcs.hanlp.HanLP +import com.github.liuyueyi.quick.transfer.ChineseUtils import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.EventBus @@ -180,8 +180,8 @@ class SearchContentActivity : //搜索替换后的正文 withContext(Dispatchers.IO) { chapter.title = when (AppConfig.chineseConverterType) { - 1 -> HanLP.convertToSimplifiedChinese(chapter.title) - 2 -> HanLP.convertToTraditionalChinese(chapter.title) + 1 -> ChineseUtils.t2s(chapter.title) + 2 -> ChineseUtils.s2t(chapter.title) else -> chapter.title } replaceContents = diff --git a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt index 20526518a..11b55b24d 100644 --- a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt +++ b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt @@ -2,7 +2,7 @@ package io.legado.app.ui.welcome import android.content.Intent import android.os.Bundle -import com.hankcs.hanlp.HanLP +import com.github.liuyueyi.quick.transfer.ChineseUtils import io.legado.app.base.BaseActivity import io.legado.app.constant.PreferKey import io.legado.app.data.appDb @@ -61,8 +61,8 @@ open class WelcomeActivity : BaseActivity() { } //初始化简繁转换引擎 when (AppConfig.chineseConverterType) { - 1 -> HanLP.convertToSimplifiedChinese("初始化") - 2 -> HanLP.convertToTraditionalChinese("初始化") + 1 -> ChineseUtils.t2s("初始化") + 2 -> ChineseUtils.s2t("初始化") else -> null } }