Skip to content

Commit

Permalink
fix(ll4j): bypass some words
Browse files Browse the repository at this point in the history
  • Loading branch information
guimc233 committed Aug 25, 2024
1 parent f98c5c8 commit 4dd5d5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/kotlin/ltd/guimc/lgzbot/PluginMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ object PluginMain : KotlinPlugin(
webHookService.start()
logger.info("正在初始化 LL4J")
LL4JUtils.init()
thread { LL4JUtils.downloadModel() }.start()
logger.info("$name v$version 加载好了喵")
}

Expand Down
11 changes: 8 additions & 3 deletions src/main/kotlin/ltd/guimc/lgzbot/utils/LL4JUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ object LL4JUtils {
}

fun predict(string: String): Boolean =
model.predictDebug(tokenizer.tokenize(0, string.replace("\n", "")).values).first == 1
model.predictDebug(
tokenizer.tokenize(
0,
string.replace("\n", "").replace("live.bilibili.com", "")
).values
).first == 1

fun predictDebug(string: String): Pair<Int, Double> =
model.predictDebug(tokenizer.tokenize(0, string.replace("\n", "")).values)
model.predictDebug(tokenizer.tokenize(0, string.replace("\n", "").replace("live.bilibili.com", "")).values)

fun predictAllResult(string: String): DoubleArray =
model.predictAllResult(
tokenizer.tokenize(
0, sbc2dbcCase(string.replace("\n", ""))
0, sbc2dbcCase(string.replace("\n", "").replace("live.bilibili.com", ""))
.lowercase()
.removeInterference()
.removeNonVisible()
Expand Down

0 comments on commit 4dd5d5c

Please sign in to comment.