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