mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 05:55:02 +03:00
daily automatic beautifier
This commit is contained in:
parent
aec2d51ce5
commit
adbb1c897a
@ -25,7 +25,7 @@ ArcLists::ArcLists()
|
||||
|
||||
ArcLists::~ArcLists()
|
||||
{
|
||||
BOOST_FOREACH(const Coll::value_type &collPair, m_coll){
|
||||
BOOST_FOREACH(const Coll::value_type &collPair, m_coll) {
|
||||
const ArcList *arcList = collPair.second;
|
||||
delete arcList;
|
||||
}
|
||||
@ -41,14 +41,12 @@ void ArcLists::AddArc(bool added, const HypothesisBase *currHypo,
|
||||
if (otherHypo) {
|
||||
// there was a existing losing hypo
|
||||
arcList = &GetAndDetachArcList(otherHypo);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// there was no existing hypo
|
||||
arcList = new ArcList;
|
||||
}
|
||||
m_coll[currHypo] = arcList;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// we're losers!
|
||||
// there should be a winner, we're not doing beam pruning
|
||||
UTIL_THROW_IF2(otherHypo == NULL, "There must have been a winning hypo");
|
||||
@ -73,7 +71,7 @@ const ArcList &ArcLists::GetArcList(const HypothesisBase *hypo) const
|
||||
|
||||
if (iter == m_coll.end()) {
|
||||
cerr << "looking for:" << hypo << " have " << m_coll.size() << " :";
|
||||
BOOST_FOREACH(const Coll::value_type &collPair, m_coll){
|
||||
BOOST_FOREACH(const Coll::value_type &collPair, m_coll) {
|
||||
const HypothesisBase *hypo = collPair.first;
|
||||
cerr << hypo << " ";
|
||||
}
|
||||
@ -97,7 +95,7 @@ ArcList &ArcLists::GetAndDetachArcList(const HypothesisBase *hypo)
|
||||
|
||||
void ArcLists::Sort()
|
||||
{
|
||||
BOOST_FOREACH(Coll::value_type &collPair, m_coll){
|
||||
BOOST_FOREACH(Coll::value_type &collPair, m_coll) {
|
||||
ArcList &list = *collPair.second;
|
||||
std::sort(list.begin(), list.end(), HypothesisFutureScoreOrderer() );
|
||||
}
|
||||
@ -118,7 +116,7 @@ void ArcLists::Delete(const HypothesisBase *hypo)
|
||||
std::string ArcLists::Debug(const System &system) const
|
||||
{
|
||||
stringstream strm;
|
||||
BOOST_FOREACH(const Coll::value_type &collPair, m_coll){
|
||||
BOOST_FOREACH(const Coll::value_type &collPair, m_coll) {
|
||||
const ArcList *arcList = collPair.second;
|
||||
strm << arcList << "(" << arcList->size() << ") ";
|
||||
}
|
||||
|
@ -13,26 +13,21 @@ public:
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
//! iterators
|
||||
const_iterator begin() const
|
||||
{
|
||||
const_iterator begin() const {
|
||||
return m_arr;
|
||||
}
|
||||
const_iterator end() const
|
||||
{
|
||||
const_iterator end() const {
|
||||
return m_arr + m_size;
|
||||
}
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
iterator begin() {
|
||||
return m_arr;
|
||||
}
|
||||
iterator end()
|
||||
{
|
||||
iterator end() {
|
||||
return m_arr + m_size;
|
||||
}
|
||||
|
||||
Array(MemPool &pool, size_t size = 0, const T &val = T())
|
||||
{
|
||||
Array(MemPool &pool, size_t size = 0, const T &val = T()) {
|
||||
m_size = size;
|
||||
m_maxSize = size;
|
||||
m_arr = pool.Allocate<T>(size);
|
||||
@ -41,26 +36,23 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
size_t size() const
|
||||
{
|
||||
size_t size() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
const T& operator[](size_t ind) const
|
||||
{
|
||||
const T& operator[](size_t ind) const {
|
||||
return m_arr[ind];
|
||||
}
|
||||
|
||||
T& operator[](size_t ind)
|
||||
{
|
||||
T& operator[](size_t ind) {
|
||||
return m_arr[ind];
|
||||
}
|
||||
|
||||
T *GetArray()
|
||||
{ return m_arr; }
|
||||
T *GetArray() {
|
||||
return m_arr;
|
||||
}
|
||||
|
||||
size_t hash() const
|
||||
{
|
||||
size_t hash() const {
|
||||
size_t seed = 0;
|
||||
for (size_t i = 0; i < m_size; ++i) {
|
||||
boost::hash_combine(seed, m_arr[i]);
|
||||
@ -68,21 +60,18 @@ public:
|
||||
return seed;
|
||||
}
|
||||
|
||||
int Compare(const Array &compare) const
|
||||
{
|
||||
int Compare(const Array &compare) const {
|
||||
|
||||
int cmp = memcmp(m_arr, compare.m_arr, sizeof(T) * m_size);
|
||||
return cmp;
|
||||
}
|
||||
|
||||
bool operator==(const Array &compare) const
|
||||
{
|
||||
bool operator==(const Array &compare) const {
|
||||
int cmp = Compare(compare);
|
||||
return cmp == 0;
|
||||
}
|
||||
|
||||
void resize(size_t newSize)
|
||||
{
|
||||
void resize(size_t newSize) {
|
||||
assert(m_size < m_maxSize);
|
||||
m_size = newSize;
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ class EstimatedScores: public Matrix<float>
|
||||
{
|
||||
public:
|
||||
EstimatedScores(MemPool &pool, size_t size) :
|
||||
Matrix<float>(pool, size, size)
|
||||
{
|
||||
Matrix<float>(pool, size, size) {
|
||||
}
|
||||
|
||||
~EstimatedScores(); // not implemented
|
||||
@ -45,8 +44,7 @@ public:
|
||||
float CalcEstimatedScore(Bitmap const&) const;
|
||||
float CalcEstimatedScore(Bitmap const&, size_t startPos, size_t endPos) const;
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const
|
||||
{
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const {
|
||||
for (size_t endPos = 0; endPos < GetSize(); endPos++) {
|
||||
for (size_t startPos = 0; startPos < GetSize(); startPos++)
|
||||
out << GetValue(startPos, endPos) << " ";
|
||||
|
@ -16,36 +16,30 @@ using namespace std;
|
||||
namespace Moses2
|
||||
{
|
||||
|
||||
struct DistortionState_traditional: public FFState
|
||||
{
|
||||
struct DistortionState_traditional: public FFState {
|
||||
Range range;
|
||||
int first_gap;
|
||||
|
||||
DistortionState_traditional() :
|
||||
range()
|
||||
{
|
||||
range() {
|
||||
// uninitialised
|
||||
}
|
||||
|
||||
void Set(const Range& wr, int fg)
|
||||
{
|
||||
void Set(const Range& wr, int fg) {
|
||||
range = wr;
|
||||
first_gap = fg;
|
||||
}
|
||||
|
||||
size_t hash() const
|
||||
{
|
||||
size_t hash() const {
|
||||
return range.GetEndPos();
|
||||
}
|
||||
virtual bool operator==(const FFState& other) const
|
||||
{
|
||||
virtual bool operator==(const FFState& other) const {
|
||||
const DistortionState_traditional& o =
|
||||
static_cast<const DistortionState_traditional&>(other);
|
||||
return range.GetEndPos() == o.range.GetEndPos();
|
||||
}
|
||||
|
||||
virtual std::string ToString() const
|
||||
{
|
||||
virtual std::string ToString() const {
|
||||
stringstream sb;
|
||||
sb << first_gap << " " << range;
|
||||
return sb.str();
|
||||
@ -128,8 +122,7 @@ SCORE Distortion::CalculateDistortionScore(const Range &prev, const Range &curr,
|
||||
bool useEarlyDistortionCost = false;
|
||||
if (!useEarlyDistortionCost) {
|
||||
return -(SCORE) ComputeDistortionDistance(prev, curr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Pay distortion score as soon as possible, from Moore and Quirk MT Summit 2007
|
||||
Definitions:
|
||||
S : current source range
|
||||
@ -173,8 +166,7 @@ int Distortion::ComputeDistortionDistance(const Range& prev,
|
||||
int dist = 0;
|
||||
if (prev.GetNumWordsCovered() == 0) {
|
||||
dist = current.GetStartPos();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dist = (int) prev.GetEndPos() - (int) current.GetStartPos() + 1;
|
||||
}
|
||||
return abs(dist);
|
||||
|
@ -35,8 +35,7 @@ public:
|
||||
const TargetPhrase<SCFG::Word> &targetPhrase, Scores &scores,
|
||||
SCORE &estimatedScore) const;
|
||||
|
||||
virtual void EvaluateWhenApplied(const std::deque<Hypothesis*> &hypos) const
|
||||
{
|
||||
virtual void EvaluateWhenApplied(const std::deque<Hypothesis*> &hypos) const {
|
||||
}
|
||||
|
||||
virtual void EvaluateWhenApplied(const ManagerBase &mgr,
|
||||
|
Loading…
Reference in New Issue
Block a user