修复繁简转换“勐”“十”问题。使用了剥离HanLP简繁代码的民间库。APK减少6M左右

pull/898/head
hoodie13 4 years ago
parent 7c9735dcec
commit 39b2f1b315
  1. 3
      app/build.gradle
  2. 6
      app/src/main/java/io/legado/app/help/ContentProcessor.kt
  3. 6
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  4. 6
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt
  5. 6
      app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt

@ -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'

@ -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("简繁转换出错")

@ -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)

@ -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 =

@ -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<ActivityWelcomeBinding>() {
}
//初始化简繁转换引擎
when (AppConfig.chineseConverterType) {
1 -> HanLP.convertToSimplifiedChinese("初始化")
2 -> HanLP.convertToTraditionalChinese("初始化")
1 -> ChineseUtils.t2s("初始化")
2 -> ChineseUtils.s2t("初始化")
else -> null
}
}

Loading…
Cancel
Save