compromise
Version:
natural language processing in the browser
22 lines (20 loc) • 463 B
JavaScript
;
const words = require('./data')
//prevent things like 'fifteen ten', and 'five sixty'
const isValid = (w, has) => {
if (words.ones[w]) {
if (has.ones || has.teens) {
return false;
}
} else if (words.teens[w]) {
if (has.ones || has.teens || has.tens) {
return false;
}
} else if (words.tens[w]) {
if (has.ones || has.teens || has.tens) {
return false;
}
}
return true;
};
module.exports = isValid