levenshteinDistance does not support unicode characters
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- devtools
調査の方向性
Start by locating the levenshteinDistance implementation and its existing tests. Reproduce the astral Unicode case from the issue, then add regression coverage for it and verify that the distance for '\u{1f431}' versus an empty string is 1.
索引モデルが issue の本文から書いたものです。
説明
Details:
levenshteinDistance does not support unicode characters outside of the BMP range properly.
Step to reproduce: expect(levenshteinDistance('\u{1f431}', '')).toBe(1) // got 2
Fix
I can issue a PR with the fix https://github.com/dubzzz/javascript-algorithms/commit/856ba360134956cca2bed165929a4d4409537201
How did I find it?
Thanks to property based testing framework fast-check.
The property was the following:
import fc from 'fast-check';
fc.assert(
fc.property(
fc.fullUnicodeString(), fc.fullUnicodeString(),
fc.fullUnicodeString(), fc.fullUnicodeString(),
fc.fullUnicodeString(),
(aBegin, aEnd, bBegin, bEnd, common) =>
levenshteinDistance(aBegin + common + aEnd, bBegin + common + bEnd)
<= Math.max([...aBegin].length, [...bBegin].length) + Math.max([...aEnd].length, [...bEnd].length)
)
)
Or:
for any
aandb- strings
such thata = aBegin + common + aEndandb = bBegin + common + bEnd
levenshteinDistance(a, b)is at mostmax(numChars(aBegin), numChars(bBegin)) + max(numChars(aEnd), numChars(bEnd))
- 主要言語
- JavaScript
- スター
- 197k
- フォーク
- 31k
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
trekhleb/javascript-algorithms のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
trekhleb/javascript-algorithms#2102 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
trekhleb/javascript-algorithms#2085 · コメント 6 件 · リアクション 1 件 ·
-
LinkedList methods. オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
trekhleb/javascript-algorithms#2065 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
trekhleb/javascript-algorithms#2057 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
trekhleb/javascript-algorithms#2056 ·
trekhleb/javascript-algorithms の issue をすべて見る
似ている issue
-
code-quality refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100