lobiwinning.blogg.se

String similarity
String similarity













string similarity

Performance improvement for compareTwoStrings(.): now O(n) instead of O(n^2).Updated to ES6 (this breaks backward-compatibility for pre-ES6 apps).findBestMatch ( 'Olive-green table for sale, in extremely good condition.', ) // → Release Notes 2.0.0 (Object): An object with a ratings property, which gives a similarity rating for each target string, a bestMatch property, which specifies which target string was most similar to the main string, and a bestMatchIndex property, which specifies the index of the bestMatch in the targetStrings array. targetStrings (Array): Each string in this array will be matched against the main string.mainString (string): The string to match each target string against.compareTwoStrings ( "Olive-green table for sale, in extremely good condition.", "Wanted: mountain bike with at least 21 gears." ) // → 0.1411764705882353 findBestMatch(mainString, targetStrings)Ĭompares mainString against each string in targetStrings. compareTwoStrings ( "Olive-green table for sale, in extremely good condition.", "For sale: green Subaru Impreza, 210,000 miles" ) // → 0.2558139534883721 stringSimilarity. compareTwoStrings ( "Olive-green table for sale, in extremely good condition.", "For sale: table in very good condition, olive green in colour." ) // → 0.6060606060606061 stringSimilarity. compareTwoStrings ( "healed", "sealed" ) // → 0.8 stringSimilarity. (number): A fraction from 0 to 1, both inclusive.

string similarity

0 indicates completely different strings, 1 indicates identical strings. Returns a fraction between 0 and 1, which indicates the degree of similarity between the two strings. The package contains two methods: compareTwoStrings(string1, string2)

string similarity

(The package is exposed as UMD, so you can consume it as such) API This exposes a global variable called stringSimilarity which you can start using. Or to get a specific version (4.0.1) in this case. findBestMatch ( "healed", ) For browser apps compareTwoStrings ( "healed", "sealed" ) var matches = stringSimilarity. Var stringSimilarity = require ( "string-similarity" ) var similarity = stringSimilarity.















String similarity