13 #include <fst/fstlib.h> 20 return os <<
"x:" << ml.
x <<
" y:" << ml.
y <<
" m:" << ml.
m;
26 is >> a >> b >> ml.
x >> a >> b >> ml.
y >> a >> b >> ml.
m;
32 for (std::list<MertLine>::const_iterator it = l.begin(); it != l.end(); it++) {
39 return thisML.
y == that.
y && thisML.
m == that.
m;
48 i1 (i1), i2 (i2), i1end (i1end), i2end (i2end) {
49 if (i1 == i1end && i2 != i2end) {
52 }
else if (i1 != i1end && i2 == i2end) {
55 }
else if (i1 != i1end && i2 != i2end) {
83 if (currList == 1 && i1 != i1end) {
85 }
else if (currList == 2 && i2 != i2end) {
88 if (i2 != i2end && i1 != i1end) {
97 if (i2 == i2end && i1 != i1end) {
100 }
else if (i2 != i2end && i1 == i1end) {
114 if (this->isEnd() == that.isEnd() ) {
118 equals &= this->i1 == that.i1;
119 equals &= this->i2 == that.i2;
120 equals &= this->currList == that.currList;
121 equals &= this->currIter == that.currIter;
126 return ! (*
this == that);
129 bool CompIter::isEnd()
const {
130 return i1 == i1end && i2 == i2end;
134 return CompIter (l1.begin(), l2.begin(), l1.end(), l2.end() );
138 return CompIter (l1.end(), l2.end(), l1.end(), l2.end() );
147 if (this->values.size() != w1.values.size() ) {
150 return equal (this->values.begin(), this->values.end(), w1.values.begin() );
154 return ! (*
this == w1);
160 return fst::TropicalWeightTpl<F> (l.
m * gamma + l.
y);
170 if (w1.values.size() == 1) {
171 singleton = w1.values;
172 fullList = w2.values;
173 }
else if (w2.values.size() == 1) {
174 singleton = w2.values;
175 fullList = w1.values;
177 cout <<
"No singleton list!" << endl;
180 MertLine multiplier = singleton.front();
187 for (
MertIter it = fullList.begin(); it != fullList.end(); ++it) {
192 output.push_back (l);
201 outputList.insert (outputList.begin(), w2.values.begin(), w2.values.end() );
204 outputList.insert (outputList.begin(), w1.values.begin(), w1.values.end() );
209 static const MertLine dummy (0, 0, 0);
210 outputList.push_front (dummy);
211 MertList::iterator output = outputList.begin();
213 if (output != outputList.begin() ) {
214 if (output->m == (*l).m) {
215 if ( (*l).y >= output->y)
219 while (output != outputList.begin() ) {
220 (*l).x = ( (*l).y - output->y) / (output->m - (*l).m);
221 if (output->x < (*l).x)
225 if (output == outputList.begin() )
226 (*l).x = -std::numeric_limits<double>::infinity();
227 output = outputList.insert (++output, *l);
229 output = outputList.insert (++output, *l);
233 outputList.pop_front();
235 outputList.erase (++output, outputList.end() );
243 for (MertList::const_iterator it = v.begin(); it != v.end(); ++it) {
251 MertList::size_type size;
254 for (MertList::size_type i = 0; i < size; ++i) {
257 outList.push_back (l);
267 for (MertList::const_iterator it = v.begin(); it != v.end(); ++it) {
275 MertList::size_type size;
278 for (MertList::size_type i = 0; i < size; ++i) {
281 outList.push_back (l);
283 this->values = outList;
288 cout <<
"aaw35 Tried to access hash function" << endl;
298 cout <<
"aaw35 Tried to access divide function" << endl;
fst::TropicalWeightTpl< F > Map(F) const
MertList::iterator MertIter
bool operator==(const MertLine &thisML, const MertLine &that)
std::ostream & operator<<(std::ostream &os, const MertLine &ml)
static const FunctionWeight & Zero()
bool operator==(const FunctionWeight &) const
CompositeList(const MertList &l1, const MertList &l2)
std::ostream & Write(std::ostream &strm) const
const MertList & Value() const
bool operator==(const cl_iterator &)
bool operator!=(const FunctionWeight &) const
bool operator!=(const cl_iterator &)
FunctionWeight Times(const FunctionWeight &w1, const FunctionWeight &w2)
std::istream & Read(std::istream &strm)
FunctionWeight Divide(const FunctionWeight &fw1, const FunctionWeight &, fst::DivideType t=fst::DIVIDE_ANY)
std::list< MertLine > MertList
CompositeList::cl_iterator CompIter
ReverseWeight Reverse() const
cl_iterator(MertIter, MertIter, MertIter, MertIter)
std::istream & operator>>(std::istream &is, MertLine &ml)
FunctionWeight Plus(const FunctionWeight &w1, const FunctionWeight &w2)
cl_iterator & operator++()
bool ApproxEqual(const FunctionWeight &w1, const FunctionWeight &w2, float delta)