20 db_helper(filename), database_filename(filename) {}
36 sqlite3_stmt *select_stmt = NULL;
39 std::string query =
"select name, bin_id from " + table +
" where type=?";
45 SQL_RETURN_CHECK( sqlite3_bind_text( select_stmt, 1, data_type.c_str(), -1, SQLITE_STATIC ), SQLITE_OK );
48 while ( (rc = sqlite3_step(select_stmt)) == SQLITE_ROW) {
49 std::string k( reinterpret_cast<const char*> ( sqlite3_column_text(select_stmt, 0) ) );
50 unsigned int v = (
unsigned int) sqlite3_column_int(select_stmt, 1);
62 std::cout << dat.first <<
" : " << dat.second << std::endl;
std::unordered_map< std::string, std::unordered_map< unsigned int, std::string > > BTN
Database access and manipulation functions.
NTB & getNameToBin()
Get the NTB object. This is a map of maps, wherein the first key represents the grammatical type to l...
std::unordered_map< std::string, std::unordered_map< std::string, unsigned int > > NTB
void printData(const std::string type, const std::string table)
Print the data with given type.
std::string database_filename
CorpusUtils()
Construct a new Load Corpus object. Database name taken from the macro/compiler defined value.
BTN & getBinToName()
Get the BTN object. This is a map of maps, wherein the first key represents the grammatical type to l...
#define SQL_RETURN_CHECK(x, y)
void loadData(const std::string data_type, const std::string table="corpus")
Loads from the database for a given data type (noun, verb, etc)
const std::string get_database_filename()
Get the database filename object.
int openDB(const std::string filename)
Opens the requested database, and gives the return code of the operation. If the DB pointer has alrea...
void clearData()
Clear all loaded data.
DBHelper & getDBHelper()
Return reference to database object.