question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Leverage levenshtein distance to help users debug easily when there are close matches

See original GitHub issue

Describe the feature you’d like:

Sometimes, due to minor typo or an extra space here and there, a match is not successful and queries throw the error. Due to the typo being non-obvious (like double-space or a dash instead of em-dash etc), it isn’t always an instantaneous pin-point to where the problem is.

I think it might be very useful for the users if they see something like this:

Unable to find an element with exact match: 15-25

Found close matches. Did you mean one of these:
  15–25
  19–22

<div>
	<ul> ... </ul>
</div>

Suggested implementation:

When a candidate node is tested for a match, also calculate levenshtein distance from its textContent to the target string, and push the score to an array (along with the node itself). After all nodes are tested, and no match is found, sort the array on distance score and suggest top 3 close candidates to the user.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kentcdoddscommented, May 19, 2020

I’ve considered this and think it would be really cool. However, I’m worried that this will be very challenging to do well. I don’t have the bandwidth to work on it myself, but I would be willing to look at a pull request for it.

0reactions
dougbacelarcommented, Nov 21, 2020

I created a proof of concept to gather some feedback. If there is interest i can finish it up 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text Similarity w/ Levenshtein Distance in Python | by Vatsal
Levenshtein distance is a great measure to use to identify lexical similarity between a pair of text, but it does not mean there...
Read more >
Levenshtein Distance and the concept of Fuzzy matching in ...
It is calculated by counting number of edits required to transform one string into another. The edits could be one of the following:...
Read more >
Address Matching in Excel Using Levenshtein Distance
Informally, the Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) ...
Read more >
How to Compare Two Strings in Python (in 8 Easy Ways)
Learn to compare if two strings are equal, or similar. Take string difference. Make comparisons ignoring case, and check if they are almost ......
Read more >
Testing Guide - OWASP Foundation
to application security that leverages the procedures already in place ... match, site B signs the user in as the user they claim...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found