1 #ifndef __PENALTY_H__ // -*- tab-width: 2 mode: c++ -*-
8 class PenaltyDAG
: public DAG
{
10 /// requires that dag->get_info() return a WordEntry*
15 PenaltyDAG(DAG
*dag_
,float weight_
):dag(dag_
),weight(weight_
) {}
17 void set_weight(float weight_
) {
21 float get_weight() const {
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
{
51 std::vector
<float> syllable_weights
;
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
);