本文整理汇总了C++中lem::MCollect::size方法的典型用法代码示例。如果您正苦于以下问题:C++ MCollect::size方法的具体用法?C++ MCollect::size怎么用?C++ MCollect::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lem::MCollect
的用法示例。
在下文中一共展示了MCollect::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Register
// Ищем в справочнике набор тегов, заданный списком tags. При необходимости
// вносим в БД новую запись. Возвращается ID найденной или созданной записи.
int TagSets::Register( const lem::MCollect< std::pair<int,int> > &tags )
{
if( tags.empty() )
{
return 0;
}
#if defined LEM_THREADS
lem::Process::CritSecLocker lock(&cs);
#endif
// Для устранения вариантов записи одного и того же набора тегов отсортируем элементы по id_tag.
lem::MCollect< std::pair<int,int> > *sorted_tags = new lem::MCollect< std::pair<int,int> >(tags);
std::sort( sorted_tags->begin(), sorted_tags->end(), tags_sorter );
// Такой кортеж есть?
const int i = tag_ptr.find(*sorted_tags);
if( i==UNKNOWN )
{
// Нет.
// Поищем в БД.
lem::UFString s;
if( tags.size()==1 )
{
s = lem::format_str( L"%d %d", tags.front().first, tags.front().second );
}
else if( tags.size()==2 )
{
s = lem::format_str( L"%d %d %d %d", sorted_tags->get(0).first, sorted_tags->get(0).second, sorted_tags->get(1).first, sorted_tags->get(1).second );
}
else
{
for( lem::Container::size_type i=0; i<sorted_tags->size(); ++i )
{
if(i>0) s += L' ';
s += lem::format_str( L"%d %d", sorted_tags->get(i).first, sorted_tags->get(i).second );
}
}
const int id = db->AddTagSet(s);
id2tags.insert( std::make_pair(id,sorted_tags) );
tag_ptr.push_back( sorted_tags );
tagset_id.push_back(id);
return id;
}
else
{
delete sorted_tags;
return tagset_id[i];
}
}
示例2: x_contains_any_of_y
static bool x_contains_any_of_y( const lem::MCollect<int> &x, const lem::MCollect<int> &y )
{
if( y.size()==1 )
return x.find(y.front())!=UNKNOWN;
else if( y.size()==2 )
return x.find(y.front())!=UNKNOWN || x.find(y.back())!=UNKNOWN;
else
{
for( lem::Container::size_type i=0; i<y.size(); ++i )
if( x.find(y[i])!=UNKNOWN )
return true;
return false;
}
}
示例3: LoadNGram
void LEMM_Compiler::LoadNGram( lem::Iridium::Macro_Parser & txtfile, Dictionary & dict, lem::MCollect<int> & terms, int order ) const
{
lem::Iridium::BSourceState beg = txtfile.tellp();
while( !txtfile.eof() )
{
lem::Iridium::BethToken t = txtfile.read();
if( lem::is_int(t.string()) )
terms.push_back( lem::to_int(t.string()) );
else
{
txtfile.seekp(t);
break;
}
}
if( terms.size() != order+1 )
{
dict.GetIO().merr().printf( "%vfDInvalid ngram%vn\n" );
lem::Iridium::Print_Error( beg, txtfile );
throw lem::E_ParserError();
}
return;
}
示例4: Lemmatize
void Lemmatizator::Lemmatize( const lem::MCollect<lem::UCString> & words, lem::MCollect<lem::UCString> &lemmas )
{
#if defined LEM_THREADS
lem::Process::CritSecLocker lock(&cs);
#endif
if( !model_loaded )
{
bin->seekp( model_pos );
model_loaded = true;
model_available = bin->read_bool();
if( model_available )
{
LoadModel();
}
}
if( model_available )
{
LemmatizeViaModel( words, lemmas );
}
else
{
for( lem::Container::size_type i=0; i<words.size(); ++i )
{
lem::UCString lemma;
Lemmatize( words[i], lemma );
lemmas.push_back( lemma );
}
}
return;
}
示例5: FilterExportedNodes
void SynPatternResult::FilterExportedNodes(const lem::MCollect< ExportNode > & must_be_exported)
{
if (must_be_exported.empty())
{
exported_nodes.clear();
}
else
{
lem::MCollect< std::pair<const lem::UCString*, const Word_Form*> > filtered;
for (lem::Container::size_type i = 0; i < exported_nodes.size(); ++i)
{
const lem::UCString & name = *exported_nodes[i].first;
for (lem::Container::size_type j = 0; j < must_be_exported.size(); ++j)
{
if (must_be_exported[j].node_name == name)
{
// Нашли ссылку, которую нужно перебросить в новый список, возможно уже под другим именем
filtered.push_back(std::make_pair(&must_be_exported[j].as_name, exported_nodes[i].second));
break;
}
}
}
exported_nodes = filtered;
}
return;
}
示例6: SelectUnique_WithoutRemoval
void SynPatternResult::SelectUnique_WithoutRemoval(lem::MCollect<const SynPatternResult*> & results)
{
lem::MCollect<int> result_hash;
lem::MCollect<const SynPatternResult*> unique_result;
for (lem::Container::size_type k = 0; k < results.size(); ++k)
{
const SynPatternResult * result_k = results[k];
const int h = result_k->CalcHash();
bool found = false;
for (lem::Container::size_type i = 0; i < unique_result.size(); ++i)
{
if (result_hash[i] == h)
{
if (SynPatternResult::Equals(result_k, unique_result[i]))
{
found = true;
break;
}
}
}
if (!found)
{
result_hash.push_back(h);
unique_result.push_back(result_k);
}
}
results = unique_result;
return;
}
示例7: AppendDebugTrace
void SynPatternResult::AppendDebugTrace(const lem::MCollect<SynPatternDebugTrace> & debug_trace2)
{
for (lem::Container::size_type i = 0; i < debug_trace2.size(); ++i)
{
debug_trace.push_back(debug_trace2[i]);
}
return;
}
示例8: AddKBCheckerMatching
void TreeMatchingExperience::AddKBCheckerMatching( int id_facts, const lem::MCollect< const Solarix::Word_Form * > & arg_values, const KB_CheckingResult & res )
{
LEM_CHECKIT_Z( id_facts!=UNKNOWN );
LEM_CHECKIT_Z( arg_values.size()>0 );
TME_KBChecker * y = new TME_KBChecker( arg_values, res );
kbid2item.insert( std::make_pair( std::make_pair(id_facts,arg_values.front()), y ) );
return;
}
示例9: Replace
void SyllabContext::Replace(int start_index, int count, lem::MCollect<SyllabContextPoint*> & new_points)
{
for (int n = 0; n < count; ++n)
points.Remove(start_index);
for (lem::Container::size_type i = 0; i < new_points.size(); ++i)
{
const int new_index = start_index + CastSizeToInt(i);
if (new_index == Count())
points.push_back(new_points[i]);
else
points.Insert(new_index, new_points[i]);
}
return;
}
示例10: UpdateNGrams
void NGramsStorage_SQLITE::UpdateNGrams(
const lem::FString &suffix,
int order,
const lem::MCollect< std::pair<int,int> > & list
)
{
char asql_buf[1000];
sprintf( asql_buf, "UPDATE NGRAM%d%s SET w=w+? WHERE id=?", order, suffix.c_str() );
sqlite3_stmt *stmt2=NULL;
int res = sqlite3_prepare_v2( hdb, asql_buf, -1, &stmt2, NULL );
if( res!=SQLITE_OK )
{
const char *errmsg = sqlite3_errmsg(hdb);
throw E_BaseException( lem::format_str( L"SQLite error %S", errmsg ).c_str() );
}
for( lem::Container::size_type i=0; i<list.size(); ++i )
{
#if LEM_DEBUGGING==1
int debug_id_ngram = list[i].first;
int debug_add_w = list[i].second;
if( debug_id_ngram==5 )
{
// printf( "add_w=%d\n", debug_add_w );
}
#endif
res = sqlite3_bind_int( stmt2, 1, list[i].second );
res = sqlite3_bind_int( stmt2, 2, list[i].first );
res = sqlite3_step( stmt2 );
if( res!=SQLITE_DONE )
{
const char *errmsg = sqlite3_errmsg(hdb);
throw E_BaseException( lem::format_str( L"SQLite error %S", errmsg ).c_str() );
}
res = sqlite3_reset(stmt2);
}
sqlite3_finalize(stmt2);
return;
}
示例11: ResetCoordStates
void SynPatternResult::ResetCoordStates(int coord_id, const lem::MCollect<int> & state_ids)
{
std::multimap< int /*id_coord*/, int /*id_state*/ > filtered;
for (auto it = exported_coords.begin(); it != exported_coords.end(); ++it)
{
if (coord_id != it->first)
filtered.insert(*it);
}
for (lem::Container::size_type i = 0; i < state_ids.size(); ++i)
{
filtered.insert(std::make_pair(coord_id, state_ids[i]));
}
exported_coords = filtered;
return;
}
示例12: FindKBCheckerMatching
bool TreeMatchingExperience::FindKBCheckerMatching( int id_facts, const lem::MCollect< const Solarix::Word_Form * > & arg_values, KB_CheckingResult * res ) const
{
LEM_CHECKIT_Z( id_facts!=UNKNOWN );
LEM_CHECKIT_Z( arg_values.size()>0 );
typedef KBID2ITEM::const_iterator IT;
std::pair<IT,IT> pit = kbid2item.equal_range( std::make_pair( id_facts, arg_values.front() ) );
for( IT it=pit.first; it!=pit.second; ++it )
{
if( arg_values == it->second->arg_values )
{
*res = it->second->res;
return true;
}
}
return false;
}
示例13:
Word_Form::Word_Form( const lem::MCollect<const Word_Form*> &variants )
{
LEM_CHECKIT_Z( !variants.empty() );
// Первая версия становится основной, ее не копируем в альтернативы.
for( lem::Container::size_type i=1; i<variants.size(); ++i )
alt.push_back( new Word_Form(*variants[i]) );
name = variants[0]->name;
normalized = variants[0]->normalized;
pair = variants[0]->pair;
entry_key = variants[0]->entry_key;
val = variants[0]->val;
score=variants[0]->score;
origin_pos = variants[0]->origin_pos;
tokenizer_flags = variants[0]->tokenizer_flags;
iversion = seq_iversion++;
return;
}
示例14: IsHtmlClosed
static bool IsHtmlClosed( const lem::UFString &tag )
{
if( tags1.empty() )
{
const wchar_t* stags[] = { L"br", L"hr", L"link", L"meta", L"img", L"input",
NULL
};
int i=0;
while(stags[i]!=NULL)
tags1.push_back( lem::UFString(stags[i++]) );
}
for( lem::Container::size_type i=0; i<tags1.size(); ++i )
{
const lem::UFString &t = tags1[i];
if( tag.eq_begi(t) && (tag.length()==t.length() || tag[ t.length() ]==L' ' ) )
return true;
}
return false;
}
示例15: IsTextDelimiterTag
static bool IsTextDelimiterTag( const UFString &tag )
{
if( tags2.empty() )
{
const wchar_t* stags[] = { L"p", L"br", L"table", L"td", L"tr", L"th",
L"ol", L"ul", L"li", L"dd", L"input", L"frame", L"div",
NULL
};
int i=0;
while(stags[i]!=NULL)
tags2.push_back( lem::UFString(stags[i++]) );
}
for( lem::Container::size_type i=0; i<tags2.size(); ++i )
{
const lem::UFString &t = tags2[i];
if( tag.eq_begi(t) && (tag.length()==t.length() || tag[ t.length() ]==L' ' ) )
return true;
}
return false;
}