本文整理汇总了C++中TermList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ TermList::begin方法的具体用法?C++ TermList::begin怎么用?C++ TermList::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TermList
的用法示例。
在下文中一共展示了TermList::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: tag
void POSTaggerEnglish::tag(const TermList & input, TermList & output )
{
std::vector<Token> vt;
TermList::const_iterator it = input.begin();
for(; it != input.end() ; it++)
vt.push_back(Token(it->textString(), "?"));
const multimap<std::string, std::string> dummy;
bidir_decode_beam(vt, dummy, vme_);
output = input;
TermList::iterator it2 = output.begin();
for (size_t i = 0; i < vt.size(); i++,it2++)
{
it2->pos_ = vt[i].prd;
}
}
示例4: getAdmissibleSolution
// 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);
}
示例5: 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;
}