gustf / js-levenshtein Goto Github PK
View Code? Open in Web Editor NEWThe most efficient JS implementation calculating the Levenshtein distance, i.e. the difference between two strings.
License: MIT License
The most efficient JS implementation calculating the Levenshtein distance, i.e. the difference between two strings.
License: MIT License
I was thinking if var vector = new Array(2 * la)
would help instead of var vector = [];
? In theory arrays are created with predefined size and they are reallocated if that size is exceeded (with some new limit estimate). I don't know how the browsers optimize it today, but surely the length constructor exists for a reason.
Any thouhts of TypeScript support?
I'm going to try my hand at this if I can wrap my head around the code. As it stands, it's fairly hard to understand what on earth is going on.
For example in the following text:
Easier to reason about useMemo can make your code easier to reason about by making it clear which values are being calculated and when.
Follow-up questions
What are some other ways to improve the performance of React applications?
I want to locate and split by sting like : Follow-up questions
, Follow-up questions:
, Follow-up question
, Followup questions
, Follow-up questions=
, follow-up questions:=
.
I know searching by regex is an option by I am looking to explore levenshtein to keep room for an unexpected letter.
This project doesn't have a typings file, which makes it hard to use in a TypeScript project. I didn't find any under @types, either.
Hello,
Thank you for this implementation. It is indeed very fast!
I am trying to optimize the algorithm for the specific (but rather common) case where we look for only close items. Stopping early when we know that the distance will certainly be over a given maximum distance can make the algorithm much faster.
I get already a good speed improvement (x2) by stopping early at the very beginning here and/or here with something like:
if (typeof max === 'number' && lb - la >= max) return max;
But when I try to stop early in the for loops below, by keeping the minimum value of vector
and stopping if min + lb - la > max
, it works but gets slower ;(
Do you have any idea of how to implement this feature in an optimized way?
The best would be of course to support this option directly in your code ;) but any advice is welcome!
Thank you very much for your help.
Cheers
Perhaps not with this library specifically, but would you happen to know if it's possible to in essence "pre-compute" part of the levenshtein distance if we know what one argument will be? eg. I have a fixed set of strings, and the other input is always unknown.
That could nudge the performance even further I presume.
hey I got a question, does it count different cases? like "something" and "SOMEthing" won't be 100%?
This library works fast, but its compatibility is very limited. Using a few lines like in old fast-levenshtein allows the algorithm to be used with AMD, requireJS, Web workers and commonJs.
Have you considered offering a case-insensitive version of the levenshtein distance algorithm?
Would be useful for folks performing fuzzy searches.
Hi, Could you please tell me, where I can plug a custom substitution cost function, or is it not straightforward? There are no comments for the substution/insertion/deletion steps.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.