QNLP  v1.0
corpus_utils.hpp
Go to the documentation of this file.
1 
8 #ifndef QNLP_CORPUS_LOADER
9 #define QNLP_CORPUS_LOADER
10 
11 #include <unordered_map>
12 #include "db_helper.hpp"
13 
14 #ifndef QNLP_DB_FILE
15 #define QNLP_DB_FILE "qnlp_tagged_corpus.sqlite"
16 #endif
17 
18 namespace QNLP{
19  class CorpusUtils{
20  public:
21 
26  CorpusUtils();
32  CorpusUtils(const std::string filename);
33  ~CorpusUtils();
34 
35  typedef std::unordered_map<std::string, std::unordered_map<std::string, unsigned int> > NTB;
36  typedef std::unordered_map<std::string, std::unordered_map<unsigned int, std::string> > BTN;
37 
43  NTB& getNameToBin();
49  BTN& getBinToName();
50 
57  void loadData(const std::string data_type, const std::string table="corpus");
64 
71  void printData(const std::string type, const std::string table);
72 
78  const std::string get_database_filename();
79 
84  void clearData();
85 
86  private:
87  //Maps for strings to binary pattern and reverse maps. Outer map keys are grammatical
88  //types (nouns, verbs, etc.). Returned maps then hold unique entries.
91 
92  //Database helper boject
94  std::string database_filename;
95  };
96 }
97 
98 #endif
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...
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.
void clearData()
Clear all loaded data.
DBHelper & getDBHelper()
Return reference to database object.