ModErn Text Analysis
META Enumerates Textual Applications
observation.h
Go to the documentation of this file.
1 
9 #ifndef META_OBSERVATION_H_
10 #define META_OBSERVATION_H_
11 
12 #include <string>
13 #include <vector>
14 
15 #include "meta.h"
16 #include "util/identifiers.h"
17 #include "util/optional.h"
18 
19 namespace meta
20 {
21 namespace sequence
22 {
23 
24 MAKE_IDENTIFIER(symbol_t, std::string)
25 MAKE_IDENTIFIER(tag_t, std::string)
26 MAKE_IDENTIFIER(feature_id, uint64_t)
27 
33 {
34  public:
36  using feature_vector = std::vector<std::pair<feature_id, double>>;
37 
43  observation(symbol_t sym, tag_t t);
44 
49  observation(symbol_t sym);
50 
54  const symbol_t& symbol() const;
55 
60  const tag_t& tag() const;
61 
66  const label_id& label() const;
67 
72  void symbol(symbol_t sym);
73 
78  void tag(tag_t t);
79 
84  void label(label_id lbl);
85 
89  bool tagged() const;
90 
94  const feature_vector& features() const;
95 
99  void features(feature_vector feats);
100 
104  class exception : public std::runtime_error
105  {
106  public:
107  using std::runtime_error::runtime_error;
108  };
109 
110  private:
112  symbol_t symbol_;
119 };
120 }
121 }
122 #endif
symbol_t symbol_
The symbol for this observation.
Definition: observation.h:112
Contains top-level namespace documentation for the META toolkit.
util::optional< label_id > label_
The label_id for this observation's tag, if it exists.
Definition: observation.h:116
class_label label(const std::string &text)
Extracts a class_label from a string in libsvm format.
Definition: libsvm_parser.cpp:18
STL namespace.
std::vector< std::pair< feature_id, double >> feature_vector
internal feature vector for observations
Definition: observation.h:36
feature_vector features_
The features for this observation.
Definition: observation.h:118
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
Represents an observation in a tagged sequence.
Definition: observation.h:32
Basic exception class for observation interactions.
Definition: observation.h:104
util::optional< tag_t > tag_
The tag for this observation, if it exists.
Definition: observation.h:114