/usr/include/hfst/implementations/HfstFastTransitionData.h is in libhfst42-dev 3.9.0~r4595-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | namespace hfst {
namespace implementations {
/** @brief One implementation of template class C in HfstTransition.
An HfstFastTransitionData has an input number and an output number
of type SymbolType (an unsigned int) and a weight of type WeightType
(a float).
*/
class HfstFastTransitionData {
public:
/** @brief The input and output symbol type. */
typedef unsigned int SymbolType;
/** @brief The weight type. */
typedef float WeightType;
/** @brief A set of symbols. */
typedef std::set<SymbolType> SymbolTypeSet;
private:
/* The actual transition data */
SymbolType input_number;
SymbolType output_number;
WeightType weight;
public:
/** @brief Create an HfstFastTransitionData with
input and output numbers and weight zero. */
HfstFastTransitionData():
input_number(0), output_number(0), weight(0) {}
/** @brief Create a deep copy of HfstFastTransitionData
\a data. */
HfstFastTransitionData
(const HfstFastTransitionData &data) {
input_number = data.input_number;
output_number = data.output_number;
weight = data.weight;
}
/** @brief Create an HfstFastTransitionData with
input number \a inumber, output number \a onumber
and weight \a weight. */
HfstFastTransitionData(SymbolType inumber,
SymbolType onumber,
WeightType weight) {
input_number = inumber;
output_number = onumber;
this->weight = weight;
}
/** @brief Get the input symbol. */
SymbolType get_input_symbol() const {
return input_number;
}
/** @brief Get the output symbol. */
SymbolType get_output_symbol() const {
return output_number;
}
/** @brief Get the weight. */
WeightType get_weight() const {
return weight;
}
static SymbolType get_epsilon()
{
return 0;
}
static SymbolType get_unknown()
{
return 1;
}
static SymbolType get_identity()
{
return 2;
}
/* Are these needed? */
static bool is_epsilon(const SymbolType &s) {
return s == 0;
}
static bool is_unknown(const SymbolType &s) {
return s == 1;
}
static bool is_identity(const SymbolType &s) {
return s == 2;
}
static bool is_valid_symbol(const SymbolType &s) {
(void)s;
return true;
}
/* Get a marker symbol. Equivalent to (biggest number in sts + 1). */
static SymbolType get_marker(const SymbolTypeSet &sts) {
SymbolType marker=0;
for (SymbolTypeSet::const_iterator it = sts.begin();
it != sts.end(); it++) {
if (marker < *it) {
marker = *it;
}
}
return marker++;
}
/** @brief Whether this transition is less than transition
\a another.
*/
bool operator<(const HfstFastTransitionData &another)
const {
if (input_number < another.input_number )
return true;
if (input_number > another.input_number)
return false;
if (output_number < another.output_number)
return true;
if (output_number > another.output_number)
return false;
return (weight < another.weight);
}
void operator=(const HfstFastTransitionData &another)
{
input_number = another.input_number;
output_number = another.output_number;
weight = another.weight;
}
friend class ComposeIntersectFst;
friend class ComposeIntersectLexicon;
friend class ComposeIntersectRule;
friend class ComposeIntersectRulePair;
};
/* std::ostream& operator<<(std::ostream &out,
const HfstFastTransitionData &tr)
{
return out << tr.get_input_symbol() << '\t'
<< tr.get_output_symbol() << '\t'
<< tr.get_weight();
}*/
} // namespace implementations
} // namespace hfst
|