本文整理汇总了C++中Relation::complement_place方法的典型用法代码示例。如果您正苦于以下问题:C++ Relation::complement_place方法的具体用法?C++ Relation::complement_place怎么用?C++ Relation::complement_place使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relation
的用法示例。
在下文中一共展示了Relation::complement_place方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mapRelation
Relation mapRelation(map<string,string> dico, Relation child, Relation current)
{
string newSubject = child.subject();
map<string,string>::iterator place = dico.find(newSubject);
if (place != dico.end() )
newSubject = place->second;
string newObject =child.object();
place = dico.find(newObject);
if (place != dico.end() )
newObject = place->second;
string newVerb = child.verb();
//place = dico.find(newVerb);
//if (place != dico.end() )
// newVerb = place->second;
string newCTime = child.complement_time();
place = dico.find(newCTime);
if (place != dico.end() )
newCTime = place->second;
string newCManner = child.complement_manner();
place = dico.find(newCManner);
if (place != dico.end() )
newCManner = place->second;
string newCPlace = child.complement_place();
place = dico.find(newCPlace);
if (place != dico.end() )
newCPlace = place->second;
return Relation(newSubject,newVerb,newObject,newCPlace,newCTime,newCManner);
}
示例2: containsRelation
bool OPCClient::containsRelation(Relation r)
{
Entity* subject = getEntity(r.subject());
Entity* object = getEntity(r.object());
Entity* cPlace = getEntity(r.complement_place());
Entity* cTime = getEntity(r.complement_time());
Entity* cManner = getEntity(r.complement_manner());
Entity* verb = getEntity(r.verb());
return containsRelation(subject,verb,object,cPlace,cTime,cManner);
}
示例3: addRelation
//Adds a relation between 2 entities
bool OPCClient::addRelation(Relation r, double lifeTime)
{
Entity* subject = getEntity(r.subject());
Entity* object = getEntity(r.object());
Entity* cPlace = getEntity(r.complement_place());
Entity* cTime = getEntity(r.complement_time());
Entity* cManner = getEntity(r.complement_manner());
Entity* verb = getEntity(r.verb());
if (subject == NULL || verb == NULL)
{
cerr<<"Verb and subject should exist before you try to add a relation"<<endl;
return false;
}
return addRelation(subject,verb,object,lifeTime,cPlace,cTime,cManner);
}
示例4: express
Action Action::express(Relation r)
{
Action a;
string initial = this->asBottle().toString().c_str();
string final = initial.c_str();
replace_all(final,this->initialDescription.subject().c_str(),"___subject");
replace_all(final,this->initialDescription.object().c_str(),"___object");
replace_all(final,this->initialDescription.complement_time().c_str(),"___compTime");
replace_all(final,this->initialDescription.complement_place().c_str(),"___compPlace");
replace_all(final,this->initialDescription.complement_manner().c_str(),"___compManner");
replace_all(final,"___subject", r.subject());
replace_all(final,"___object", r.object());
replace_all(final,"___compTime", r.complement_time());
replace_all(final,"___compPlace", r.complement_place());
replace_all(final,"___compManner", r.complement_manner());
Bottle b(final.c_str());
a.fromBottle(b);
return a;
}
示例5: handleSpeech
bool AdaptiveLayer::handleSpeech()
{
bool gotSignal = false;
Bottle* speechCmd = iCub->getSpeechClient()->STT(false);
if (speechCmd)
{
if (speechCmd->size() != 2)
{
std::cout << "in adaptativeLayer::handleSpeech | error: bottle received size !=2" << std::endl;
return false;
}
gotSignal = true;
std::cout << speechCmd->toString() << std::endl;
std::cout << speechCmd->toString() << std::endl;
cout<<"Raw sentence: |"<<speechCmd->get(0).toString()<<"|"<<endl;
//cout<<"Semantic:"<<speechCmd->get(1).toString();
Bottle* semanticBottle = speechCmd->get(1).asList();
string sentenceType = semanticBottle->get(0).asString();
if (sentenceType == "SUBNODE")
{
Bottle keyBot;
keyBot.addString(semanticBottle->get(1).asList()->check("keyword",Value("none")).asString());
pSpeechRecognizerKeywordOut.write(keyBot);
return true;
}
if (sentenceType == "miscSentences")
{
string rawSentence = speechCmd->get(0).toString();
cout<<"Catched a misc sentence : "<<semanticBottle->toString().c_str()<<endl;
return true;
}
//We trigger a scenario from speech
if (sentenceType == "GAME")
{
Bottle keyBot;
string gameName = semanticBottle->get(1).asList()->find("gameName").asString();
return true;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
//Create a relation for information exchange
Bottle bRelation;
Relation relationForm = this->getRelationFromSemantic(*semanticBottle->get(1).asList());
cout<< "Sentence type : "<<sentenceType<<endl;
cout<< "Relation form : "<<relationForm.toString()<<endl;
string answerFromRobot = "";
if (sentenceType == "IMPERATIVE")
{
//Execute the action
}
else if (sentenceType == "AFFIRMATIVE")
{
if (!iCub->opc->containsRelation(relationForm))
{
iCub->opc->addRelation(relationForm);
answerFromRobot = "Ok, I will know that " + relationForm.toString();
}
else
{
answerFromRobot = "I already knew that.";
}
//Update the other model to reflect his knowledge
Agent* partner = dynamic_cast<Agent*>(iCub->opc->getEntity("partner"));
partner->addBelief(relationForm);
iCub->opc->commit(partner);
}
else //interrogative
{
if (sentenceType == "INTERROGATIVE_WHO")
relationForm.m_subject = "?";
if (sentenceType == "INTERROGATIVE_WHAT")
relationForm.m_object = "?";
if (sentenceType == "INTERROGATIVE_WHEN")
relationForm.m_complement_time = "?";
if (sentenceType == "INTERROGATIVE_WHERE")
relationForm.m_complement_place = "?";
if (sentenceType == "INTERROGATIVE_HOW")
relationForm.m_complement_manner = "?";
Relation relationReturn(relationForm);
//Retrieve from OPC
string matchingSubject;
string matchingObject;
string matchingVerb;
string matchingPlace;
string matchingTime;
string matchingManner;
relationForm.subject() != "?" && relationForm.subject() != "none" ? matchingSubject = relationForm.subject() : matchingSubject = "any";
relationForm.verb() != "?" && relationForm.verb() != "none" ? matchingVerb = relationForm.verb() : matchingVerb = "any";
relationForm.object() != "?" && relationForm.object() != "none" ? matchingObject = relationForm.object() : matchingObject = "any";
relationForm.complement_place() != "?" && relationForm.complement_place() != "none" ? matchingPlace = relationForm.complement_place() : matchingPlace = "any" ;
relationForm.complement_time() != "?" && relationForm.complement_time() != "none" ? matchingTime = relationForm.complement_time() : matchingTime = "any" ;
//.........这里部分代码省略.........