[RFC]: Hamming distance between two strings
- 主要语言
- JavaScript
- 星标
- 6k
- 派生
- 1.3k
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 611
描述
### Description
This RFC proposes adding a function to calculate the Hamming distance between two strings.
The function should have the following signature `(a: string, b: string): number`.
The function should take two strings as arguments and return the Hamming distance between them. The Hamming distance is defined as the number of characters that have to be changed to convert one string to the other. Since it only allows substitutions, it can only be used to compare strings of the same length.
Additionally, in order to account for code points and grapheme clusters, we should add separate packages for dealing with each, as the underlying algorithms are likely to differ. We then can provide a more general API which unifies the underlying algorithms. Accordingly, we should create the following packages:
- [x] `@stdlib/string/base/distances/hamming`: compares UTF-16 code units.
- PR: https://github.com/stdlib-js/stdlib/pull/1166
- [ ] `@stdlib/string/base/distances/hamming-code-points`: compares Unicode code points.
- [ ] `@stdlib/string/base/distances/hamming-grapheme-clusters`: compares grapheme clusters (i.e., visual characters)
Once the above are completed, we can add
- [ ] `@stdlib/string/distances/hamming`: unifies the above "base" packages and provides an option for specifying the computation "mode" (i.e., `code_units`, `code_points`, or `grapheme_clusters`, with `grapheme_clusters` being the default).
### Related Issues
Related issues https://github.com/stdlib-js/stdlib/issues/151.
### Questions
No.
### Other
No.
### Checklist
- [X] I have read and understood the [Code of Conduct](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md).
- [X] Searched for existing issues and pull requests.
- [X] The issue name begins with `RFC:`.
贡献指南
调研方向
Review the completed @stdlib/string/base/distances/hamming package and PR #1166 first. Then scope the remaining code-point and grapheme-cluster packages and the unified @stdlib/string/distances/hamming API; the work is done when those unchecked packages and the mode-based API are completed as specified.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- api
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100