mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 12:52:29 +03:00
5240c430ce
This adds a new string-to-tree decoder, which can be enabled with the -s2t option. It's intended to be faster and simpler than the generic chart decoder, and is designed to support lattice input (still WIP). For a en-de system trained on WMT14 data, it's approximately 40% faster in practice. For background information, see the decoding section of the EMNLP tutorial on syntax-based MT: http://www.emnlp2014.org/tutorials/5_notes.pdf Some features are not implemented yet, including support for internal tree structure and soft source-syntactic constraints.
39 lines
667 B
C++
39 lines
667 B
C++
#pragma once
|
|
|
|
#include "moses/FF/FFState.h"
|
|
|
|
#include "SVertex.h"
|
|
|
|
namespace Moses
|
|
{
|
|
namespace Syntax
|
|
{
|
|
|
|
struct SVertexRecombinationOrderer
|
|
{
|
|
public:
|
|
bool operator()(const SVertex &x, const SVertex &y) const
|
|
{
|
|
int comp = 0;
|
|
for (std::size_t i = 0; i < x.state.size(); ++i) {
|
|
if (x.state[i] == NULL || y.state[i] == NULL) {
|
|
comp = x.state[i] - y.state[i];
|
|
} else {
|
|
comp = x.state[i]->Compare(*y.state[i]);
|
|
}
|
|
if (comp != 0) {
|
|
return comp < 0;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool operator()(const SVertex *x, const SVertex *y) const
|
|
{
|
|
return operator()(*x, *y);
|
|
}
|
|
};
|
|
|
|
} // Syntax
|
|
} // Moses
|