Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

Commit

Permalink
feat: MessageFilter: improved predict
Browse files Browse the repository at this point in the history
  • Loading branch information
guimc233 committed Feb 24, 2024
1 parent cd75319 commit 6d505b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ object MessageFilter {
riskList.add(e.sender)
setVl(e.sender.id, 99.0)
muted = true
} else if (LL4JUtils.predictMap(textMessage)[1]!! >= 0.9) {
} else if (LL4JUtils.predictMap(textMessage)[1]!! >= 0.22) {
e.sender.mute(120, "非法发言内容 (模型预测认为可能性较高)")
riskList.add(e.sender)
setVl(e.sender.id, 99.0)
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/ltd/guimc/lgzbot/utils/LL4JUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ object LL4JUtils {
fun predictMap(string: String): MutableMap<Int, Double> =
model.predict(tokenizer.tokenize(0, string.replace("\n", "")).values)

fun predictAllResult(string: String): DoubleArray =
model.predictAllResult(tokenizer.tokenize(0, string.replace("\n", "")).values)

fun learn(type: Int, string: String) {
val dataSet = DataSet()
dataSet.split.add(tokenizer.tokenize(type, string.replace("\n", "")))
Expand Down
7 changes: 5 additions & 2 deletions src/test/java/Test.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import ltd.guimc.lgzbot.utils.HomoIntUtils;
import ltd.guimc.lgzbot.utils.LL4JUtils;

import java.util.Arrays;

public class Test {
public static void main(String[] args) {
System.out.println(HomoIntUtils.INSTANCE.getInt(8965));
LL4JUtils.INSTANCE.init();
System.out.println(Arrays.toString(LL4JUtils.INSTANCE.predictAllResult("")));
}
}

0 comments on commit 6d505b1

Please sign in to comment.