当前位置: 首页>>代码示例>>C++>>正文


C++ TermList::addTerm方法代码示例

本文整理汇总了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!");
	}

}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:31,代码来源:fotableau.cpp

示例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();
		}
	}
}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:39,代码来源:fotableau.cpp

示例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;
}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:19,代码来源:fotableau.cpp

示例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();
//.........这里部分代码省略.........
开发者ID:busjaeger,项目名称:cs410sp12,代码行数:101,代码来源:IndexWriter.cpp


注:本文中的TermList::addTerm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。