Class LevenshteinDistance
java.lang.Object
cloud.opencode.base.string.similarity.LevenshteinDistance
Levenshtein Distance - Calculates edit distance between strings.
编辑距离 - 计算字符串之间的编辑距离。
Features | 主要功能:
- Edit distance calculation - 编辑距离计算
- Similarity ratio calculation - 相似度比率计算
- O(n*m) time, O(m) space optimized - O(n*m)时间,O(m)空间优化
Usage Examples | 使用示例:
int distance = LevenshteinDistance.calculate("kitten", "sitting"); // 3
double similarity = LevenshteinDistance.similarity("hello", "hallo"); // 0.8
Security | 安全性:
- Thread-safe: Yes (stateless utility) - 线程安全: 是(无状态工具类)
- Null-safe: No (throws IllegalArgumentException for null) - 空值安全: 否
- Since:
- JDK 25, opencode-base-string V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
-
Method Details
-
calculate
-
similarity
-