levenshteinDistance does not support unicode characters
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 45/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- À l'abandon
- Stack technique
- javascript
- Domaine
- devtools
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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))
- Langage dominant
- JavaScript
- Étoiles
- 197k
- Forks
- 31k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de trekhleb/javascript-algorithms
-
BinarySearchTreeNode removing Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
trekhleb/javascript-algorithms#2102 · 1 commentaire ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
trekhleb/javascript-algorithms#2085 · 6 commentaires · 1 réaction ·
-
LinkedList methods. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
trekhleb/javascript-algorithms#2065 · 1 commentaire ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
trekhleb/javascript-algorithms#2057 · 1 commentaire ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
trekhleb/javascript-algorithms#2056 ·
Toutes les issues de trekhleb/javascript-algorithms
Issues similaires
-
code-quality refactoring
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100