本文整理汇总了C++中TermList::add方法的典型用法代码示例。如果您正苦于以下问题:C++ TermList::add方法的具体用法?C++ TermList::add怎么用?C++ TermList::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TermList
的用法示例。
在下文中一共展示了TermList::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSynonym
bool CommonLanguageAnalyzer::getSynonym(
const UString& combine,
int offset,
const unsigned char andOrBit,
const unsigned int level,
TermList& syOutList,
unsigned int& subLevel)
{
bool ret = false;
//cout << "combined: "; combine.displayStringValue(izenelib::util::UString::UTF_8); cout << endl;
char* combineStr = lowercase_string_buffer_;
UString::convertString(UString::UTF_8, combine.c_str(), combine.length(), lowercase_string_buffer_, term_string_buffer_limit_);
//cout << "combined string: " << string(combineStr) << endl;
UString::CharT * synonymResultUstr = NULL;
size_t synonymResultUstrLen = 0;
pSynonymContainer_ = uscSPtr_->getSynonymContainer();
pSynonymContainer_->searchNgetSynonym(combineStr, pSynonymResult_);
for (int i =0; i<pSynonymResult_->getSynonymCount(0); i++)
{
char * synonymResult = pSynonymResult_->getWord(0, i);
if (synonymResult)
{
if (strcmp(combineStr, synonymResult) == 0)
{
//cout << "synonym self: "<<string(synonymResult) <<endl;
continue;
}
cout << "synonym : "<<string(synonymResult) <<endl;
ret = true;
size_t synonymResultLen = strlen(synonymResult);
if (synonymResultLen <= term_ustring_buffer_limit_)
{
synonymResultUstr = synonym_ustring_buffer_;
synonymResultUstrLen = UString::toUcs2(synonymEncode_,
synonymResult, synonymResultLen, synonym_ustring_buffer_, term_ustring_buffer_limit_);
}
// word segmentment
UString term(synonymResultUstr, synonymResultUstrLen);
TermList termList;
if (innerAnalyzer_.get())
{
innerAnalyzer_->analyze(term, termList);
if (termList.size() <= 1)
{
syOutList.add(synonymResultUstr, synonymResultUstrLen, offset, NULL, andOrBit, level+subLevel);
subLevel++;
}
else
{
for (TermList::iterator iter = termList.begin(); iter != termList.end(); ++iter)
{
syOutList.add(iter->text_.c_str(), iter->text_.length(), offset, NULL, Term::AND, level+subLevel);
}
subLevel++;
}
}
else
{
syOutList.add(synonymResultUstr, synonymResultUstrLen, offset, NULL, andOrBit, level+subLevel);
subLevel++;
}
}
}
return ret;
}