ModErn Text Analysis
META Enumerates Textual Applications
forward_index.h
Go to the documentation of this file.
1 
10 #ifndef META_FORWARD_INDEX_H_
11 #define META_FORWARD_INDEX_H_
12 
13 #include <stdexcept>
14 
15 #include "index/disk_index.h"
16 #include "index/make_index.h"
17 #include "util/disk_vector.h"
18 #include "meta.h"
19 
20 namespace meta
21 {
22 namespace corpus
23 {
24 class corpus;
25 }
26 
27 namespace index
28 {
29 template <class, class>
31 }
32 }
33 
34 namespace meta
35 {
36 namespace index
37 {
38 
44 class forward_index : public disk_index
45 {
46  public:
50  class forward_index_exception : public std::runtime_error
51  {
52  public:
53  using std::runtime_error::runtime_error;
54  };
55 
60  template <class Index, class... Args>
61  friend std::shared_ptr<Index> make_index(const std::string& config_file,
62  Args&&... args);
63 
68  template <class Index, template <class, class> class Cache, class... Args>
69  friend std::shared_ptr<cached_index<Index, Cache>>
70  make_index(const std::string& config_file, Args&&... args);
71 
72  using primary_key_type = doc_id;
73  using secondary_key_type = term_id;
78 
79  protected:
84  forward_index(const cpptoml::table& config);
85 
86  public:
91 
97 
101  forward_index(const forward_index&) = delete;
102 
106  forward_index& operator=(const forward_index&) = delete;
107 
111  virtual ~forward_index();
112 
117  virtual std::shared_ptr<postings_data_type>
118  search_primary(doc_id d_id) const;
119 
124  std::string liblinear_data(doc_id d_id) const;
125 
129  virtual uint64_t unique_terms() const override;
130 
131  private:
136  void load_index();
137 
142  void create_index(const std::string& config_file);
143 
147  bool valid() const;
148 
150  class impl;
153 };
154 }
155 }
156 
157 #endif
Contains top-level namespace documentation for the META toolkit.
Implementation of a forward_index.
Definition: forward_index.cpp:30
void create_index(const std::string &config_file)
This function initializes the forward index.
Definition: forward_index.cpp:178
Holds generic data structures and functions that inverted_index and forward_index both use...
Definition: disk_index.h:55
Class to assist in simple pointer-to-implementation classes.
Definition: pimpl.h:26
virtual ~forward_index()
Default destructor.
virtual uint64_t unique_terms() const override
Definition: forward_index.cpp:339
bool valid() const
Definition: forward_index.cpp:120
Basic exception for forward_index interactions.
Definition: forward_index.h:50
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
A class to represent the per-PrimaryKey data in an index's postings file.
Definition: forward_index.h:30
forward_index(const cpptoml::table &config)
Definition: forward_index.cpp:104
virtual std::shared_ptr< postings_data_type > search_primary(doc_id d_id) const
Definition: forward_index.cpp:344
std::string liblinear_data(doc_id d_id) const
Definition: forward_index.cpp:142
The forward_index stores information on a corpus by doc_ids.
Definition: forward_index.h:44
void load_index()
This function loads a disk index from its filesystem representation.
Definition: forward_index.cpp:159
util::pimpl< impl > fwd_impl_
Implementation of this index.
Definition: forward_index.h:150
forward_index & operator=(forward_index &&)
Move assigns a forward_index.
friend std::shared_ptr< Index > make_index(const std::string &config_file, Args &&...args)
forward_index is a friend of the factory method used to create it.
Definition: make_index.h:60