mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-26 19:37:58 +03:00
directory structure
This commit is contained in:
parent
c118849e97
commit
6e5a8ac39c
@ -1,147 +0,0 @@
|
||||
/*
|
||||
* Distortion.cpp
|
||||
*
|
||||
* Created on: 28 Oct 2015
|
||||
* Author: hieu
|
||||
*/
|
||||
|
||||
#include "Distortion.h"
|
||||
#include "Hypothesis.h"
|
||||
#include "Manager.h"
|
||||
#include "moses/Range.h"
|
||||
#include "moses/Bitmap.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct DistortionState_traditional : public Moses::FFState {
|
||||
Moses::Range range;
|
||||
int first_gap;
|
||||
DistortionState_traditional(const Moses::Range& wr, int fg) : range(wr), first_gap(fg) {}
|
||||
|
||||
size_t hash() const {
|
||||
return range.GetEndPos();
|
||||
}
|
||||
virtual bool operator==(const FFState& other) const {
|
||||
const DistortionState_traditional& o =
|
||||
static_cast<const DistortionState_traditional&>(other);
|
||||
return range.GetEndPos() == o.range.GetEndPos();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
Distortion::Distortion(size_t startInd, const std::string &line)
|
||||
:StatefulFeatureFunction(startInd, line)
|
||||
{
|
||||
ReadParameters();
|
||||
}
|
||||
|
||||
Distortion::~Distortion() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
const Moses::FFState* Distortion::EmptyHypothesisState(const Manager &mgr, const Phrase &input) const
|
||||
{
|
||||
MemPool &pool = mgr.GetPool();
|
||||
|
||||
// fake previous translated phrase start and end
|
||||
size_t start = NOT_FOUND;
|
||||
size_t end = NOT_FOUND;
|
||||
/*
|
||||
if (input.m_frontSpanCoveredLength > 0) {
|
||||
// can happen with --continue-partial-translation
|
||||
start = 0;
|
||||
end = input.m_frontSpanCoveredLength -1;
|
||||
}
|
||||
*/
|
||||
return new (pool.Allocate<DistortionState_traditional>()) DistortionState_traditional(
|
||||
Moses::Range(start, end),
|
||||
NOT_FOUND);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Distortion::EvaluateInIsolation(const System &system,
|
||||
const PhraseBase &source, const TargetPhrase &targetPhrase,
|
||||
Scores &scores,
|
||||
Scores *estimatedScore) const
|
||||
{
|
||||
}
|
||||
|
||||
Moses::FFState* Distortion::EvaluateWhenApplied(const Manager &mgr,
|
||||
const Hypothesis &hypo,
|
||||
const Moses::FFState &prevState,
|
||||
Scores &scores) const
|
||||
{
|
||||
MemPool &pool = mgr.GetPool();
|
||||
|
||||
const DistortionState_traditional &prev = static_cast<const DistortionState_traditional&>(prevState);
|
||||
SCORE distortionScore = CalculateDistortionScore(
|
||||
prev.range,
|
||||
hypo.GetRange(),
|
||||
prev.first_gap);
|
||||
//cerr << "distortionScore=" << distortionScore << endl;
|
||||
|
||||
scores.PlusEquals(mgr.GetSystem(), *this, distortionScore);
|
||||
|
||||
DistortionState_traditional* res = new (pool.Allocate<DistortionState_traditional>()) DistortionState_traditional(
|
||||
hypo.GetRange(),
|
||||
hypo.GetBitmap().GetFirstGapPos());
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
SCORE Distortion::CalculateDistortionScore(const Moses::Range &prev, const Moses::Range &curr, const int FirstGap) const
|
||||
{
|
||||
bool useEarlyDistortionCost = false;
|
||||
if(!useEarlyDistortionCost) {
|
||||
return - (SCORE) ComputeDistortionDistance(prev, curr);
|
||||
} else {
|
||||
/* Pay distortion score as soon as possible, from Moore and Quirk MT Summit 2007
|
||||
Definitions:
|
||||
S : current source range
|
||||
S' : last translated source phrase range
|
||||
S'' : longest fully-translated initial segment
|
||||
*/
|
||||
|
||||
int prefixEndPos = (int)FirstGap-1;
|
||||
if((int)FirstGap==-1)
|
||||
prefixEndPos = -1;
|
||||
|
||||
// case1: S is adjacent to S'' => return 0
|
||||
if ((int) curr.GetStartPos() == prefixEndPos+1) {
|
||||
//IFVERBOSE(4) std::cerr<< "MQ07disto:case1" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// case2: S is to the left of S' => return 2(length(S))
|
||||
if ((int) curr.GetEndPos() < (int) prev.GetEndPos()) {
|
||||
//IFVERBOSE(4) std::cerr<< "MQ07disto:case2" << std::endl;
|
||||
return (float) -2*(int)curr.GetNumWordsCovered();
|
||||
}
|
||||
|
||||
// case3: S' is a subsequence of S'' => return 2(nbWordBetween(S,S'')+length(S))
|
||||
if ((int) prev.GetEndPos() <= prefixEndPos) {
|
||||
//IFVERBOSE(4) std::cerr<< "MQ07disto:case3" << std::endl;
|
||||
int z = (int)curr.GetStartPos()-prefixEndPos - 1;
|
||||
return (float) -2*(z + (int)curr.GetNumWordsCovered());
|
||||
}
|
||||
|
||||
// case4: otherwise => return 2(nbWordBetween(S,S')+length(S))
|
||||
//IFVERBOSE(4) std::cerr<< "MQ07disto:case4" << std::endl;
|
||||
return (float) -2*((int)curr.GetNumWordsBetween(prev) + (int)curr.GetNumWordsCovered());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int Distortion::ComputeDistortionDistance(const Moses::Range& prev, const Moses::Range& current) const
|
||||
{
|
||||
int dist = 0;
|
||||
if (prev.GetNumWordsCovered() == 0) {
|
||||
dist = current.GetStartPos();
|
||||
} else {
|
||||
dist = (int)prev.GetEndPos() - (int)current.GetStartPos() + 1 ;
|
||||
}
|
||||
return abs(dist);
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Distortion.h
|
||||
*
|
||||
* Created on: 28 Oct 2015
|
||||
* Author: hieu
|
||||
*/
|
||||
|
||||
#ifndef DISTORTION_H_
|
||||
#define DISTORTION_H_
|
||||
|
||||
#include "StatefulFeatureFunction.h"
|
||||
#include "moses/Range.h"
|
||||
#include "TypeDef.h"
|
||||
|
||||
class Distortion : public StatefulFeatureFunction
|
||||
{
|
||||
public:
|
||||
Distortion(size_t startInd, const std::string &line);
|
||||
virtual ~Distortion();
|
||||
|
||||
virtual const Moses::FFState* EmptyHypothesisState(const Manager &mgr, const Phrase &input) const;
|
||||
|
||||
virtual void
|
||||
EvaluateInIsolation(const System &system,
|
||||
const PhraseBase &source,
|
||||
const TargetPhrase &targetPhrase,
|
||||
Scores &scores,
|
||||
Scores *estimatedScore) const;
|
||||
|
||||
virtual Moses::FFState* EvaluateWhenApplied(const Manager &mgr,
|
||||
const Hypothesis &hypo,
|
||||
const Moses::FFState &prevState,
|
||||
Scores &scores) const;
|
||||
|
||||
protected:
|
||||
SCORE CalculateDistortionScore(const Moses::Range &prev, const Moses::Range &curr, const int FirstGap) const;
|
||||
|
||||
int ComputeDistortionDistance(const Moses::Range& prev, const Moses::Range& current) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /* DISTORTION_H_ */
|
@ -7,7 +7,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "FeatureFunction.h"
|
||||
#include "System.h"
|
||||
#include "../System.h"
|
||||
#include "moses/Util.h"
|
||||
|
||||
using namespace std;
|
@ -8,17 +8,17 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include "FeatureFunctions.h"
|
||||
#include "StatefulFeatureFunction.h"
|
||||
#include "System.h"
|
||||
#include "../System.h"
|
||||
#include "../Scores.h"
|
||||
#include "../MemPool.h"
|
||||
|
||||
#include "SkeletonStatelessFF.h"
|
||||
#include "SkeletonStatefulFF.h"
|
||||
#include "PhraseTableMemory.h"
|
||||
#include "UnknownWordPenalty.h"
|
||||
#include "WordPenalty.h"
|
||||
#include "Distortion.h"
|
||||
#include "LanguageModel.h"
|
||||
#include "Scores.h"
|
||||
#include "MemPool.h"
|
||||
#include "TranslationModel/PhraseTableMemory.h"
|
||||
#include "TranslationModel/UnknownWordPenalty.h"
|
||||
#include "LM/LanguageModel.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -6,9 +6,9 @@
|
||||
*/
|
||||
#include <vector>
|
||||
#include "LanguageModel.h"
|
||||
#include "System.h"
|
||||
#include "Manager.h"
|
||||
#include "Hypothesis.h"
|
||||
#include "../../System.h"
|
||||
#include "../../Search/Manager.h"
|
||||
#include "../../Search/Hypothesis.h"
|
||||
#include "moses/Util.h"
|
||||
#include "moses/InputFileStream.h"
|
||||
#include "moses/LM/PointerState.h"
|
@ -8,11 +8,11 @@
|
||||
#ifndef LANGUAGEMODEL_H_
|
||||
#define LANGUAGEMODEL_H_
|
||||
|
||||
#include "StatefulFeatureFunction.h"
|
||||
#include "TypeDef.h"
|
||||
#include "../StatefulFeatureFunction.h"
|
||||
#include "../../TypeDef.h"
|
||||
#include "moses/Factor.h"
|
||||
#include "moses/TypeDef.h"
|
||||
#include "MorphoTrie/MorphTrie.h"
|
||||
#include "../../MorphoTrie/MorphTrie.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
struct LMScores
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
#include <boost/foreach.hpp>
|
||||
#include "PhraseTable.h"
|
||||
#include "InputPaths.h"
|
||||
#include "../../InputPaths.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -7,9 +7,9 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include "TargetPhrases.h"
|
||||
#include "Word.h"
|
||||
#include "StatelessFeatureFunction.h"
|
||||
#include "../../TargetPhrases.h"
|
||||
#include "../../Word.h"
|
||||
#include "../StatelessFeatureFunction.h"
|
||||
#include "moses/Util.h"
|
||||
|
||||
class System;
|
@ -8,11 +8,11 @@
|
||||
#include <cassert>
|
||||
#include <boost/foreach.hpp>
|
||||
#include "PhraseTableMemory.h"
|
||||
#include "Phrase.h"
|
||||
#include "TargetPhrase.h"
|
||||
#include "System.h"
|
||||
#include "Scores.h"
|
||||
#include "InputPaths.h"
|
||||
#include "../../Phrase.h"
|
||||
#include "../../TargetPhrase.h"
|
||||
#include "../../System.h"
|
||||
#include "../../Scores.h"
|
||||
#include "../../InputPaths.h"
|
||||
#include "moses/InputFileStream.h"
|
||||
|
||||
using namespace std;
|
@ -6,8 +6,9 @@
|
||||
*/
|
||||
|
||||
#include "UnknownWordPenalty.h"
|
||||
#include "System.h"
|
||||
#include "Manager.h"
|
||||
#include "../../System.h"
|
||||
#include "../../InputPath.h"
|
||||
#include "../../Search/Manager.h"
|
||||
|
||||
UnknownWordPenalty::UnknownWordPenalty(size_t startInd, const std::string &line)
|
||||
:PhraseTable(startInd, line)
|
@ -6,10 +6,9 @@
|
||||
*/
|
||||
|
||||
#include "WordPenalty.h"
|
||||
#include "TypeDef.h"
|
||||
#include "Scores.h"
|
||||
#include "TargetPhrase.h"
|
||||
#include "Manager.h"
|
||||
#include "../TypeDef.h"
|
||||
#include "../Scores.h"
|
||||
#include "../TargetPhrase.h"
|
||||
|
||||
WordPenalty::WordPenalty(size_t startInd, const std::string &line)
|
||||
:StatelessFeatureFunction(startInd, line)
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "InputPath.h"
|
||||
#include "PhraseTable.h"
|
||||
#include "FF/TranslationModel/PhraseTable.h"
|
||||
|
||||
InputPath::InputPath(const SubPhrase &subPhrase, const Moses::Range &range, size_t numPt)
|
||||
:m_subPhrase(subPhrase)
|
||||
|
@ -5,35 +5,36 @@ import option ;
|
||||
import path ;
|
||||
|
||||
exe moses2 :
|
||||
ArcLists.cpp
|
||||
Distortion.cpp
|
||||
FeatureFunction.cpp
|
||||
FeatureFunctions.cpp
|
||||
Hypothesis.cpp
|
||||
InputPath.cpp
|
||||
InputPaths.cpp
|
||||
LanguageModel.cpp
|
||||
Main.cpp
|
||||
Manager.cpp
|
||||
MemPool.cpp
|
||||
Phrase.cpp
|
||||
PhraseTable.cpp
|
||||
PhraseTableMemory.cpp
|
||||
Scores.cpp
|
||||
SearchNormal.cpp
|
||||
SkeletonStatefulFF.cpp
|
||||
SkeletonStatelessFF.cpp
|
||||
Stack.cpp
|
||||
StatefulFeatureFunction.cpp
|
||||
StatelessFeatureFunction.cpp
|
||||
Scores.cpp
|
||||
System.cpp
|
||||
TargetPhrase.cpp
|
||||
TargetPhrases.cpp
|
||||
UnknownWordPenalty.cpp
|
||||
Weights.cpp
|
||||
Weights.cpp
|
||||
Word.cpp
|
||||
WordPenalty.cpp
|
||||
|
||||
FF/Distortion.cpp
|
||||
FF/FeatureFunction.cpp
|
||||
FF/FeatureFunctions.cpp
|
||||
FF/SkeletonStatefulFF.cpp
|
||||
FF/SkeletonStatelessFF.cpp
|
||||
FF/StatefulFeatureFunction.cpp
|
||||
FF/StatelessFeatureFunction.cpp
|
||||
FF/WordPenalty.cpp
|
||||
FF/LM/LanguageModel.cpp
|
||||
FF/TranslationModel/PhraseTable.cpp
|
||||
FF/TranslationModel/PhraseTableMemory.cpp
|
||||
FF/TranslationModel/UnknownWordPenalty.cpp
|
||||
Search/ArcLists.cpp
|
||||
Search/Hypothesis.cpp
|
||||
Search/Manager.cpp
|
||||
Search/SearchNormal.cpp
|
||||
Search/Stack.cpp
|
||||
|
||||
|
||||
../../../moses//moses
|
||||
../../../OnDiskPt//OnDiskPt
|
||||
../../..//boost_filesystem
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
#include "System.h"
|
||||
#include "Manager.h"
|
||||
#include "Phrase.h"
|
||||
#include "Search/Manager.h"
|
||||
#include "moses/InputFileStream.h"
|
||||
#include "moses/Parameter.h"
|
||||
|
||||
|
@ -9,11 +9,11 @@
|
||||
#include <cstddef>
|
||||
#include <stdio.h>
|
||||
#include "Scores.h"
|
||||
#include "FeatureFunction.h"
|
||||
#include "FeatureFunctions.h"
|
||||
#include "Util.h"
|
||||
#include "Weights.h"
|
||||
#include "System.h"
|
||||
#include "FF/FeatureFunction.h"
|
||||
#include "FF/FeatureFunctions.h"
|
||||
#include "moses/Util.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -9,9 +9,9 @@
|
||||
#include <stdlib.h>
|
||||
#include "Hypothesis.h"
|
||||
#include "Manager.h"
|
||||
#include "System.h"
|
||||
#include "Scores.h"
|
||||
#include "StatefulFeatureFunction.h"
|
||||
#include "../System.h"
|
||||
#include "../Scores.h"
|
||||
#include "../FF/StatefulFeatureFunction.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <cstddef>
|
||||
#include "moses/FF/FFState.h"
|
||||
#include "moses/Bitmap.h"
|
||||
#include "Scores.h"
|
||||
#include "../Scores.h"
|
||||
|
||||
class Manager;
|
||||
class Phrase;
|
@ -6,13 +6,13 @@
|
||||
*/
|
||||
#include <boost/foreach.hpp>
|
||||
#include "Manager.h"
|
||||
#include "PhraseTable.h"
|
||||
#include "System.h"
|
||||
#include "SearchNormal.h"
|
||||
#include "TargetPhrases.h"
|
||||
#include "TargetPhrase.h"
|
||||
#include "InputPaths.h"
|
||||
#include "InputPath.h"
|
||||
#include "../System.h"
|
||||
#include "../TargetPhrases.h"
|
||||
#include "../TargetPhrase.h"
|
||||
#include "../InputPaths.h"
|
||||
#include "../InputPath.h"
|
||||
#include "../FF/TranslationModel/PhraseTable.h"
|
||||
#include "moses/Range.h"
|
||||
|
||||
using namespace std;
|
@ -10,10 +10,10 @@
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "InputPaths.h"
|
||||
#include "../InputPaths.h"
|
||||
#include "../TargetPhrase.h"
|
||||
#include "../MemPool.h"
|
||||
#include "Stack.h"
|
||||
#include "TargetPhrase.h"
|
||||
#include "MemPool.h"
|
||||
#include "moses/Bitmaps.h"
|
||||
#include "moses/SquareMatrix.h"
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include "SearchNormal.h"
|
||||
#include "Stack.h"
|
||||
#include "Manager.h"
|
||||
#include "InputPaths.h"
|
||||
#include "TargetPhrases.h"
|
||||
#include "TargetPhrase.h"
|
||||
#include "../InputPaths.h"
|
||||
#include "../TargetPhrases.h"
|
||||
#include "../TargetPhrase.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "Stack.h"
|
||||
#include "Hypothesis.h"
|
||||
#include "Scores.h"
|
||||
#include "../Scores.h"
|
||||
|
||||
Stack::Stack() {
|
||||
// TODO Auto-generated constructor stub
|
@ -8,8 +8,8 @@
|
||||
#include <iostream>
|
||||
#include <boost/foreach.hpp>
|
||||
#include "System.h"
|
||||
#include "FeatureFunction.h"
|
||||
#include "UnknownWordPenalty.h"
|
||||
#include "FF/FeatureFunction.h"
|
||||
#include "FF/TranslationModel/UnknownWordPenalty.h"
|
||||
#include "moses/Util.h"
|
||||
#include "util/exception.hh"
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "FeatureFunctions.h"
|
||||
#include "FF/FeatureFunctions.h"
|
||||
#include "Weights.h"
|
||||
#include "MemPool.h"
|
||||
#include "moses/FactorCollection.h"
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include <stdlib.h>
|
||||
#include "TargetPhrase.h"
|
||||
#include "Scores.h"
|
||||
#include "Manager.h"
|
||||
#include "System.h"
|
||||
#include "MemPool.h"
|
||||
#include "Search/Manager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "FeatureFunction.h"
|
||||
#include "FeatureFunctions.h"
|
||||
#include "FF/FeatureFunction.h"
|
||||
#include "FF/FeatureFunctions.h"
|
||||
#include "Weights.h"
|
||||
#include "moses/Util.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user