HFST - Helsinki Finite-State Transducer Technology API  version 3.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HfstTransition.h
Go to the documentation of this file.
1 #ifndef _HFST_TRANSITION_H_
2 #define _HFST_TRANSITION_H_
3 
7 #include "../HfstDataTypes.h"
8 
9 namespace hfst {
10 
11  namespace implementations {
12 
22  template <class C> class HfstTransition
23  {
24  protected:
25  HfstState target_state; // the state where the transition leads
26  C transition_data; // the actual transition data
27 
28  /* Get the number that represents the symbol in the transition data. */
29  static unsigned int get_symbol_number
30  (const typename C::SymbolType &symbol) {
31  return C::get_symbol_number(symbol);
32  }
33 
34  public:
35 
39  HfstTransition(): target_state(0)
40  {}
41 
45  typename C::SymbolType isymbol,
46  typename C::SymbolType osymbol,
47  typename C::WeightType weight):
48  target_state(s), transition_data(isymbol, osymbol, weight)
49  {}
50 
52  unsigned int inumber,
53  unsigned int onumber,
54  typename C::WeightType weight,
55  bool foo):
56  target_state(s), transition_data(inumber, onumber, weight)
57  { (void)foo; }
58 
61  target_state(another.target_state),
62  transition_data(another.transition_data)
63  {}
64 
67  bool operator<(const HfstTransition<C> &another) const {
68  if (target_state == another.target_state)
69  return (transition_data < another.transition_data);
70  return (target_state < another.target_state);
71  }
72 
75  void operator=(const HfstTransition<C> &another) {
76  target_state = another.target_state;
77  transition_data = another.transition_data;
78  }
79 
82  return target_state;
83  }
84 
86  const C & get_transition_data() const {
87  return transition_data;
88  }
89 
91  typename C::SymbolType get_input_symbol() const {
92  return transition_data.get_input_symbol();
93  }
94 
96  typename C::SymbolType get_output_symbol() const {
97  return transition_data.get_output_symbol();
98  }
99 
100  /* Get the internal input number of the transition. */
101  unsigned int get_input_number() const {
102  return transition_data.get_input_number();
103  }
104 
105  /* Get the internal output number of the transition. */
106  unsigned int get_output_number() const {
107  return transition_data.get_output_number();
108  }
109 
111  typename C::WeightType get_weight() const {
112  return transition_data.get_weight();
113  }
114 
115  friend class ComposeIntersectFst;
116  friend class ComposeIntersectLexicon;
117  friend class ComposeIntersectRule;
118  friend class ComposeIntersectRulePair;
119  };
120 
127  typedef HfstTransition<HfstTropicalTransducerTransitionData>
129 
136  typedef HfstTransition<HfstFastTransitionData> HfstFastTransition;
137 
138  }
139 
140 }
141 
142 #endif // _HFST_TRANSITION_H_
C::SymbolType get_output_symbol() const
Get the output symbol of the transition.
Definition: HfstTransition.h:96
C::SymbolType get_input_symbol() const
Get the input symbol of the transition.
Definition: HfstTransition.h:91
unsigned int HfstState
The number of a state in an HfstTransitionGraph.
Definition: HfstDataTypes.h:120
HfstTransition< HfstFastTransitionData > HfstFastTransition
An HfstTransition with transition data of type HfstFastTransitionData.
Definition: HfstDataTypes.h:126
HfstState get_target_state() const
Get the target state of the transition.
Definition: HfstTransition.h:81
HfstTransition(HfstState s, typename C::SymbolType isymbol, typename C::SymbolType osymbol, typename C::WeightType weight)
Create a transition leading to state s with input symbol isymbol, output_symbol osymbol and weight we...
Definition: HfstTransition.h:44
const C & get_transition_data() const
Get the transition data of the transition.
Definition: HfstTransition.h:86
HfstTransition< HfstTropicalTransducerTransitionData > HfstBasicTransition
An HfstTransition with transition data of type HfstTropicalTransducerTransitionData.
Definition: HfstDataTypes.h:122
C::WeightType get_weight() const
Get the weight of the transition.
Definition: HfstTransition.h:111
A transition that consists of a target state and transition data represented by class C...
Definition: HfstDataTypes.h:122
HfstTransition()
Create a transition leading to state zero with input and output symbols and weight as given by defaul...
Definition: HfstTransition.h:39
HfstTransition(const HfstTransition< C > &another)
Create a deep copy of transition another.
Definition: HfstTransition.h:60
void operator=(const HfstTransition< C > &another)
Assign this transition the same value as transition another.
Definition: HfstTransition.h:75