/*
* Function checking if a sentence in Present Simple contains a time-marker of type:
* adverb of manner, ex. usually, always.
*
*/

module.exports = function (ruleManager, sentence, result) {

    if (!ruleManager || !result || !result.tokenIndices || result.tokenIndices.length < 2 || !sentence) {
        debugger;
        console.error("inputs are wrong");
        return false;
    }

    if (result.tokenRules.length < 1) {
        return false;
    }

    var dico = ruleManager.dictionaries.PresentSimple_time_markers;

    if (!dico) {
        debugger;
        return false;
    }

    if (result.tokenIndices.length > 2){
        for (let ti = 1; ti < result.tokenIndices.length; ti++) {
            let token = sentence.tokens[result.tokenIndices[ti]];
            if (token.pos == "RB") {
                let adverb = token.lemma;
                for (var key in dico) {
                    if (adverb === key){
                        console.log("adverb " + adverb + " est present");
                        return true;
                        ti = result.tokenIndices.length;
                        break;
                    }
                }
            }
        }
    }
    else{
        console.log("adverbe n'est pas present");
        return false;
    }
    
}