fix minitoc/heading error
[vspell.git] / libvspell / penalty.h
blob9929e6ac9797ef693de97a4c6c1ce26a56a8bdef
1 #ifndef __PENALTY_H__ // -*- tab-width: 2 mode: c++ -*-
2 #define __PENALTY_H__
4 #ifndef __DAG_H__
5 #include "dag.h"
6 #endif
8 class PenaltyDAG : public DAG {
9 protected:
10 /// requires that dag->get_info() return a WordEntry*
11 DAG *dag;
12 float weight;
14 public:
15 PenaltyDAG(DAG *dag_,float weight_):dag(dag_),weight(weight_) {}
17 void set_weight(float weight_) {
18 weight = weight_;
21 float get_weight() const {
22 return weight;
25 virtual uint node_begin() const {
26 return dag->node_begin();
28 virtual uint node_end() const {
29 return dag->node_end();
31 virtual uint node_count() const {
32 return dag->node_count();
34 virtual const void* node_info(uint node_id) const {
35 return dag->node_info(node_id);
37 virtual VocabIndex node_id(uint id) const {
38 return dag->node_id(id);
40 virtual void get_next(uint node_id,std::vector<uint> &next_id) const {
41 dag->get_next(node_id,next_id);
43 virtual float edge_value(uint node_from,uint node_to) const;
44 virtual bool fill_vi(uint node_from,uint node_to,VocabIndex &v,VocabIndex *vi,int size) const {
45 return dag->fill_vi(node_from,node_to,v,vi,size);
49 class Penalty2DAG : public PenaltyDAG {
50 protected:
51 std::vector<float> syllable_weights;
53 public:
54 Penalty2DAG(DAG *dag_,float weight_):PenaltyDAG(dag_,weight_) {}
56 void set_syllable_weights(const Segmentation &seg);
58 virtual float edge_value(uint node_from,uint node_to) const;
59 virtual bool fill_vi(uint node_from,uint node_to,VocabIndex &v,VocabIndex *vi,int size) const {
60 return dag->fill_vi(node_from,node_to,v,vi,size);
64 #endif