项目概述
📐 Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.
项目地址
https://github.com/life4/textdistance
项目页面预览

关键指标
- Stars:3510
- 主要语言:Python
- License:MIT License
- 最近更新:2025-04-18T12:13:17Z
- 默认分支:master
本站高速下载(国内可用)
点击下载(本站镜像)
– SHA256:54725fe98c6a6aa64742ffa15fde614cb680cdfe7b3bfa3be77b01731a44a2d4
安装部署要点(README 精选)
Installation
Usage
All algorithms have 2 interfaces:
- Class with algorithm-specific params for customizing.
- Class instance with default params for quick and simple usage.
All algorithms have some common methods:
.distance(*sequences)— calculate distance between sequences..similarity(*sequences)— calculate similarity for sequences..maximum(*sequences)— maximum possible value for distance and similarity. For any sequence:distance + similarity == maximum..normalized_distance(*sequences)— normalized distance between sequences. The return value is a float between 0 and 1, where 0 means equal, and 1 totally different..normalized_similarity(*sequences)— normalized similarity for sequences. The return value is a float between 0 and 1, where 0 means totally different, and 1 equal.
Most common init arguments:
qval— q-value for split sequences into q-grams. Possible values:- 1 (default) — compare sequences by chars.
- 2 or more — transform sequences to q-grams.
- None — split sequences by words.
as_set— for token-based algorithms:- True —
tandtttis equal. - False (default) —
tandtttis different.
- True —
Running tests
All you need is task. See Taskfile.yml for the list of available commands. For example, to run tests including third-party libraries usage, execute task pytest-external:run.
常用命令(从 README 提取)
pip install textdistance
pip install "textdistance[extras]"
pip install "textdistance[benchmark]"
通用部署说明
- 下载源码并阅读 README
- 安装依赖(pip/npm/yarn 等)
- 配置环境变量(API Key、模型路径、数据库等)
- 启动服务并测试访问
- 上线建议:Nginx 反代 + HTTPS + 进程守护(systemd / pm2)
免责声明与版权说明
本文仅做开源项目整理与教程索引,源码版权归原作者所有,请遵循对应 License 合规使用。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END








暂无评论内容