Cambridge SMT System
LMert.h
Go to the documentation of this file.
1 //Copyright (c) 2012, University of Cambridge
2 //All rights reserved.
3 //
4 //Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met://
5 //
6 // * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 // * Neither the name of the University of Cambridge nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9 //
10 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 
12 #ifndef LMERT_H_
13 #define LMERT_H_
14 
15 #include <vector>
16 
17 #include <fst/fstlib.h>
18 
19 #include "MertCommon.h"
20 #include "function-weight.h"
21 
22 bool GradientSortPredicate (const MertLine& line1, const MertLine& line2);
23 
24 class MertEnvelope {
25  public:
26  void SortLines(); // sort envelope lines by slope
27  void SweepLine(); // compute upper envelope of lines in array
28  std::string ToString (
29  bool); // returns lines that constitute the envelope as a string
30  std::vector<MertLine> lines; // lines that define the envelope / convex hull
31 };
32 
33 class MertLattice {
34  public:
35  MertLattice (TupleArcFst *, const PARAMS&, const PARAMS&);
36  void InitializeEnvelopes();
37  void InitializeStartState();
38  void PropagateEnvelope (const TupleArcFst::StateId&,
39  const TupleArcFst::StateId&,
40  const TupleW&, const Wid& w);
41  void ComputeStateEnvelopes();
42  void ComputeFinalEnvelope();
43  MertEnvelope ComputeLatticeEnvelope();
44  private:
46  std::vector<MertEnvelope> envelopes;
47  PARAMS lambda;
48  PARAMS direction;
49 };
50 
52  public:
53  typedef std::vector<MertLine> Lines;
54 
55  static Lines const ComputeLatticeEnvelope (TupleArcFst*, const PARAMS&,
56  const PARAMS&);
57 };
58 
59 #endif /* LMERT_H_ */
long long Wid
std::vector< MertLine > Lines
Definition: LMert.h:53
Definition: fstio.hpp:27
bool GradientSortPredicate(const MertLine &line1, const MertLine &line2)
Definition: LMert.cpp:21
Implements Tropical Sparse tuple weight semiring, extending from openfst SparsePowerWeight class...
std::vector< MertLine > lines
Definition: LMert.h:30
void SweepLine()
Definition: LMert.cpp:29
fst::VectorFst< TupleArc > TupleArcFst
std::string ToString(bool)
Definition: LMert.cpp:57
void SortLines()
Definition: LMert.cpp:25