10 #ifndef META_SEQUENCE_SEQUENCE_ANALYZER_H_
11 #define META_SEQUENCE_SEQUENCE_ANALYZER_H_
16 #include <unordered_map>
89 void load(
const std::string& prefix);
96 void save(
const std::string& prefix)
const;
113 void analyze(sequence& sequence, uint64_t idx);
122 void analyze(sequence& sequence)
const;
130 void analyze(sequence& sequence, uint64_t idx)
const;
150 feature_id
feature(
const std::string& feature)
const;
161 label_id
label(tag_t lbl)
const;
167 tag_t
tag(label_id lbl)
const;
177 const std::string&
prefix()
const;
190 template <
class Function>
193 obs_fns_.emplace_back(std::forward<Function>(
function));
217 using pair = std::pair<feature_id, double>;
219 [](
const pair& lhs,
const pair& rhs)
221 return lhs.first < rhs.first;
232 virtual void add(
const std::string& feat,
double amount)
242 virtual feature_id
feature(
const std::string& feat) = 0;
253 using std::runtime_error::runtime_error;
260 template <
class Analyzer>
279 virtual feature_id
feature(
const std::string& feat)
281 return analyzer_->feature(feat);
306 virtual void add(
const std::string& feat,
double amount)
310 feats_.emplace_back(fid, amount);
334 double weight = 1.0);
337 std::vector<std::function<void(const sequence&, uint64_t, collector&)>>