From 2c365edb169be9ed4ac80897fcff68178d011153 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 29 Aug 2020 15:53:36 +0800 Subject: [PATCH] Improve Chinese length in fuzzy search --- .../console/command/description/CommandArgParserBuiltins.kt | 4 ++-- .../net/mamoe/mirai/console/internal/command/internal.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgParserBuiltins.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgParserBuiltins.kt index bc2bf3115..21deaf53a 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgParserBuiltins.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandArgParserBuiltins.kt @@ -340,7 +340,7 @@ internal fun Char.chineseLength(): Int { return when (this) { in '\u0000'..'\u007F' -> 1 in '\u0080'..'\u07FF' -> 2 - in '\u0800'..'\uFFFF' -> 3 - else -> 4 + in '\u0800'..'\uFFFF' -> 2 + else -> 2 } } \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/internal.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/internal.kt index b23671266..6eb77d867 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/internal.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/internal.kt @@ -101,7 +101,7 @@ internal inline fun Collection.fuzzySearchOnly( */ internal fun Group.fuzzySearchMember( nameCardTarget: String, - minRate: Double = 0.5, // 参与判断, 用于提示可能的解 + minRate: Double = 0.2, // 参与判断, 用于提示可能的解 matchRate: Double = 0.6,// 最终选择的最少需要的匹配率, 减少歧义 /** * 如果有多个值超过 [matchRate], 并相互差距小于等于 [disambiguationRate], 则认为有较大歧义风险, 返回可能的解的列表.