Strsim
Calculate string similarity library, integrate multiple algorithms on the back end。计算字符串相似度库,后端集成多种算法[从零实现]
Install / Use
/learn @antlabs/StrsimREADME
strsim
strsim是golang实现的字符串相识度库,后端集成多种算法,主要解决现有相似度库不能很好的处理中文
构架

使用方式
go get -u github.com/antlabs/strsim
功能
- 可以忽略空白字符
- 可以大小写
多种算法支持
- 莱文斯坦-编辑距离(Levenshtein)
- Hamming
- Dice's coefficient
- Jaro
- JaroWinkler
- Cosine
- Simhash
内容
比较两个字符串相识度
strsim.Compare("中国人", "中")
// -> 0.333333
从数组里找到相似度最高的字符串
strsim.FindBestMatchOne("海刘", []string{"白日依山尽", "黄河入海流", "欲穷千里目", "更上一层楼"})
从数组里找到相似度最高的字符串-带下标
strsim.FindBestMatch("海刘", []string{"白日依山尽", "黄河入海流", "欲穷千里目", "更上一层楼"})
选择不同算法
莱文斯坦-编辑距离(Levenshtein)
strsim.Compare("abc", "ab")
// -> 0.6666666666666667
选择Dice's coefficient
strsim.Compare("abc", "ab", strsim.DiceCoefficient())
//-> 0.6666666666666666
选择jaro
strsim.Compare("abc", "ab", strsim.Jaro())
选择JaroWinkler
strsim.Compare("abc", "ab", strsim.JaroWinkler())
选择Hamming
strsim.Compare("abc", "ab", strsim.Hamming())
选择Cosine
strsim.Compare("abc", "ab", strsim.Cosine())
选择Simhash
strsim.Compare("abc", "ab", strsim.Simhash())
Related Skills
node-connect
344.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
99.2kCreate 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
344.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
