Bktree
bk-tree for golang
Install / Use
/learn @gansidui/BktreeREADME
bktree
编辑距离(Edit Distance),又称Levenshtein距离,是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。
许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。
bktree的作用是:
给定一个词典(很多字符串),然后每输入一个字符串和一个数字k,
从词典中查找出与该字符串编辑距离小于等于k的字符串。
package main
import (
"fmt"
"github.com/gansidui/bktree"
"log"
)
func main() {
if bktree.Levenshtein("hello", "Aelo") != 2 {
log.Fatal()
}
if bktree.Levenshtein("我爱你", "你爱我") != 2 {
log.Fatal()
}
bk := bktree.New()
bk.SetLevenshteinLimit(50)
bk.Insert("ABCD")
bk.Insert("ACED")
bk.Insert("SBDE")
ret := bk.Find("AABB", 3, -1)
fmt.Println(ret)
}
LICENSE
MIT
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
