• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TermList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TermList的典型用法代码示例。如果您正苦于以下问题:C++ TermList类的具体用法?C++ TermList怎么用?C++ TermList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TermList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Index

void IndexContentTestCase::testIndexContent_DL()
{
    Index* pIndex;
    IndexReaderPtr pReader;

    const Term* pTerm;
    TermIteratorPtr pTermIter;
    int	docCount = 0;
    int	termCount = 0;
    uint32_t i;
    uint32_t indexTermId;
    string fileName;

    //Check posting list
    Path indexPath = TestHelper::getTestDataPath();
    indexPath.makeDirectory();
    indexPath.pushDirectory(_T("test_dlindex"));    
    pIndex = new Index(indexPath.toString().c_str(), Index::READ, NULL);
    auto_ptr<Index> indexPtr(pIndex);
    pReader = pIndex->acquireReader();
    TermReaderPtr pTermReader = pReader->termReader();

    pTermIter = pTermReader->termIterator("BODY");

    StoredFieldsReaderPtr pDocReader = pReader->createStoredFieldsReader();
    //Iterator all terms
    while(pTermIter->next())
    {
        pTerm = pTermIter->term();
		
        CPPUNIT_ASSERT(pTermReader->seek(pTerm));
				
        indexTermId = (pTerm->cast<int32_t>())->getValue();
        docCount = 0;
        TermPostingIteratorPtr pTermDocFreqs = pTermReader->termPostings();
        while(pTermDocFreqs->nextDoc())
        {
            DocumentPtr pDoc = pDocReader->document(pTermDocFreqs->doc());
            docCount++;
            // 获取文件路径
            fileName.assign(pDoc->getField("PATH")->getValue().c_str());

            TermList* pTermIdList = m_pDocScanner->getTermListOfFile(fileName);
            CPPUNIT_ASSERT(pTermIdList != NULL);

            for(i = 0, termCount = 0; i < pTermIdList->getSize(); i++)
            {
                if(indexTermId == pTermIdList->getValue(i))
                {
                    termCount++;
                }
            }
			
            CPPUNIT_ASSERT_EQUAL((tf_t)termCount, pTermDocFreqs->freq());

        }//end while nextDoc()
        CPPUNIT_ASSERT_EQUAL((df_t)docCount, pTermDocFreqs->getDocFreq());
    }
    CPPUNIT_ASSERT(m_pDocScanner->getTotalTermCount() == pReader->getNumTerms());
}
开发者ID:Web5design,项目名称:firtex2,代码行数:60,代码来源:IndexContentTestCase.cpp


示例2: documentBase

const indri::index::TermList* indri::index::MemoryIndex::termList( lemur::api::DOCID_T documentID ) {
  int documentIndex = documentID - documentBase();
  if( documentIndex < 0 || documentIndex >= (int)_documentData.size() )
    return 0;

  const DocumentData& data = _documentData[documentIndex];
  UINT64 documentOffset = data.offset;
  indri::utility::Buffer* documentBuffer = 0;
  std::list<indri::utility::Buffer*>::const_iterator iter;

  for( iter = _termLists.begin(); iter != _termLists.end(); ++iter ) {
    if( documentOffset < (*iter)->position() ) {
      documentBuffer = (*iter);
      break;
    }

    documentOffset -= (*iter)->position();
  }

  assert( documentBuffer );
  TermList* list = new TermList();

  list->read( documentBuffer->front() + documentOffset, data.byteLength );
  return list;
}
开发者ID:oroszgy,项目名称:sefh,代码行数:25,代码来源:MemoryIndex.cpp


示例3: input

void
Term::inputsToList(TermList& out)
{
    out.resize(numInputs());
    for (int i=0; i < numInputs(); i++)
        out.setAt(i, input(i));
}
开发者ID:andyfischer,项目名称:circa,代码行数:7,代码来源:term.cpp


示例4: analyze_index

    int StemAnalyzer::analyze_index( const TermList & input, TermList & output, unsigned char retFlag )
    {
        string inputstr, stem;
        TermList::const_iterator it;

        Term newTerm;
        TermList::iterator term_it;

        for( it = input.begin(); it != input.end(); it++ )
        {
//            if( retFlag_idx_ & ANALYZE_PRIME_ )
//            {
//                term_it = output.insert( output.end(), *it );
//            }
//            if( (retFlag_idx_ & ANALYZE_SECOND_) == 0 )
//                continue;
//
//
//            it->text_.convertString( inputstr, UString::CP949 );
//            stemmer_.stem( inputstr, stem );
//
//            if( !(retFlag_idx_ & ANALYZE_PRIME_) || inputstr != stem )
//            {
//                term_it = output.insert( output.end(), *it );
//                term_it->text_.assign( stem, UString::CP949 );
//            }
        }
        return 0;
    }
