当前位置: 首页>>代码示例>>C++>>正文


C++ UCString::c_str方法代码示例

本文整理汇总了C++中lem::UCString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ UCString::c_str方法的具体用法?C++ UCString::c_str怎么用?C++ UCString::c_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lem::UCString的用法示例。


在下文中一共展示了UCString::c_str方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rs

void NGramsDBMS::FindRaw3GramsWithRight(
    const lem::FString &suffix,
    const lem::FString &sgm,
    float max_w3,
    const lem::UCString &right,
    int min_freq,
    std::map< std::pair<lem::UCString, lem::UCString>, float > & reslist
)
{
    FString sql = lem::format_str(
        "SELECT wrd2.word, wrd3.word, w"
        " FROM NGRAM3%s%s, NGRAM_WORDS%s%s wrd1, NGRAM_WORDS%s%s wrd2, NGRAM_WORDS%s%s wrd3"
        " WHERE wrd1.word='%s' AND iword3=wrd1.id AND wrd2.id=iword1 AND wrd3.id=iword2"
        , suffix.c_str(), sgm.c_str()
        , suffix.c_str(), sgm.c_str()
        , suffix.c_str(), sgm.c_str()
        , suffix.c_str(), sgm.c_str()
        , to_utf8(right.c_str()).c_str());

    std::unique_ptr<LS_ResultSet> rs(Select(sql));
    while (rs->Fetch())
    {
        const int f = rs->GetInt(2);
        if (f >= min_freq)
        {
            UCString cw2(rs->GetUCString(0));
            UCString cw3(rs->GetUCString(1));
            const float ff = float(f) / max_w3;

            auto it = reslist.find(std::make_pair(cw2, cw3));
            if (it == reslist.end())
                reslist.insert(std::make_pair(std::make_pair(cw2, cw3), ff));
            else
                it->second += ff;
        }
    }

    return;
}
开发者ID:Koziev,项目名称:GrammarEngine,代码行数:39,代码来源:NGramsDBMS.cpp

示例2: SyllabContextLeftBoundary

SyllabContext::SyllabContext(GraphGram &alphabet, const lem::UCString &word, int id_language)
{
    LEM_CHECKIT_Z(id_language != UNKNOWN);

    const SG_Language &lang = alphabet.GetDict().GetSynGram().languages()[id_language];
    const lem::MCollect<int> & id_alphabets = lang.GetAlphabets();

    points.push_back(new SyllabContextLeftBoundary());

    // Разбираем исходное слово по символам, каждый символ ищем в алфавите и создаем по результатам одну точку контекста 
    lem::WideStringUcs4 ucs4(word.c_str());
    lem::uint32_t c;
    while ((c = ucs4.Fetch()) != 0)
    {
        const Word_Coord wc = alphabet.entries().FindSymbol(c, id_alphabets);
        if (wc.IsUnknown())
        {
            SyllabContextUnknownSymbol *point = new SyllabContextUnknownSymbol(c);
            points.push_back(point);
        }
        else
        {
            const GG_Entry &e = alphabet.entries()[wc.GetEntry()];
            const int id_class = e.GetClass();

            const GG_EntryForm & f = e.forms()[wc.GetForm()];
            lem::MCollect<GramCoordPair> coords = f.dims();
            for (lem::Container::size_type k = 0; k < e.attrs().size(); ++k)
                coords.push_back(e.attrs()[k]);

            SyllabContextSymbol *point = new SyllabContextSymbol(c, e.GetName(), wc.GetEntry(), id_class, coords);
            points.push_back(point);
        }
    }

    points.push_back(new SyllabContextRightBoundary());

    return;
}
开发者ID:Koziev,项目名称:GrammarEngine,代码行数:39,代码来源:SyllabContext.cpp

示例3: cs

void NGramsDBMS::Find2GramsWithLeft(
    const lem::FString &suffix,
    const lem::FString &segment,
    float max_w2,
    const lem::UCString &left,
    int min_freq,
    std::map< lem::UCString, float > & reslist
)
{
    FString sql = lem::format_str("SELECT wrd2.word, w"
        " FROM NGRAM_WORDS%s%s wrd1, NGRAM2%s%s, NGRAM_WORDS%s%s wrd2"
        " WHERE wrd1.word='%s' AND iword1=wrd1.id AND wrd2.id=iword2"
        , suffix.c_str(), segment.c_str()
        , suffix.c_str(), segment.c_str()
        , suffix.c_str(), segment.c_str()
        , to_utf8(left.c_str()).c_str());

    std::unique_ptr<LS_ResultSet> rs(Select(sql));
    while (rs->Fetch())
    {
        const int f = rs->GetInt(1);
        if (f >= min_freq)
        {
            UCString cs(rs->GetUCString(0));
            const float ff = float(f) / max_w2;

            auto it = reslist.find(cs);
            if (it == reslist.end())
                reslist.insert(std::make_pair(cs, ff));
            else
                it->second += ff;
        }
    }

    return;
}
开发者ID:Koziev,项目名称:GrammarEngine,代码行数:36,代码来源:NGramsDBMS.cpp

