当前位置: 首页>>代码示例>>C++>>正文


C++ Sentence::GetPremise方法代码示例

本文整理汇总了C++中Sentence::GetPremise方法的典型用法代码示例。如果您正苦于以下问题:C++ Sentence::GetPremise方法的具体用法?C++ Sentence::GetPremise怎么用?C++ Sentence::GetPremise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentence的用法示例。


在下文中一共展示了Sentence::GetPremise方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: askOr

bool KnowLedgeBasedAgent::askOr(string query, vector<string>& theta)
{
    Predicate p = TextParser::GetPredicate(query);
    if (predicateMap.find(p.name) != predicateMap.end())
    {
        vector<int>rules = predicateMap[p.name];
        bool flag = false;
        for (int ruleIterator = 0; ruleIterator < rules.size(); ruleIterator++)
        {
            Sentence sentence = KnowledgeBase[rules[ruleIterator]-1];
            vector<string> premise = sentence.GetPremise();
            string conclusion = sentence.GetConclusion();
            Predicate q = TextParser::GetPredicate(conclusion);
            string substitution = "";
            bool unificationResult = Unify(p, q, substitution);
            if (!unificationResult) continue;
            if (find(theta.begin(), theta.end(), substitution) == theta.end())
            {
                theta.push_back(*new string(substitution));
            }
            bool validity = askAnd(premise, theta);
            if (validity) flag = true;
            else flag = false;
        }
        if(flag) return true;
        else return false;
    }
    else return false;
}
开发者ID:Warun26,项目名称:LogicInference,代码行数:29,代码来源:KnowledgeBasedAgent.cpp

示例2: Tell

void KnowLedgeBasedAgent::Tell(string percept)
{
    t = t+1;
    Sentence sentence = MakePerceptSentence(percept);
    KnowledgeBase.push_back(sentence);
    Predicate conclusion = TextParser::GetPredicate(sentence.GetConclusion());
    if (predicateMap.find(conclusion.name) == predicateMap.end())
    {
        vector<int> conclusionId;
        conclusionId.push_back(t);
        predicateMap[conclusion.name] = conclusionId;
        if (conclusion.arg1[0] != 'x' && find(constants.begin(), constants.end(), conclusion.arg1) == constants.end())
            constants.push_back(conclusion.arg1);
        if (conclusion.arg2[0] != 'x' && find(constants.begin(), constants.end(), conclusion.arg2) == constants.end())
            constants.push_back(conclusion.arg2);
        }
    else
    {
        (predicateMap[conclusion.name]).push_back(t);
        if (conclusion.arg1[0] != 'x' && find(constants.begin(), constants.end(), conclusion.arg1) == constants.end())
            constants.push_back(conclusion.arg1);
        if (conclusion.arg2[0] != 'x' && find(constants.begin(), constants.end(), conclusion.arg2) == constants.end())
            constants.push_back(conclusion.arg2);
    }
    vector<string> premises = sentence.GetPremise();
    for (int i=0; i<premises.size(); i++)
    {
        Predicate premise = TextParser::GetPredicate(premises[i]);
        if (premise.arg1[0] != 'x' && find(constants.begin(), constants.end(), premise.arg1) == constants.end())
            constants.push_back(premise.arg1);
        if (premise.arg2[0] != 'x' && find(constants.begin(), constants.end(), premise.arg2) == constants.end())
            constants.push_back(premise.arg2);
    }
}
开发者ID:Warun26,项目名称:LogicInference,代码行数:34,代码来源:KnowledgeBasedAgent.cpp


注:本文中的Sentence::GetPremise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。