HFST - Helsinki Finite-State Transducer Technology API  version 3.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HfstFastTransitionData.h
1 
2 namespace hfst {
3 
4  namespace implementations {
5 
14  public:
16  typedef unsigned int SymbolType;
18  typedef float WeightType;
20  typedef std::set<SymbolType> SymbolTypeSet;
21 
22  private:
23  /* The actual transition data */
24  SymbolType input_number;
25  SymbolType output_number;
26  WeightType weight;
27 
28  public:
29 
33  input_number(0), output_number(0), weight(0) {}
34 
38  (const HfstFastTransitionData &data) {
39  input_number = data.input_number;
40  output_number = data.output_number;
41  weight = data.weight;
42  }
43 
48  SymbolType onumber,
49  WeightType weight) {
50  input_number = inumber;
51  output_number = onumber;
52  this->weight = weight;
53  }
54 
57  return input_number;
58  }
59 
62  return output_number;
63  }
64 
67  return weight;
68  }
69 
70  static SymbolType get_epsilon()
71  {
72  return 0;
73  }
74 
75  static SymbolType get_unknown()
76  {
77  return 1;
78  }
79 
80  static SymbolType get_identity()
81  {
82  return 2;
83  }
84 
85  /* Are these needed? */
86  static bool is_epsilon(const SymbolType &s) {
87  return s == 0;
88  }
89  static bool is_unknown(const SymbolType &s) {
90  return s == 1;
91  }
92  static bool is_identity(const SymbolType &s) {
93  return s == 2;
94  }
95  static bool is_valid_symbol(const SymbolType &s) {
96  (void)s;
97  return true;
98  }
99 
100  /* Get a marker symbol. Equivalent to (biggest number in sts + 1). */
101  static SymbolType get_marker(const SymbolTypeSet &sts) {
102  SymbolType marker=0;
103  for (SymbolTypeSet::const_iterator it = sts.begin();
104  it != sts.end(); it++) {
105  if (marker < *it) {
106  marker = *it;
107  }
108  }
109  return marker++;
110  }
111 
115  bool operator<(const HfstFastTransitionData &another)
116  const {
117  if (input_number < another.input_number )
118  return true;
119  if (input_number > another.input_number)
120  return false;
121  if (output_number < another.output_number)
122  return true;
123  if (output_number > another.output_number)
124  return false;
125  return (weight < another.weight);
126  }
127 
128  void operator=(const HfstFastTransitionData &another)
129  {
130  input_number = another.input_number;
131  output_number = another.output_number;
132  weight = another.weight;
133  }
134 
135  friend class ComposeIntersectFst;
136  friend class ComposeIntersectLexicon;
137  friend class ComposeIntersectRule;
138  friend class ComposeIntersectRulePair;
139 
140  };
141 
142 
143  /* std::ostream& operator<<(std::ostream &out,
144  const HfstFastTransitionData &tr)
145  {
146  return out << tr.get_input_symbol() << '\t'
147  << tr.get_output_symbol() << '\t'
148  << tr.get_weight();
149  }*/
150 
151  } // namespace implementations
152 
153 } // namespace hfst
154 
155 
156 
HfstFastTransitionData()
Create an HfstFastTransitionData with input and output numbers and weight zero.
Definition: HfstFastTransitionData.h:32
WeightType get_weight() const
Get the weight.
Definition: HfstFastTransitionData.h:66
SymbolType get_input_symbol() const
Get the input symbol.
Definition: HfstFastTransitionData.h:56
unsigned int SymbolType
The input and output symbol type.
Definition: HfstFastTransitionData.h:16
float WeightType
The weight type.
Definition: HfstFastTransitionData.h:18
std::set< SymbolType > SymbolTypeSet
A set of symbols.
Definition: HfstFastTransitionData.h:20
SymbolType get_output_symbol() const
Get the output symbol.
Definition: HfstFastTransitionData.h:61
One implementation of template class C in HfstTransition.
Definition: HfstFastTransitionData.h:13
HfstFastTransitionData(SymbolType inumber, SymbolType onumber, WeightType weight)
Create an HfstFastTransitionData with input number inumber, output number onumber and weight weight...
Definition: HfstFastTransitionData.h:47
bool operator<(const HfstFastTransitionData &another) const
Whether this transition is less than transition another.
Definition: HfstFastTransitionData.h:115