示例4: FindWord

int NGramsDBMS::FindWord(
    const lem::FString &suffix,
    const lem::UCString &word
)
{
    FString sql = lem::format_str("SELECT id FROM NGRAM_WORDS%s WHERE word='%s'", suffix.c_str(), to_utf8(word.c_str()).c_str());
    int id = SelectInt(sql);
    return id;
}
开发者ID:Koziev,项目名称:GrammarEngine,代码行数:9,代码来源:NGramsDBMS.cpp

示例5: SaveRules_SQL

void LexicalAutomat::SaveRules_SQL( OFormatter &out, OFormatter &alters, const SQL_Production &sql_version )
{
 if( sql_version.norules )
  return;

 PM_Automat::SaveRules_SQL( "la", out, alters, sql_version );


 lem::Ptr<LS_ResultSet> rs_predicates( GetStorage().ListPredicateTemplate() );
 while( rs_predicates->Fetch() )
 {
  int id = rs_predicates->GetInt(0);
  lem::Ptr<PredicateTemplate> t( GetStorage().LoadPredicateTemplate(id) );

  lem::UFString src( sql_version.SqlStr(t->GetSrc()) );
  
  lem::UFString params;
  for( lem::Container::size_type i=0; i<t->GetParams().size(); ++i )
   if( i>0 )
    {
     params.Add_Dirty( L"," );
     params.Add_Dirty( t->GetParams()[i].c_str() );
    }
   else
    {
     params.Add_Dirty( t->GetParams()[i].c_str() );
    }

  out.printf( "INSERT INTO predicate_template( src, params ) VALUES ( '%us', '%us' );\n", src.c_str(), params.c_str() );
 }
 rs_predicates.Delete();
 out.eol();
 out.flush();
 

 lem::Ptr<LS_ResultSet> rs_assocs( GetStorage().ListAssociatedEntries() );
 while( rs_assocs->Fetch() )
 {
  const int id = rs_assocs->GetInt(0);
  lem::Ptr<WordAssociation> assoc( GetStorage().LoadAssocitation(id) );
  assoc->SaveSQL( out, sql_version );
 }
 rs_assocs.Delete();
 out.flush();

 out.printf( "\n\n" );

 lem::Ptr<LS_ResultSet> misspelling( GetStorage().ListMisspelling() );
 while( misspelling->Fetch() )
  {
   int id_language = misspelling->GetInt(1);
   UFString old_word = sql_version.SqlStr(misspelling->GetUFString(2));
   UFString new_word = sql_version.SqlStr(misspelling->GetUFString(3));

   old_word = sql_version.SqlStr(old_word);
   new_word = sql_version.SqlStr(new_word);   

   out.printf( "INSERT INTO misspelling( id_language, original_word, substitution ) VALUES ( %d, '%us', '%us' );\n",
    id_language, old_word.c_str(), new_word.c_str() );
  }
 misspelling.Delete();
 out.eol();


 lem::Ptr<WordEntrySetEnumerator> wordentry_sets( wordentry_set->ListWordEntrySets() );
 while( wordentry_sets->Fetch() )
  {
   const WordEntrySetItem &wes = wordentry_sets->GetItem();

   lem::UFString s;
   for( std::set<int>::const_iterator it=wes.ies.begin(); it!=wes.ies.end(); ++it )
    {
     if( !s.empty() )
      s.Add_Dirty(L' ');

     s.Add_Dirty( lem::to_ustr(*it).c_str() );
    } 

   out.printf( "INSERT INTO word_entry_set( id, name, ies ) VALUES ( %d, '%us', '%us' );\n",
                 wes.GetId(), lem::to_upper(wes.GetName()).c_str(), s.c_str() );
  }
 wordentry_sets.Delete();
 out.eol();


 lem::Ptr<WordSetEnumerator> word_sets( wordentry_set->ListWordSets() );
 while( word_sets->Fetch() )
  {
   const WordSetItem &wes = word_sets->GetItem();

   lem::UFString s;
   for( std::set<lem::UCString>::const_iterator it=wes.words.begin(); it!=wes.words.end(); ++it )
    {
     if( !s.empty() )
      s.Add_Dirty(LexiconStorage::WORD_SET_DELIMITER);

     s.Add_Dirty( sql_version.SqlStr(*it) );
    } 

   out.printf( "INSERT INTO word_set( id, name, words, case_sensitive ) VALUES ( %d, '%us', '%us', %d );\n",
//.........这里部分代码省略.........
开发者ID:mcdir,项目名称:GrammarEngine,代码行数:101,代码来源:la_sql_export.cpp


注:本文中的lem::UCString::c_str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。