本文整理汇总了C++中TermList类的典型用法代码示例。如果您正苦于以下问题:C++ TermList类的具体用法?C++ TermList怎么用?C++ TermList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TermList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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;
}
示例3: input
void
Term::inputsToList(TermList& out)
{
out.resize(numInputs());
for (int i=0; i < numInputs(); i++)
out.setAt(i, input(i));
}
示例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;
}
示例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);
}
}
}
示例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!");
}
}
示例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();
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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];
}
示例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);
}
示例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);
}
示例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