Beispiel #1
0
void NGramsDBMS::LoadSegments(const lem::FString &suffix, lem::Collect<lem::FString> &segments)
{
    if (TableExists("NGRAM_SEGMENTS"))
    {
        lem::FString sql = lem::format_str("SELECT segment_n FROM NGRAM_SEGMENTS Where suffix='%s'", suffix.c_str());

        lem::Collect<lem::FString> list;
        SelectFStrings(sql, list);

        for (lem::Container::size_type i = 0; i < list.size(); ++i)
        {
            if (list[i].empty())
                segments.push_back(list[i]);
            else
                segments.push_back(FString("_") + list[i]);
        }
    }

    if (segments.empty())
        segments.push_back(lem::FString(""));

    return;
}
void NGramsStorage_SQLITE::SelectFStrings( const lem::FString &Select, lem::Collect<lem::FString> &list )
{
 LEM_CHECKIT_Z( !Select.empty() );

 sqlite3_stmt *stmt=NULL;
 int res = sqlite3_prepare_v2( hdb, Select.c_str(), -1, &stmt, NULL );
 if( res==SQLITE_OK )
  {
   while( sqlite3_step( stmt ) == SQLITE_ROW )
    {
     lem::FString s = lem::sqlite_column_fstring( stmt, 0 );
     list.push_back(s);
    } 

   sqlite3_finalize(stmt);
  }

 return;
}