hylar/core/Logics/Solver.js
function(rule, kb) {
        var mappingList = this.getMappings(rule, kb), deferred = q.defer(),
            consequences = [], consequence, causes, iterationConsequences;

        this.checkOperators(rule, mappingList);

        try {
            for (var i = 0; i < mappingList.length; i++) {
                if (mappingList[i]) {
                    // Replace mappings on all consequences
                    causes = Logics.buildCauses(mappingList[i].__facts__);
                    iterationConsequences = [];
                    for (var j = 0; j < rule.consequences.length; j++) {
                        consequence = this.substituteFactVariables(mappingList[i], rule.consequences[j], causes, rule);
                        //if (Logics.filterKnownOrAlternativeImplicitFact(consequence, kb, resolvedImplicitFacts)) {
                        consequences.push(consequence);
                        iterationConsequences.push(consequence);
                        //}
                    }
                    try {
                        Logics.addConsequences(mappingList[i].__facts__, iterationConsequences);
                    } catch(e) {
                        throw "Error when trying to add consequences on the implicit fact.";
                    }
                }
            }
            deferred.resolve(consequences);
        } catch(e) {
            deferred.reject(e);
        }

        return deferred.promise;
    }
function(rule, kb) {
        var mappingList = this.getMappings(rule, kb), deferred = q.defer(),
            consequences = [], consequence, causes, iterationConsequences;

        this.checkOperators(rule, mappingList);

        try {
            for (var i = 0; i < mappingList.length; i++) {
                if (mappingList[i]) {
                    // Replace mappings on all consequences
                    causes = Logics.buildCauses(mappingList[i].__facts__);
                    iterationConsequences = [];
                    for (var j = 0; j < rule.consequences.length; j++) {
                        consequence = this.substituteFactVariables(mappingList[i], rule.consequences[j], causes, rule);
                        //if (Logics.filterKnownOrAlternativeImplicitFact(consequence, kb, resolvedImplicitFacts)) {
                        consequences.push(consequence);
                        iterationConsequences.push(consequence);
                        //}
                    }
                    try {
                        Logics.addConsequences(mappingList[i].__facts__, iterationConsequences);
                    } catch(e) {
                        throw "Error when trying to add consequences on the implicit fact.";
                    }
                }
            }
            deferred.resolve(consequences);
        } catch(e) {
            deferred.reject(e);
        }

        return deferred.promise;
    }
function ( rule , kb ) { var mappingList = this . getMappings ( rule , kb ) , deferred = q . defer ( ) , consequences = [ ] , consequence , causes , iterationConsequences ; this . checkOperators ( rule , mappingList ) ; try { for ( var i = 0 ; i < mappingList . length ; i ++ ) { if ( mappingList [ i ] ) { // Replace mappings on all consequences causes = Logics . buildCauses ( mappingList [ i ] . __facts__ ) ; iterationConsequences = [ ] ; for ( var j = 0 ; j < rule . consequences . length ; j ++ ) { consequence = this . substituteFactVariables ( mappingList [ i ] , rule . consequences [ j ] , causes , rule ) ; //if (Logics.filterKnownOrAlternativeImplicitFact(consequence, kb, resolvedImplicitFacts)) { consequences . push ( consequence ) ; iterationConsequences . push ( consequence ) ; //} } try { Logics . addConsequences ( mappingList [ i ] . __facts__ , iterationConsequences ) ; } catch ( e ) { throw "Error when trying to add consequences on the implicit fact." ; } } } deferred . resolve ( consequences ) ; } catch ( e ) { deferred . reject ( e ) ; } return deferred . promise ; }
Evaluates a rule over a set of facts through
restriction of the rule's causes with tagging.
@param rule
@param kb
@returns {Array}
Evaluates a rule over a set of facts through restriction of the rule s causes with tagging .