コード例 #1
0
ファイル: TestRacerNRQL.cpp プロジェクト: hexhex/dlplugin
void
TestRacerNRQL::runRacerRetrieveTest()
{
  std::stringstream sst;

  Tuple tup;
  tup.push_back(Term("X"));
  tup.push_back(Term("Y"));

  AtomSet as;
  AtomPtr ap1(new Atom("foo(X)"));
  AtomPtr ap2(new Atom("moo(X,Y)"));
  as.insert(ap1);
  as.insert(ap2);

  KBManager kb("DEFAULT");
  DLQuery::shared_pointer dlq(new DLQuery(Ontology::createOntology(test),as,tup));
  Query q(kb,dlq,Term(""),Term(""),Term(""),Term(""),AtomSet());

  NRQLRetrieve<NRQLConjunctionBuilder> nrql(q);

  sst << nrql;
     
  std::string s = sst.str();
 
  std::cout << s << std::endl;

  CPPUNIT_ASSERT(s == "(retrieve ($?X $?Y) (and ($?X $?Y |http://www.test.com/test#moo|) ($?X |http://www.test.com/test#foo|)) :abox DEFAULT)");
}
コード例 #2
0
ファイル: TestRacerNRQL.cpp プロジェクト: hexhex/dlplugin
void
TestRacerNRQL::runRacerPremiseRetrieveTest()
{
  std::stringstream sst;

  Tuple tup;
  tup.push_back(Term("X"));
  tup.push_back(Term("Y"));

  AtomSet as;
  AtomPtr ap1(new Atom("foo(X)"));
  AtomPtr ap2(new Atom("moo(X,Y)"));
  as.insert(ap1);
  as.insert(ap2);

  AtomSet ints;
  AtomPtr ap4(new Atom("pc(foo,a)"));
  AtomPtr ap5(new Atom("pr(moo,a,b)"));
  ints.insert(ap4);
  ints.insert(ap5);

  KBManager kb("DEFAULT");
  DLQuery::shared_pointer dlq(new DLQuery(Ontology::createOntology(test),as,tup));
  Query q(kb,dlq,Term("pc"),Term(""),Term("pr"),Term(""),ints);

  NRQLRetrieveUnderPremise<NRQLConjunctionBuilder> nrql(q);

  sst << nrql;
     
  std::string s = sst.str();
 
  std::cout << s << std::endl;

  URI u(testuri, true); // absolute pathname
  CPPUNIT_ASSERT(s == "(retrieve-under-premise ((related |http://www.test.com/test#a| |http://www.test.com/test#b| |http://www.test.com/test#moo|) (instance |http://www.test.com/test#a| |http://www.test.com/test#foo|)) ($?X $?Y) (and ($?X $?Y |http://www.test.com/test#moo|) ($?X |http://www.test.com/test#foo|)) :abox |" + u.getString() + "|)");
}
コード例 #3
0
PosAtomSet* PosLogProg::nextPosSmodel(Smodels* smodels){
   if (smodels->model ()){  // Returns 0 when there is no more smodel
	AtomSet atomSet; // the non-possibilistic stable model
	Node* nd = smodels->program.atoms.head();
	for (; nd; nd = nd->next){
	  if (nd->atom->Bpos) {  
	    // The atom is in the stable model
	    AtomExt * ae = (AtomExt*) nd->atom; // cast
            atomSet.insert(ae->getMyAtom());
	  }
	}
	return this->possCn(&atomSet); //the correponding possibilistic stable model
   }
   else 
   	return NULL; // there is no more possibilistic smodel
}