开发者ID:izenecloud,项目名称:ilplib,代码行数:29,代码来源:StemAnalyzer.cpp


示例5: if_block_create_input_placeholders_for_outer_pointers

void if_block_create_input_placeholders_for_outer_pointers(Term* ifCall)
{
    Branch* contents = nested_contents(ifCall);
    TermList outerTerms;

    // Find outer pointers across each case
    for (CaseIterator it(contents); it.unfinished(); it.advance()) {
        list_outer_pointers(nested_contents(it.current()), &outerTerms);
    }

    ca_assert(ifCall->numInputs() == 0);

    // Create input placeholders and add inputs for all outer pointers
    for (int i=0; i < outerTerms.length(); i++) {
        Term* outer = outerTerms[i];

        set_input(ifCall, i, outer);
        Term* placeholder = append_input_placeholder(nested_contents(ifCall));
        rename(placeholder, outer->name);

        // Go through each case and repoint to this new placeholder
        for (CaseIterator it(contents); it.unfinished(); it.advance()) {
            remap_pointers_quick(nested_contents(it.current()), outer, placeholder);
        }
    }
}
开发者ID:levelplane,项目名称:circa,代码行数:26,代码来源:if_block.cpp


示例6: 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


示例7: 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


示例8: analyze_search

    int StemAnalyzer::analyze_search( const TermList & input, TermList & output, unsigned char retFlag )
    {
        string inputstr, stem;
        TermList::const_iterator it;

        //unsigned char       level = 0;
        Term                newTerm;
        TermList::iterator  term_it;

        for( it = input.begin(); it != input.end(); it++ )
        {
//            if( retFlag_sch_ & ANALYZE_PRIME_ )
//            {
//                term_it = output.insert( output.end(), *it );
//                term_it->stats_ = makeStatBit( Term::OR_BIT, level++ );
//            }
//            if( (retFlag_sch_ & ANALYZE_SECOND_) == 0 )
//                continue;
//
//
//            it->text_.convertString( inputstr, UString::CP949 );
//            stemmer_.stem( inputstr, stem );
//
//            if( !(retFlag_sch_ & ANALYZE_PRIME_) || inputstr != stem )
//            {
//                term_it = output.insert( output.end(), newTerm );
//
//                term_it->text_.assign( stem, UString::CP949 );
//                term_it->stats_ = makeStatBit( Term::AND_BIT, level );
//            }
        }
        return 0;
    }
开发者ID:izenecloud,项目名称:ilplib,代码行数:33,代码来源:StemAnalyzer.cpp


示例9:

bool TermList::operator==(TermList &list)
{
	if (this->list->size() != list.getList()->size()) return false;
	for (int i = 0; i < this->list->size(); i++) {
		if (*(this->list->at(i)) != *(list.getList()->at(i))) return false;
	}
	return true;
}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:8,代码来源:fotableau.cpp


示例10: Term

TermList::TermList(TermList &tList)
{
	this->list = new vector<Term*>();
	for (int i = 0; i < tList.getList()->size(); i++) {
		Term *t = new Term(*(tList.getList()->at(i)));
		this->list->push_back(t);
	}
}
开发者ID:syeedibnfaiz,项目名称:Fotableau,代码行数:8,代码来源:fotableau.cpp


示例11: SPACE

