Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Full method just for fun:

    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;
    }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: