Как использовать свойство оценок в модуле сходства строк в JavaScript? - PullRequest
0 голосов
/ 18 мая 2019

Я хочу использовать значение ratings в результате использования модуля сходства строк для использования, подобного этому

Мой код

var stringSimilarity = require('string-similarity');

var matches = 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.'
]);
var target = matches.bestMatch.target;
console.log("Matches : " + JSON.stringify(matches));
console.log("Best matches : " + JSON.stringify(matches.bestMatch));
console.log("Result Best Match target : " + target);

if(ratings > 0.5){
    console.log("Good Match String");
}else{
    console.log("Bad Match String");
}

Мой результат сходства строк

matches:{"ratings":[{"target":"For sale: green Subaru Impreza, 210,000 miles","rating":0.2558139534883721},{"target":"For sale: table in very good condition, olive green in colour.","rating":0.6060606060606061},{"target":"Wanted: mountain bike with at least 21 gears.","rating":0.1411764705882353}],"bestMatch":{"target":"For sale: table in very good condition, olive green in colour.","rating":0.6060606060606061},"bestMatchIndex":1}
best matches:{"target":"For sale: table in very good condition, olive green in colour.","rating":0.6060606060606061}
result bestMatch target:For sale: table in very good condition, olive green in colour.

Я хочу использовать это "rating":0.6060606060606061 для моего условия if в моем коде

...