示例#1
0
void DragonsKnowledgeBase::TellDragonExists(const std::string &name)
{
  /* tell ((G_A & R_A) | ((!G_A) & (!R_A))) <=> T_A
   * tell ((G_A & (!R_A)) | ((!G_A) & R_A)) <=> (!T_A) */

  // Truth teller rule.
  std::sprintf(buf, "((G_%s & R_%s) | ((!G_%s) & (!R_%s))) <=> T_%s",
               name.c_str(), name.c_str(), name.c_str(), name.c_str(),
	       name.c_str());
  AddSentence(buf);
  // Not a truth teller rule.
  std::sprintf(buf, "((G_%s & (!R_%s)) | ((!G_%s) & R_%s)) <=> (!T_%s)",
               name.c_str(), name.c_str(), name.c_str(), name.c_str(),
	       name.c_str());
  AddSentence(buf);
}
示例#2
0
bool nuiTranslator::LoadLanguage(nglIStream* pStream)
{
  nuiCSV csv(_T(','));
  bool res = csv.Load(pStream);
  
  if (!res)
    return false;
    
  const std::vector<std::vector<nglString> >& rDoc(csv.GetDocument());
  
  uint32 count = 0;
  
  for (uint32 i = 0; i < rDoc.size(); i++)
  {
    const std::vector<nglString>& rLine(rDoc[i]);
    if (rLine.size() >= 3)
    {
      AddSentence(rLine[0], rLine[1], rLine[2]);
      count++;
    }
  }
  
  NGL_OUT(_T("Loaded %d translated sentences from %d lines\n"), count, rDoc.size());
  
  return true;
}
示例#3
0
void DragonsKnowledgeBase::TellDragonSays(const std::string &name,
                                          const std::string &sentence)
{
  /* tell T_A <=> (!R_B) */
  std::sprintf(buf, "(T_%s) <=> (%s)",
               name.c_str(), sentence.c_str());
  AddSentence(buf);
}
inline void TTransCorpus::AddSentence(const int& SentId, const TStr& OrgStr, 
        const TStr& TransStr, const TStr& RefTransStr) {

    AddSentence(SentId, OrgStr, TransStr, TStrV::GetV(RefTransStr));
}