mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-06 20:46:50 +08:00
20 lines
636 B
TypeScript
20 lines
636 B
TypeScript
import stringSimilarity = require('string-similarity');
|
|
|
|
stringSimilarity.compareTwoStrings('test', 'test');
|
|
|
|
const match: stringSimilarity.BestMatch = stringSimilarity.findBestMatch('Olive-green table for sale, in extremely good condition.', [
|
|
'For sale: green Subaru Impreza, 210,000 miles',
|
|
'For sale: table in very good condition, olive green in colour.',
|
|
'Wanted: mountain bike with at least 21 gears.'
|
|
]);
|
|
|
|
// ratings accessible
|
|
for (const rating of match.ratings) {
|
|
rating.target; // $ExpectType string
|
|
rating.rating; // $ExpectType number
|
|
}
|
|
|
|
// bestMatch accessible
|
|
match.bestMatch.rating;
|
|
match.bestMatch.target;
|