Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function test(err, results) {
t.error(err);
t.equal(typeof results, 'object');
t.equal(typeof results[0], 'object');
t.equal(typeof results[0].result, 'object');
var sentence = _.reduce(results, combine, '');
var distance = natural.JaroWinklerDistance(sentence, text);
t.equal(distance >= opts.accuracy, true);
};
return true
//if search has no uppercased letters, it'll be case insensitive
let smartcase = !/[A-Z]+/.test(search)
if(isGlob(search)) {
return mm(path.path, search.split(' '), {matchBase: true, nocase: smartcase}).length > 0
}
if(smartcase) {
name = name.toLowerCase()
}
name = sanitize(name)
if(natural.JaroWinklerDistance(name, search) > options.maxScore) {
return true
}
return false
}
}
function checkMatch(element, index, words) {
return natural.JaroWinklerDistance(word,element) > 0.8;
}
.reduce((bestHotword, hotword) => {
const distance = JaroWinklerDistance(switchName, hotword);
if (!bestHotword || distance > bestHotword.distance) {
return {
distance,
hotword
};
}
return bestHotword;
}, null);
_.forEach(this.features, (prop, name) => {
let delta = 0;
if (node.features[name] && _node.features[name] && (typeof node.features[name] === 'number') && (typeof _node.features[name] === 'number') && (this.features[name].range !== 0)) {
let difference = 0;
if (_node.features[name] > node.features[name]) difference = _node.features[name] - node.features[name]
else if (node.features[name] > _node.features[name]) difference = node.features[name] - _node.features[name]
delta = difference / (prop.max - prop.min);
let feature = Math.sqrt(delta * delta);
features.push(feature);
}
else if (node.features[name] && _node.features[name] && (typeof node.features[name] === 'string') && (typeof _node.features[name] === 'string') && (this.features[name].range !== 0)) {
if (this.stringAlgorithm === 'Jaro-Winkler') delta = natural.JaroWinklerDistance(node.features[name], _node.features[name]);
if (this.stringAlgorithm === 'Levenshtein') delta = natural.LevenshteinDistance(node.features[name], _node.features[name]);
if (this.stringAlgorithm === 'Dice') delta = natural.DiceCoefficient(node.features[name], _node.features[name]);
let feature = Math.sqrt(delta * delta);
features.push(feature);
}
});
arc.distance = features.length > 1 ? features.reduce((x, y) => x + y) : features[0];
.reduce((best, switchConfig) => {
if (!switchConfig.hotwords) {
const distance = JaroWinklerDistance(switchName, switchConfig.id);
if (!best || distance > best.distance) {
return {
distance,
hotword: switchConfig.id,
config: switchConfig
};
}
return best;
}
const result = switchConfig.hotwords
.reduce((bestHotword, hotword) => {
const distance = JaroWinklerDistance(switchName, hotword);
if (!bestHotword || distance > bestHotword.distance) {
(bestHotword, hotword) => {
const distance = JaroWinklerDistance(switchName, hotword);
if (!bestHotword || distance > bestHotword.distance) {
return {
distance,
hotword
};
}
return bestHotword;
},
null
(best, switchConfig) => {
if (!switchConfig.hotwords) {
const distance = JaroWinklerDistance(switchName, switchConfig.id);
if (!best || distance > best.distance) {
return {
distance,
hotword: switchConfig.id,
config: switchConfig
};
}
return best;
}
const result = switchConfig.hotwords.reduce(
(bestHotword, hotword) => {
const distance = JaroWinklerDistance(switchName, hotword);
if (!bestHotword || distance > bestHotword.distance) {