void CommonLanguageAnalyzer::analyzeSynonym(TermList& outList, size_t n)
{
    static UString SPACE(" ", izenelib::util::UString::UTF_8);
    TermList syOutList;

    size_t wordCount = outList.size();
    for (size_t i = 0; i < wordCount; i++)
    {
//        cout << "[off]" <<outList[i].wordOffset_<<" [level]"<<outList[i].getLevel() <<" [andor]" <<(unsigned int)(outList[i].getAndOrBit())
//             << "  "<< outList[i].textString()<<endl;

        // find synonym for word(s)
        for (size_t len = 1; (len <= n) && (i+len <= wordCount) ; len++)
        {
            // with space
            bool ret = false;
            unsigned int subLevel = 0;
            UString combine;
            if (len > 1)
            {
                for (size_t j = 0; j < len-1; j++)
                {
                    combine.append(outList[i+j].text_);
                    combine.append(SPACE);
                }
                combine.append(outList[i+len-1].text_);
                ret = getSynonym(combine, outList[i].wordOffset_, Term::OR, outList[i].getLevel(), syOutList, subLevel);
            }

            // without space
            if (!ret)
            {
                combine.clear();
                for (size_t j = 0; j < len; j++)
                    combine.append(outList[i+j].text_);
               ret = getSynonym(combine, outList[i].wordOffset_, Term::OR, outList[i].getLevel(), syOutList, subLevel);
            }

            // adjust
            if (ret)
            {
                outList[i].setStats(outList[i].getAndOrBit(), outList[i].getLevel()+subLevel);
                for (size_t j = 1; j < len; j++)
                {
                    outList[i+j].wordOffset_ = outList[i].wordOffset_;
                    outList[i+j].setStats(outList[i+j].getAndOrBit(), outList[i].getLevel());
                }
                break;
            }
        }

        syOutList.push_back(outList[i]);
    }

    outList.swap(syOutList);
}
开发者ID:izenecloud,项目名称:ilplib,代码行数:56,代码来源:CommonLanguageAnalyzer.cpp


示例12: find_accessor_head_term

Term* find_accessor_head_term(Term* accessor)
{
    TermList chain;
    trace_accessor_chain(accessor, &chain);

    if (chain.length() == 0)
        return NULL;

    return chain[0];
}
开发者ID:mokerjoke,项目名称:circa,代码行数:10,代码来源:selector.cpp


示例13: block_add_pack_state

Term* block_add_pack_state(Block* block)
{
    TermList inputs;
    list_inputs_to_pack_state(block, block->length(), &inputs);

    // Don't create anything if there are no state outputs
    if (inputs.length() == 0)
        return NULL;

    return apply(block, FUNCS.pack_state, inputs);
}
开发者ID:whunmr,项目名称:circa,代码行数:11,代码来源:stateful_code.cpp


示例14: branch_add_pack_state

Term* branch_add_pack_state(Branch* branch)
{
    TermList inputs;
    get_list_of_state_outputs(branch, branch->length(), &inputs);

    // Don't create anything if there are no state outputs
    if (inputs.length() == 0)
        return NULL;

    return apply(branch, FUNCS.pack_state, inputs);
}
开发者ID:mokerjoke,项目名称:circa,代码行数:11,代码来源:stateful_code.cpp


示例15: TRACER

// 28/08/2002 Torrevieja
void Atom::rectify (Substitution& subst, Var& last, VarList& freeVars)
{
  TRACER ("Atom::rectify");

  TermList ts (args());
  ts.rectify (subst, last, freeVars);
  if (ts == args()) { // space-economic version
    return;
  }

  Atom a (functor(),ts);
  *this = a;
} // Atom::rectify
开发者ID:kdgerring,项目名称:sigma,代码行数:14,代码来源:Atom.cpp


示例16: block_update_pack_state_calls

void block_update_pack_state_calls(Block* block)
{
    if (block->stateType == NULL) {
        // No state type, make sure there's no pack_state call.
        // TODO: Handle this case properly (should search and destroy an existing pack_state call)
        return;
    }

    int stateOutputIndex = block->length() - 1 - find_state_output(block)->index;

    for (int i=0; i < block->length(); i++) {
        Term* term = block->get(i);
        if (term == NULL)
            continue;

        if (term->function == FUNCS.pack_state) {
            // Update the inputs for this pack_state call
            TermList inputs;
            list_inputs_to_pack_state(block, i, &inputs);
            set_inputs(term, inputs);
        }

        else if (should_have_preceeding_pack_state(term)) {
            // Check if we need to insert a pack_state call
            Term* existing = term->input(stateOutputIndex);

            if (existing == NULL || existing->function != FUNCS.pack_state) {
                TermList inputs;
                list_inputs_to_pack_state(block, i, &inputs);
                if (inputs.length() != 0) {
                    Term* pack_state = apply(block, FUNCS.pack_state, inputs);
                    move_before(pack_state, term);

                    // Only set as an input for a non-minor block.
                    if (term->nestedContents == NULL || !is_minor_block(term->nestedContents)) {
                        set_input(term, stateOutputIndex, pack_state);
                        set_input_hidden(term, stateOutputIndex, true);
                        set_input_implicit(term, stateOutputIndex, true);
                    }

                    // Advance i to compensate for the term just added
                    i++;
                }
            }
        }
    }
}
开发者ID:whunmr,项目名称:circa,代码行数:47,代码来源:stateful_code.cpp


