|
|
@ -1,5 +1,7 @@
|
|
|
|
const fs = require('fs');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const commands = module.exports = {};
|
|
|
|
|
|
|
|
|
|
|
|
// Compute the edit distance between the two given strings
|
|
|
|
// Compute the edit distance between the two given strings
|
|
|
|
function getEditDistance(sourceString, targetString) {
|
|
|
|
function getEditDistance(sourceString, targetString) {
|
|
|
|
if (sourceString.length === 0) return targetString.length;
|
|
|
|
if (sourceString.length === 0) return targetString.length;
|
|
|
@ -53,8 +55,8 @@ function fetchCommand(input, commands, threshhold){
|
|
|
|
return candidates;
|
|
|
|
return candidates;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports.fetchCommand = fetchCommand;
|
|
|
|
commands.fetchCommand = fetchCommand;
|
|
|
|
module.exports.getEditDistance = getEditDistance;
|
|
|
|
commands.getEditDistance = getEditDistance;
|
|
|
|
|
|
|
|
|
|
|
|
fs.readdirSync('./projects').forEach((file) => {
|
|
|
|
fs.readdirSync('./projects').forEach((file) => {
|
|
|
|
let project = file.match(/^([a-z]*)\.js$/);
|
|
|
|
let project = file.match(/^([a-z]*)\.js$/);
|
|
|
@ -64,7 +66,7 @@ fs.readdirSync('./projects').forEach((file) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
project = project[1];
|
|
|
|
project = project[1];
|
|
|
|
|
|
|
|
|
|
|
|
module.exports[project] = require('./projects/' + file);
|
|
|
|
commands[project] = require('./projects/' + file);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/* //Test code
|
|
|
|
/* //Test code
|
|
|
|