本文整理汇总了C++中TermList::addTerm方法的典型用法代码示例。如果您正苦于以下问题:C++ TermList::addTerm方法的具体用法?C++ TermList::addTerm怎么用?C++ TermList::addTerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TermList
的用法示例。
在下文中一共展示了TermList::addTerm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formulaTest
void formulaTest()
{
TermList *list = new TermList();
list->addTerm(new Term(Term::VAR, "x"));
list->addTerm(new Term(Term::VAR, NULL));
list->addTerm(new Term(Term::CONS, "A"));
Formula *f = new Formula(new Predicate("P", list));
Formula *g = new Formula(f);
Formula *q = new Formula(f, g, '&');
Formula *r = new Formula(new Term(Term::VAR, NULL), q, Formula::UNIV);
r->print();
Term *x = new Term(Term::VAR, "xy");
Term *y = new Term(Term::VAR, "x");
TermList *list2 = new TermList();
list2->addTerm(x);
list2->addTerm(y);
Term *f2 = new Term("f10", list2);
Term *g2 = new Term("f10", list2);
f2->print();
puts("");
g2->print();
puts("");
if (!(*f2 != *g2)) {
printf("yes! equal!");
}
}
示例2: testTerms
/*
===================================================
End of Prover
===================================================
*/
void testTerms()
{
int n;
int m;
int type;
char name[10];
for (int i = 0; i < 5; i++) {
printf("type and Name: ");
scanf("%d %s", &type, name);
if(type == Term::FUNC) {
TermList *list = new TermList();
Term term(name, list);
printf("place: ");
scanf("%d", &m);
for (int j = 0; j < m; ++j) {
printf("%dth term: ",j);
scanf("%s", name);
Term *term = new Term(Term::VAR, name);
list->addTerm(term);
}
term.print();
}
else {
Term term(type, name);
term.print();
}
}
}
示例3: parseTermList
TermList* Parser::parseTermList()
{
TermList *list = NULL;
while(isspace(*p)) p++;
if (*p == '(') {
list = new TermList();
while (*p && *p != ')') {
if (isalpha(*p)) {
Term *t = this->parseTerm();
list->addTerm(t);
p--;
}
p++;
}
if (*p == ')') p++;
}
return list;
}
示例4: _writeDirectLists
void IndexWriter::_writeDirectLists( WriterIndexContext* context,
indri::file::SequentialWriteBuffer* directOutput,
indri::file::SequentialWriteBuffer* lengthsOutput,
indri::file::SequentialWriteBuffer* dataOutput ) {
VocabularyIterator* vocabulary = context->index->frequentVocabularyIterator();
indri::index::Index* index = context->index;
vocabulary->startIteration();
while( !vocabulary->finished() ) {
indri::index::DiskTermData* diskTermData = vocabulary->currentEntry();
context->oldFrequent->add( diskTermData->termID, diskTermData->termData->term );
vocabulary->nextEntry();
}
delete vocabulary;
vocabulary = 0;
TermListFileIterator* iterator = index->termListFileIterator();
TermTranslator* translator = _buildTermTranslator( _infrequentTermsReader,
_frequentTermsReader,
*context->oldFrequent,
context->oldInfrequent,
*context->newlyFrequent,
index,
context->bitmap );
iterator->startIteration();
TermList writeList;
indri::utility::Buffer outputBuffer( 256*1024 );
indri::index::DocumentDataIterator* dataIterator = context->index->documentDataIterator();
dataIterator->startIteration();
while( !iterator->finished() ) {
writeList.clear();
TermList* list = iterator->currentEntry();
assert( list );
int currentTerm;
int translated;
// copy and translate terms
for( int i=0; i<list->terms().size(); i++ ) {
currentTerm = list->terms()[i];
assert( currentTerm >= 0 );
assert( currentTerm <= index->uniqueTermCount() );
translated = (*translator)( currentTerm );
assert( translated > 0 || (translated == 0 && currentTerm == 0) );
writeList.addTerm( translated );
}
// copy field data
int fieldCount = list->fields().size();
const indri::utility::greedy_vector<indri::index::FieldExtent>& fields = list->fields();
for( int i=0; i<fieldCount; i++ ) {
writeList.addField( fields[i] );
}
// record the start position
size_t writeStart = outputBuffer.position();
UINT32 length = 0;
// write the list, leaving room for a length count
outputBuffer.write( sizeof(UINT32) );
writeList.write( outputBuffer );
// record the end position, compute length
size_t writeEnd = outputBuffer.position();
length = writeEnd - (writeStart + sizeof(UINT32));
// store length
assert( outputBuffer.position() >= (sizeof(UINT32) + length + writeStart) );
memcpy( outputBuffer.front() + writeStart, &length, sizeof(UINT32) );
assert( dataIterator );
// get a copy of the document data
assert( dataIterator );
assert( !dataIterator->finished() );
indri::index::DocumentData documentData = *dataIterator->currentEntry();
// store offset information
documentData.byteLength = length;
documentData.offset = directOutput->tell() + writeStart + sizeof(UINT32);
// tell has to happen before a write or the offset will be wrong.
if( outputBuffer.position() > 128*1024 ) {
directOutput->write( outputBuffer.front(), outputBuffer.position() );
outputBuffer.clear();
}
dataOutput->write( &documentData, sizeof(DocumentData) );
int termLength = documentData.totalLength;
assert( termLength >= 0 );
lengthsOutput->write( &termLength, sizeof(UINT32) );
iterator->nextEntry();
//.........这里部分代码省略.........