22 return line1.
m < line2.
m;
32 for (std::vector<MertLine>::size_type i = 0; i < lines.size(); i++) {
34 l.
x = -std::numeric_limits<double>::infinity();
36 if (lines[j - 1].m == l.
m) {
37 if (l.
y <= lines[j - 1].y)
42 l.
x = (l.
y - lines[j - 1].y) / (lines[j - 1].m - l.
m);
43 if (lines[j - 1].x < l.
x)
48 l.
x = -std::numeric_limits<double>::infinity();
58 std::ostringstream oss;
59 for (std::vector<MertLine>::size_type i = 0; i < lines.size(); ++i) {
60 oss <<
"line i=[" << std::right << std::setw (4) << i <<
"]" << std::fixed
61 << std::setprecision (6) <<
" x=[" << std::right << std::setw (12) << lines[i].x
62 <<
"]" <<
" y=[" << std::right << std::setw (12) << lines[i].y <<
"]" 63 <<
" m=[" << std::right << std::setw (12) << lines[i].m <<
"]";
64 if (show_hypothesis) {
65 oss <<
" t=[" << lines[i].t <<
"]";
74 fst (fst), lambda (lambda), direction (direction) {
78 envelopes.resize (
fst->NumStates() + 1);
82 envelopes[
fst->Start()].lines.push_back (
MertLine() );
86 const TupleArcFst::StateId& trg,
const TupleW& features,
const Wid& w = 0) {
87 for (
unsigned int i = 0; i < envelopes[src].lines.size(); ++i) {
88 MertLine line (envelopes[src].lines[i]);
94 envelopes[trg].lines.push_back (line);
99 for (fst::StateIterator < TupleArcFst > si (*
fst); !si.Done(); si.Next() ) {
100 const TupleArc::StateId& s = si.Value();
101 envelopes[s].SweepLine();
102 for (fst::ArcIterator < TupleArcFst > ai (*
fst, si.Value() ); !ai.Done();
110 envelopes[s].lines.clear();
115 envelopes[
fst->NumStates()].SweepLine();
123 return envelopes[
fst->NumStates()];
void PropagateEnvelope(const TupleArcFst::StateId &, const TupleArcFst::StateId &, const TupleW &, const Wid &w)
void InitializeEnvelopes()
void InitializeStartState()
Implements Tropical Sparse tuple weight semiring, extending from openfst SparsePowerWeight class...
MertLattice(TupleArcFst *, const PARAMS &, const PARAMS &)
void ComputeFinalEnvelope()
void ComputeStateEnvelopes()
std::vector< MertLine > lines
MertEnvelope ComputeLatticeEnvelope()
static Lines const ComputeLatticeEnvelope(TupleArcFst *, const PARAMS &, const PARAMS &)
std::string ToString(bool)
static const TropicalSparseTupleWeight< T > & Zero()
T DotProduct(const TropicalSparseTupleWeight< T > &w, const std::vector< T > &vw)
Implements Dot product of two vector weights.
bool GradientSortPredicate(const MertLine &line1, const MertLine &line2)