扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
创新互联专注于网站建设,为客户提供成都做网站、成都网站建设、网页设计开发服务,多年建网站服务经验,各类网站都可以开发,成都品牌网站建设,公司官网,公司展示网站,网站设计,建网站费用,建网站多少钱,价格优惠,收费合理。
Levenshtein
计算两个字符串之间的Levenshtein
距离。 Levenshtein(str1, str2 string, costIns, costRep, costDel int) int
func ExampleLevenshtein() {
var (
str1 = "Hello World"
str2 = "hallo World"
costIns = 1
costRep = 1
costDel = 1
result = gstr.Levenshtein(str1, str2, costIns, costRep, costDel)
)
fmt.Println(result)
// Output:
// 2
}
SimilarText
计算两个字符串之间的相似度。 SimilarText(first, second string, percent *float64) int
func ExampleSimilarText() {
var (
first = `AaBbCcDd`
second = `ad`
percent = 0.80
result = gstr.SimilarText(first, second, &percent)
)
fmt.Println(result)
// Output:
// 2
}
Soundex
用于计算字符串的Soundex
键。 Soundex(str string) string
func ExampleSoundex() {
var (
str1 = `Hello`
str2 = `Hallo`
result1 = gstr.Soundex(str1)
result2 = gstr.Soundex(str2)
)
fmt.Println(result1, result2)
// Output:
// H400 H400
}
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流