新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)GoFrame教程:GoFramegstr-相似計(jì)算
Levenshtein

創(chuàng)新互聯(lián)專注于網(wǎng)站建設(shè),為客戶提供成都做網(wǎng)站、成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)開發(fā)服務(wù),多年建網(wǎng)站服務(wù)經(jīng)驗(yàn),各類網(wǎng)站都可以開發(fā),成都品牌網(wǎng)站建設(shè),公司官網(wǎng),公司展示網(wǎng)站,網(wǎng)站設(shè)計(jì),建網(wǎng)站費(fèi)用,建網(wǎng)站多少錢,價格優(yōu)惠,收費(fèi)合理。
- 說明:?
Levenshtein?計(jì)算兩個字符串之間的?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?計(jì)算兩個字符串之間的相似度。 - 格式:
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?用于計(jì)算字符串的?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
} 本文標(biāo)題:創(chuàng)新互聯(lián)GoFrame教程:GoFramegstr-相似計(jì)算
瀏覽地址:http://fisionsoft.com.cn/article/dpihojs.html


咨詢
建站咨詢
