Improve Chinese length in fuzzy search

This commit is contained in:
Him188 2020-08-29 15:53:36 +08:00
parent 83f43615c6
commit 2c365edb16
2 changed files with 3 additions and 3 deletions

View File

@ -340,7 +340,7 @@ internal fun Char.chineseLength(): Int {
return when (this) { return when (this) {
in '\u0000'..'\u007F' -> 1 in '\u0000'..'\u007F' -> 1
in '\u0080'..'\u07FF' -> 2 in '\u0080'..'\u07FF' -> 2
in '\u0800'..'\uFFFF' -> 3 in '\u0800'..'\uFFFF' -> 2
else -> 4 else -> 2
} }
} }

View File

@ -101,7 +101,7 @@ internal inline fun <T : Any> Collection<T>.fuzzySearchOnly(
*/ */
internal fun Group.fuzzySearchMember( internal fun Group.fuzzySearchMember(
nameCardTarget: String, nameCardTarget: String,
minRate: Double = 0.5, // 参与判断, 用于提示可能的解 minRate: Double = 0.2, // 参与判断, 用于提示可能的解
matchRate: Double = 0.6,// 最终选择的最少需要的匹配率, 减少歧义 matchRate: Double = 0.6,// 最终选择的最少需要的匹配率, 减少歧义
/** /**
* 如果有多个值超过 [matchRate], 并相互差距小于等于 [disambiguationRate], 则认为有较大歧义风险, 返回可能的解的列表. * 如果有多个值超过 [matchRate], 并相互差距小于等于 [disambiguationRate], 则认为有较大歧义风险, 返回可能的解的列表.