本文整理汇总了C++中TermList::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TermList::getSize方法的具体用法?C++ TermList::getSize怎么用?C++ TermList::getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TermList
的用法示例。
在下文中一共展示了TermList::getSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Index
void IndexContentTestCase::testIndexContent_DL0()
{
Index* pIndex;
IndexReaderPtr pReader;
const Term* pTerm;
TermIteratorPtr pTermIter;
int docCount = 0;
uint32_t i;
uint32_t indexTermId;
string fileName;
//Check posting list
Path indexPath = TestHelper::getTestDataPath();
indexPath.makeDirectory();
indexPath.pushDirectory(_T("test_dl0index"));
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();
TermPostingIteratorPtr pTermDocFreqs = pTermReader->termPostings();
docCount = 0;
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; i < pTermIdList->getSize(); i++)
{
if(indexTermId == pTermIdList->getValue(i))
{
break;
}
}
CPPUNIT_ASSERT(i < pTermIdList->getSize());//源文档中是否存在该词
}//end while nextDoc()
CPPUNIT_ASSERT_EQUAL((df_t)docCount, pTermDocFreqs->getDocFreq());//测DF
}
CPPUNIT_ASSERT_EQUAL((int64_t)m_pDocScanner->getTotalTermCount(),
pReader->getNumTerms());//CTF
}