by cabirum · 11y ago · 0 comments
var probablyWrong = ["doubl", "expon", "multipl", "^", "", "power", "two", "2", "twice", "as big", "nth", "rais"];
var seemsRight = ["larger", "increas", "greater", "small", "less", "big", ">", "<", "go up", "ascending"], weaselWords = ['but ', 'not ', 'odd'];
Been expecting something more interesting than that
function judgeSentence(sentence, numNo) {
sentence = sentence.toLowerCase();
// no nos -> wrong.
if (numNo === 0 || sentence == "") {
return false;
}
// if have any fancy words -> wrong.
var probablyWrong = ["doubl", "expon", "multipl", "^", "**", "power", "two", "2", "twice", "as big", "nth", "rais"];
if (hasAny(probablyWrong, sentence)) {
return false;
}
// if you have the right words, and no buts.
var seemsRight = ["larger", "increas", "greater", "small", "less", "big", ">", "<", "go up", "ascending"],
weaselWords = ['but ', 'not ', 'odd'];
if (hasAny(seemsRight, sentence) & !hasAny(weaselWords, sentence)) {
return true;
}
// // no nouns, verbs or adjectives in your sentence -> wrong.
// var s = nlp.pos(sentence).sentences[0],
// verbs = s.verbs().map(getWords),
// nouns = s.nouns().map(getWords),
// adj = s.adjectives().map(getWords),
// numWords = verbs.length + nouns.length + adj.length;
// if (numWords === 0) {
// return false;
// }
return false;
}What is surprising is how basically 15 lines of python implementing these rules, invokes a very real emotional response in a lot of people :-)
I named it "Wilhelm".
[0] inspired by this comic http://gunshowcomic.com/513
The sequence is not monotonically increasing.
It only means non-decreasing in the context of a monotonic function, where the definition, I believe, is that the derivative of the function is never <0.