示例17: as

// normalize the atom
// 29/08/2002 Torrevieja, changed
void Atom::normalize () 
{
  if ( ! isEquality() ) {
    return;
  }

  // equality
  TermList as (args());
  Term l (as.head());
  Term r (as.second());

  if (l.compare(r) == LESS) {
    TermList newAs (r, TermList (l));
    Atom newAtom (functor(), newAs);
    *this = newAtom;
  }
} // Atom::normalize
开发者ID:kdgerring,项目名称:sigma,代码行数:19,代码来源:Atom.cpp


示例18: make_lp

// TODO there's a seriouxx need for refactoring here !
Solution LpsolveAdaptator::getAdmissibleSolution(LinearProblem * lp) {
	lprec *lprec;
	int nbCol = lp->getVariables().size();
	lprec = make_lp(0, nbCol);

	if (lprec == NULL) {
		// TODO raise an exception
	}

	/* set variables name to ease debugging */
	for (int i = 0; i < (int)lp->getVariables().size(); ++i) {
		Variable * var = (lp->getVariables())[i];
		set_col_name(lprec, i+1, var->getNameToChar());
		if (var->isBinary()) {
			set_binary(lprec, i+1, TRUE);
		}
	}

	/* to build the model faster when adding constraints one at a time */
	set_add_rowmode(lprec, TRUE);

	for (int i = 0; i < (int)(lp->getConstraints().size()); ++i) {
		// FIXME there's a bug here but I can't find it
		Constraint c = (Constraint)(lp->getConstraints()[i]);
		TermList terms = c.getTerms();
		int col[terms.size()];
		REAL row[terms.size()];
		int j = 0;
		for (TermList::const_iterator it = terms.begin(); it != terms.end();
				++it, ++j) {
			// TODO check if this is fixed
			col[j] = ((Term)*it).getVariable().getPosition();
			row[j] = ((Term)*it).getCoeff();
		}
		// WARNING the Consraint uses the same operator values than in lp_lib.h
		if (!add_constraintex(lprec, j, row, col, c.getOperator(), c.getBound())) {
			// TODO raise an exception
		}
	}

	/* the objective function requires rowmode to be off */
	set_add_rowmode(lprec, FALSE);

	return getSolution(lprec);
}
开发者ID:falcong,项目名称:portfolio-opti,代码行数:46,代码来源:LpsolveAdaptator.cpp


示例19: while

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


示例20: branch_update_existing_pack_state_calls

void branch_update_existing_pack_state_calls(Branch* branch)
{
    if (branch->stateType == NULL) {
        // No state type, make sure there's no pack_state call.
        // TODO: Handle this case properly (should search and destroy an existing pack_state call)
        return;
    }

    int stateOutputIndex = branch->length() - 1 - find_state_output(branch)->index;

    for (int i=0; i < branch->length(); i++) {
        Term* term = branch->get(i);
        if (term == NULL)
            continue;

        if (term->function == FUNCS.pack_state) {
            // Update the inputs for this pack_state call
            TermList inputs;
            get_list_of_state_outputs(branch, i, &inputs);

            set_inputs(term, inputs);
        }

        if (term->function == FUNCS.exit_point) {
            // Check if we need to insert a pack_state call
            Term* existing = term->input(stateOutputIndex);

            if (existing == NULL || existing->function != FUNCS.pack_state) {
                TermList inputs;
                get_list_of_state_outputs(branch, i, &inputs);
                if (inputs.length() != 0) {
                    Term* pack_state = apply(branch, FUNCS.pack_state, inputs);
                    move_before(pack_state, term);
                    set_input(term, stateOutputIndex + 1, pack_state);

                    // Advance i to compensate for the term just added
                    i++;
                }
            }
        }
    }
}
开发者ID:mokerjoke,项目名称:circa,代码行数:42,代码来源:stateful_code.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Terminal类代码示例发布时间:2022-05-31
下一篇:
C++ TermInst类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap