Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorccorbett <ccorbett@1f5c12ca-751b-0410-a591-d2e778427230>2006-07-25 19:52:09 +0400
committerccorbett <ccorbett@1f5c12ca-751b-0410-a591-d2e778427230>2006-07-25 19:52:09 +0400
commitee3e1e1576e33e17e9ee1d58fed221001a7e4f68 (patch)
tree5098dd2bd46f6619edecbb2a4c7c6456d8e2989b
parentfadad52ad0e35d74ed4f441607a3fcf7cfd723cc (diff)
Lexical reordering framework; confusion net still not working but Chris implied that was ok. All other regression tests passed
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@276 1f5c12ca-751b-0410-a591-d2e778427230
-rw-r--r--moses-cmd/.settings/org.eclipse.cdt.managedbuilder.core.prefs5
-rw-r--r--moses-cmd/src/Main.cpp10
-rwxr-xr-xmoses/.cdtbuild8
-rwxr-xr-xmoses/src/Hypothesis.cpp53
-rwxr-xr-xmoses/src/Hypothesis.h53
-rw-r--r--moses/src/Input.h3
-rwxr-xr-xmoses/src/LanguageModel_IRST.cpp3
-rwxr-xr-xmoses/src/LexicalReordering.cpp104
-rwxr-xr-xmoses/src/LexicalReordering.h15
-rwxr-xr-xmoses/src/Manager.cpp1
-rwxr-xr-xmoses/src/Phrase.cpp16
-rwxr-xr-xmoses/src/Phrase.h4
-rwxr-xr-xmoses/src/StaticData.cpp14
-rwxr-xr-xmoses/src/StaticData.h5
-rwxr-xr-xmoses/src/TypeDef.h17
15 files changed, 251 insertions, 60 deletions
diff --git a/moses-cmd/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/moses-cmd/.settings/org.eclipse.cdt.managedbuilder.core.prefs
index 25d881341..6e3c357b6 100644
--- a/moses-cmd/.settings/org.eclipse.cdt.managedbuilder.core.prefs
+++ b/moses-cmd/.settings/org.eclipse.cdt.managedbuilder.core.prefs
@@ -1,4 +1,7 @@
-#Fri Jul 21 22:31:59 EDT 2006
+#Tue Jul 25 11:19:35 EDT 2006
+=\=\=\=\=\=\=
+<<<<<<<=org.eclipse.cdt.managedbuilder.core.prefs
+>>>>>>>=1.2
eclipse.preferences.version=1
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.807464492=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.862821065=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
diff --git a/moses-cmd/src/Main.cpp b/moses-cmd/src/Main.cpp
index 78655d1e7..1ae879410 100644
--- a/moses-cmd/src/Main.cpp
+++ b/moses-cmd/src/Main.cpp
@@ -76,12 +76,14 @@ int main(int argc, char* argv[])
timer.start("Starting...");
StaticData staticData;
+
if (!staticData.LoadParameters(argc, argv))
return EXIT_FAILURE;
-/*
- boost::shared_ptr<UnknownWordHandler> unknownWordHandler(new UnknownWordHandler);
+
+ /*
+ * boost::shared_ptr<UnknownWordHandler> unknownWordHandler(new UnknownWordHandler);
staticData.SetUnknownWordHandler(unknownWordHandler);
-*/
+ */
if (staticData.GetVerboseLevel() > 0)
{
#if N_BEST
@@ -91,6 +93,7 @@ int main(int argc, char* argv[])
#endif
}
+
// set up read/writing class
InputOutput *inputOutput = GetInputOutput(staticData);
@@ -129,6 +132,7 @@ int main(int argc, char* argv[])
delete source;
delete translationOptionCollection;
}
+
delete inputOutput;
diff --git a/moses/.cdtbuild b/moses/.cdtbuild
index d05f52bf0..7c7fdc53b 100755
--- a/moses/.cdtbuild
+++ b/moses/.cdtbuild
@@ -10,6 +10,8 @@
<option id="gnu.cpp.compiler.option.preprocessor.def.2071633498" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="LM_SRI"/>
<listOptionValue builtIn="false" value="TRACE_ENABLE"/>
+<listOptionValue builtIn="false" value="_FILE_OFFSET_BITS=64"/>
+<listOptionValue builtIn="false" value="_LARGE_FILES"/>
</option>
<option id="gnu.cpp.compiler.option.include.paths.560695438" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="${ProjDirPath}/../boost/include/boost-1_33_1"/>
@@ -43,7 +45,9 @@
<listOptionValue builtIn="false" value="${ProjDirPath}/../mysqlpp/lib"/>
</option>
<option id="gnu.cpp.compiler.option.preprocessor.def.444585015" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="_LARGE_FILES"/>
<listOptionValue builtIn="false" value="LM_SRI"/>
+<listOptionValue builtIn="false" value="_FILE_OFFSET_BITS=64"/>
<listOptionValue builtIn="false" value="TRACE_ENABLE"/>
</option>
</tool>
@@ -58,6 +62,8 @@
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.57605597" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug">
<option id="gnu.cpp.compiler.option.preprocessor.def.547610699" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="LM_SRI"/>
+<listOptionValue builtIn="false" value="_FILE_OFFSET_BITS=64"/>
+<listOptionValue builtIn="false" value="_LARGE_FILES"/>
<listOptionValue builtIn="false" value="TRACE_ENABLE"/>
<listOptionValue builtIn="false" value="N_BEST"/>
</option>
@@ -93,6 +99,8 @@
</option>
<option id="gnu.cpp.compiler.option.preprocessor.def.1390867069" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
<listOptionValue builtIn="false" value="LM_SRI"/>
+<listOptionValue builtIn="false" value="_FILE_OFFSET_BITS=64"/>
+<listOptionValue builtIn="false" value="_LARGE_FILES"/>
<listOptionValue builtIn="false" value="TRACE_ENABLE"/>
<listOptionValue builtIn="false" value="N_BEST"/>
</option>
diff --git a/moses/src/Hypothesis.cpp b/moses/src/Hypothesis.cpp
index d39022e85..ac80a6346 100755
--- a/moses/src/Hypothesis.cpp
+++ b/moses/src/Hypothesis.cpp
@@ -28,22 +28,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "Util.h"
#include "Arc.h"
#include "SquareMatrix.h"
+#include "LexicalReordering.h"
#include "StaticData.h"
#include "Input.h"
#include "LMList.h"
#include "md5.h"
-//TODO: add this include in when it compiles
-//#include "LexicalReordering.h"
-
using namespace std;
-
+unsigned int Hypothesis::s_numNodes = 0;
unsigned int Hypothesis::s_HypothesesCreated = 0;
+
Hypothesis::Hypothesis(InputType const& source)
: LatticeEdge(Output)
, m_sourceCompleted(source.GetSize())
+ , m_sourceInput(source)
, m_currSourceWordsRange(NOT_FOUND, NOT_FOUND)
, m_currTargetWordsRange(NOT_FOUND, NOT_FOUND)
, m_wordDeleted(false)
@@ -55,6 +55,7 @@ Hypothesis::Hypothesis(InputType const& source)
Hypothesis::Hypothesis(const Hypothesis &copy)
: LatticeEdge (Output, copy.m_prevHypo)
+ , m_sourceInput (copy.m_sourceInput)
, m_sourceCompleted (copy.m_sourceCompleted )
, m_currSourceWordsRange (copy.m_currSourceWordsRange)
, m_currTargetWordsRange (copy.m_currTargetWordsRange)
@@ -72,6 +73,8 @@ Hypothesis::Hypothesis(const Hypothesis &copy)
*/
Hypothesis::Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt)
: LatticeEdge (Output, &prevHypo)
+
+ , m_sourceInput (prevHypo.m_sourceInput)
, m_sourceCompleted (prevHypo.m_sourceCompleted )
, m_currSourceWordsRange (transOpt.GetSourceWordsRange())
, m_currTargetWordsRange ( prevHypo.m_currTargetWordsRange.GetEndPos() + 1
@@ -133,6 +136,7 @@ Hypothesis* Hypothesis::Create(const Hypothesis &prevHypo, const TranslationOpti
/***
* return the subclass of Hypothesis most appropriate to the given target phrase
*/
+
Hypothesis* Hypothesis::Create(InputType const& m_source)
{
return new Hypothesis(m_source);
@@ -297,17 +301,6 @@ int Hypothesis::NGramCompare(const Hypothesis &compare, size_t nGramSize) const
// identical
return 0;
}
-void Hypothesis::CalcLexicalReorderingScore()
-{
-//TODO: should referece a copy of the lexical reorderrrrr, rather than pass in
-// m_score[ScoreType::LexicalReordering] = LexicalReordering::CalcLexicalReorderingScore(
-// m_sourceCompleted, //number source words covered,
-// m_currTargetWordsRange, //Current Target Range,
-// LatticeEdge.getPrevHypo().getCurrSourceWordsRange(), //Previous Source Range,
-// m_currentSourceWordsRange, //Current Source Range,
-// LatticeEdge.getPrevHypo()); //Previous Hypothesis
-}
-
/**
* Calculates the overall language model score by combining the scores
* of language models generated for each of the factors. Because the factors
@@ -444,7 +437,17 @@ void Hypothesis::CalcLMScore(const LMList &lmListInitial, const LMList &lmListEn
}
}
+
+//void Hypothesis::CalcScore(const LMList &lmListInitial
+// , const LMList &lmListEnd
+// , float weightDistortion
+// , float weightWordPenalty
+// , const SquareMatrix &futureScore
+// , const Sentence &source
+// , LexicalReordering *m_lexreorder)
+//=======
void Hypothesis::CalcDistortionScore()
+
{
const WordsRange &prevRange = m_prevHypo->GetCurrSourceWordsRange()
, &currRange = GetCurrSourceWordsRange();
@@ -476,9 +479,24 @@ void Hypothesis::CalcScore(const StaticData& staticData, const SquareMatrix &fut
// FUTURE COST
CalcFutureScore(futureScore);
+
//LEXICAL REORDERING COST
- CalcLexicalReorderingScore();
+ LexicalReordering *m_lexReorder = staticData.GetLexReorder();
+ if(m_lexReorder == NULL)
+ {
+ //we're not scoring lexical reordering, so we add in a zero
+ m_score[ScoreType::LexicalReordering] = 0;
+ }
+ else
+ {
+ //we're scoring lexical reordering, so we add in the score
+ m_score[ScoreType::LexicalReordering] = m_lexReorder->CalcScore(this);
+ }
+
+
+
+
// TOTAL COST
m_score[ScoreType::Total] = m_score[ScoreType::PhraseTrans]
@@ -486,7 +504,8 @@ void Hypothesis::CalcScore(const StaticData& staticData, const SquareMatrix &fut
+ m_score[ScoreType::LanguageModelScore]
+ m_score[ScoreType::Distortion] * staticData.GetWeightDistortion()
+ m_score[ScoreType::WordPenalty] * staticData.GetWeightWordPenalty()
- + m_score[ScoreType::FutureScoreEnum];
+ + m_score[ScoreType::FutureScoreEnum]
+ + m_score[ScoreType::LexicalReordering];
}
void Hypothesis::CalcFutureScore(const SquareMatrix &futureScore)
diff --git a/moses/src/Hypothesis.h b/moses/src/Hypothesis.h
index e8b34367e..0e7dc536e 100755
--- a/moses/src/Hypothesis.h
+++ b/moses/src/Hypothesis.h
@@ -34,11 +34,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "Arc.h"
#include "LatticeEdge.h"
#include "ScoreComponentCollection.h"
+#include "LexicalReordering.h"
+#include "Input.h"
class SquareMatrix;
class StaticData;
class TranslationOption;
-class InputType;
class WordsRange;
class WordDeletionTable;
@@ -53,6 +54,10 @@ protected:
// phrase in target language. factors completed will be superset
// of those in dictionary
WordsBitmap m_sourceCompleted;
+ //TODO: how to integrate this into confusion network framework; what if
+ //it's a confusion network in the end???
+ //how to make a general InputType without getting abstract warnings.
+ InputType const& m_sourceInput;
WordsRange m_currSourceWordsRange, m_currTargetWordsRange;
bool m_wordDeleted;
#ifdef N_BEST
@@ -60,9 +65,19 @@ protected:
#endif
/***
- * \return whether none of the factors clash
- * \param phrase TODO ???
- */
+//<<<<<<< Hypothesis.h
+// * Used for initializing translation process
+// */
+// Hypothesis(const InputType &source);
+// // create next
+// Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt);
+//
+// /***
+//=======
+////>>>>>>> 1.16
+// * \return whether none of the factors clash
+// * \param phrase TODO ???
+// */
bool IsCompatible(const Phrase &phrase) const;
void CalcFutureScore(const SquareMatrix &futureScore);
@@ -70,13 +85,15 @@ protected:
void CalcLMScore(const LMList &lmListInitial, const LMList &lmListEnd);
void CalcDistortionScore();
//TODO: add appropriate arguments to score calculator
- void CalcLexicalReorderingScore();
+
void CalcDeletionScore(const Sentence& sourceSentence, const WordsRange& sourceWordsRange, const WordDeletionTable& wordDeletionTable);
+
public:
- static unsigned int s_HypothesesCreated; // Statistics: how many hypotheses were created in total
- static int s_numNodes; //TODO what is this?
+
+ static unsigned int s_HypothesesCreated; // Statistics: how many hypotheses were created in total
+ static unsigned int s_numNodes; // Statistics: how many hypotheses were created in total
int m_id;
/***
@@ -97,12 +114,14 @@ public:
/***
* return the subclass of Hypothesis most appropriate to the given target phrase
*/
+
static Hypothesis* Create(const WordsBitmap &initialCoverage);
/***
* return the subclass of Hypothesis most appropriate to the given target phrase
*/
static Hypothesis* Create(InputType const& source);
+
/***
* return the subclass of Hypothesis most appropriate to the given translation option
*/
@@ -124,16 +143,32 @@ public:
return m_currSourceWordsRange;
}
+ inline const WordsRange &GetCurrTargetWordsRange() const
+ {
+ return m_currTargetWordsRange;
+ }
+
// subsequent translation should only translate this sub-phrase
virtual size_t GetCurrTargetLength() const
+
{
return m_currTargetWordsRange.GetWordsCount();
}
+
+// void CalcScore(const LMList &lmListInitial
+// , const LMList &lmListEnd
+// , float weightDistortion
+// , float weightWordPenalty
+// , const SquareMatrix &futureScore
+// , const Sentence &source
+// , LexicalReordering *m_lexreorder=NULL);
+
virtual void CalcScore(const StaticData& staticData, const SquareMatrix &futureScore);
int GetId() const;
+
const Hypothesis* GetPrevHypo() const;
// same as for phrase
@@ -145,6 +180,10 @@ public:
{
return m_targetPhrase;
}
+ inline const InputType &GetSourcePhrase() const
+ {
+ return m_sourceInput;
+ }
// curr - pos is relative from CURRENT hypothesis's starting index
// (ie, start of sentence would be some negative number, which is
diff --git a/moses/src/Input.h b/moses/src/Input.h
index 3990d36e6..b90223d71 100644
--- a/moses/src/Input.h
+++ b/moses/src/Input.h
@@ -31,7 +31,7 @@ protected:
{ // for db stuff;
m_translationId = translationId;
}
- virtual size_t GetSize() const=0;
+ virtual size_t GetSize() const=0;
virtual int Read(std::istream& in,const std::vector<FactorType>& factorOrder, FactorCollection &factorCollection) =0;
@@ -40,7 +40,6 @@ protected:
virtual TargetPhraseCollection const* CreateTargetPhraseCollection(PhraseDictionaryBase const& d,const WordsRange& r) const=0;
virtual TranslationOptionCollection* CreateTranslationOptionCollection() const=0;
- // these functions are not (yet) well-defined for confusion networks
virtual Phrase GetSubString(const WordsRange&) const =0;
virtual const FactorArray& GetFactorArray(size_t pos) const=0;
};
diff --git a/moses/src/LanguageModel_IRST.cpp b/moses/src/LanguageModel_IRST.cpp
index 6dc228cab..3d4dfa217 100755
--- a/moses/src/LanguageModel_IRST.cpp
+++ b/moses/src/LanguageModel_IRST.cpp
@@ -62,7 +62,10 @@ void LanguageModel_IRST::Load(size_t id
InputFileStream inp(fileName);
+
+
m_lmtb = new lmtable(inp);
+
// LM can be ok, just outputs warnings
CreateFactors(factorCollection);
diff --git a/moses/src/LexicalReordering.cpp b/moses/src/LexicalReordering.cpp
index 0977e11f6..aad63db6e 100755
--- a/moses/src/LexicalReordering.cpp
+++ b/moses/src/LexicalReordering.cpp
@@ -3,6 +3,7 @@
#include <assert.h>
#include "LexicalReordering.h"
#include "InputFileStream.h"
+#include "DistortionOrientation.h"
using namespace std;
@@ -52,7 +53,7 @@ void LexicalReordering::LoadFile()
key = f;
probs = Scan<float>(Tokenize(tokens[F_PROBS]));
}
- if (m_orientation == LexReorderType::Monotone)
+ if (m_orientation == DistortionOrientationType::Monotone)
{
assert(probs.size() == MONO_NUM_PROBS); // 2 backward, 2 forward
}
@@ -90,23 +91,98 @@ void LexicalReordering::PrintTable()
}
}
+float LexicalReordering::GetProbability(Hypothesis *hypothesis, int orientation)
+{
+ vector<float> val;
+ //this phrase declaration is to get around const mumbo jumbo and let me call a
+ //"convert to a string" method
+ Phrase myphrase = hypothesis->GetPhrase();
+ if(m_condition==LexReorderType::Fe)
+ {
+ //this key string is be F+'|||'+E from the hypothesis
+ val=m_orientation_table[myphrase.GetStringRep(hypothesis->GetCurrSourceWordsRange())
+ +"|||"
+ +myphrase.GetStringRep(hypothesis->GetCurrTargetWordsRange())];
+
+ }
+ else
+ {
+ //this key string is F from the hypothesis
+ val=m_orientation_table[ myphrase.GetStringRep(hypothesis->GetCurrTargetWordsRange())];
+ }
+ int index = 0;
+ if(m_orientation==DistortionOrientationType::Msd)
+ {
+ if(m_direction==LexReorderType::Backward)
+ {
+ if(orientation==DistortionOrientationType::MONO)
+ {
+ index=BACK_M;
+ }
+ else if(orientation==DistortionOrientationType::SWAP)
+ {
+ index=BACK_S;
+ }
+ else
+ {
+ index=BACK_D;
+ }
+
+ }
+ else
+ {
+ if(orientation==DistortionOrientationType::MONO)
+ {
+ index=FOR_M;
+ }
+ else if(orientation==DistortionOrientationType::SWAP)
+ {
+ index=FOR_S;
+ }
+ else
+ {
+ index=FOR_D;
+ }
+ }
+ }
+ else
+ {
+ if(m_direction==LexReorderType::Backward)
+ {
+ if(orientation==DistortionOrientationType::MONO)
+ {
+ index=BACK_MONO;
+ }
+ else
+ {
+ index=BACK_NONMONO;
+ }
+ }
+ else
+ {
+ if(orientation==DistortionOrientationType::MONO)
+ {
+ index=FOR_MONO;
+ }
+ else
+ {
+ index=FOR_NONMONO;
+ }
+ }
+ }
+ return val[index];
+}
+
/*
* Compute the score for the current hypothesis.
*/
-float LexicalReordering::CalcScore(int numSourceWords,
- WordsRange &currTargetRange,
- WordsRange &prevSourceRange,
- WordsRange &currSourceRange)
+float LexicalReordering::CalcScore(Hypothesis *curr_hypothesis)
{
+
// First determine if this hypothesis is monotonic, non-monotonic,
- // swap, or discontinuous
- size_t prev_source_start = prevSourceRange.GetStartPos();
- size_t prev_source_end = prevSourceRange.GetEndPos();
- size_t curr_source_start = currSourceRange.GetStartPos();
- size_t curr_source_end = currSourceRange.GetEndPos();
- size_t curr_target_start = currTargetRange.GetStartPos();
- size_t curr_target_end = currTargetRange.GetEndPos();
-
- return 0;
+ // swap, or discontinuous. Make this determination using DistortionOrientation class
+ int orientation = DistortionOrientation::GetOrientation(curr_hypothesis, m_direction);
+ //now looking up in the table the appropriate score for these orientation
+ return GetProbability(curr_hypothesis, orientation);
}
diff --git a/moses/src/LexicalReordering.h b/moses/src/LexicalReordering.h
index f92285072..0fb1bfe09 100755
--- a/moses/src/LexicalReordering.h
+++ b/moses/src/LexicalReordering.h
@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <vector>
#include <map>
#include "Factor.h"
+#include "Phrase.h"
#include "TypeDef.h"
#include "Util.h"
#include "WordsRange.h"
@@ -32,6 +33,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
class FactorCollection;
class Factor;
class Phrase;
+class Hypothesis;
+
/***
* The LexicalReordering class handles everything involved with
@@ -39,6 +42,7 @@ class Phrase;
* and computes scores in either forward, backward, or bidirectional
* direction.
*/
+
class LexicalReordering
{
@@ -49,7 +53,8 @@ private:
// This is the order in which the different forward/backward
// probabilities are stored in the table.
- enum TableLookup { BACK_M, BACK_S, BACK_D, FOR_M, FOR_S, FOR_D };
+ enum TableLookupMsd { BACK_M, BACK_S, BACK_D, FOR_M,FOR_S, FOR_D };
+ enum TableLookupMonotone { BACK_MONO, BACK_NONMONO, FOR_MONO, FOR_NONMONO};
// This is the order in which pieces appear in the orientation table
// when conditioning on f and e.
@@ -58,9 +63,6 @@ private:
// This is the order in which pieces appear in the orientation table
// when conditioning on f only.
enum FFileFormat { F_FOREIGN, F_PROBS };
-
- // Possible values for orientation.
- enum ORIENTATIONS { MONO, NON_MONO, SWAP, DISC };
// different numbers of probabilities for different ranges of
// orientation variable
@@ -89,8 +91,7 @@ public:
~LexicalReordering(void) {}
// Compute and return a score for a hypothesis
- float CalcScore(int numSourceWords, WordsRange &currTargetRange,
- WordsRange &prevSourceRange, WordsRange &currSourceRange);
+ float CalcScore(Hypothesis *curr_hypothesis);
// Print the orientation probability table
void PrintTable(void);
@@ -102,5 +103,7 @@ public:
float GetForwardWeight(void);
float GetBackwardWeight(void);
+
+ float GetProbability(Hypothesis *hypothesis, int orientation);
};
diff --git a/moses/src/Manager.cpp b/moses/src/Manager.cpp
index 31dc18eb5..a13ef2aba 100755
--- a/moses/src/Manager.cpp
+++ b/moses/src/Manager.cpp
@@ -76,6 +76,7 @@ void Manager::ProcessSentence()
// seed hypothesis
{
+
Hypothesis *hypo = Hypothesis::Create(m_source);
#ifdef N_BEST
LMList allLM = m_staticData.GetAllLM();
diff --git a/moses/src/Phrase.cpp b/moses/src/Phrase.cpp
index eda750e2b..c299c8005 100755
--- a/moses/src/Phrase.cpp
+++ b/moses/src/Phrase.cpp
@@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "assert.h"
#include <algorithm>
#include <sstream>
+#include <string>
#include "memory.h"
#include "FactorCollection.h"
#include "Phrase.h"
@@ -108,6 +109,21 @@ Phrase Phrase::GetSubString(const WordsRange &wordsRange) const
return retPhrase;
}
+std::string Phrase::GetStringRep(const WordsRange &wordsRange)
+{
+ std::string phrase_string = "";
+ Phrase retPhrase(m_direction);
+ for (size_t currPos = wordsRange.GetStartPos() ; currPos <= wordsRange.GetEndPos() ; currPos++)
+ {
+ phrase_string = phrase_string+ " "+ Word::ToString(GetFactorArray(currPos));
+ }
+ return phrase_string;
+}
+
+
+
+
+
FactorArray &Phrase::AddWord()
{
if (m_phraseSize % ARRAY_SIZE_INCR == 0)
diff --git a/moses/src/Phrase.h b/moses/src/Phrase.h
index 7559f0aa1..4bd370b31 100755
--- a/moses/src/Phrase.h
+++ b/moses/src/Phrase.h
@@ -107,7 +107,9 @@ public:
void AddWords(const Phrase &copy);
Phrase GetSubString(const WordsRange &wordsRange) const;
-
+
+ std::string GetStringRep(const WordsRange &wordsRange);
+
TO_STRING
// used to insert & find phrase in dictionary
diff --git a/moses/src/StaticData.cpp b/moses/src/StaticData.cpp
index 998d67407..d8c4ce685 100755
--- a/moses/src/StaticData.cpp
+++ b/moses/src/StaticData.cpp
@@ -41,6 +41,7 @@ StaticData::StaticData()
:m_languageModel(2)
,m_weightInput(0.0)
,m_inputOutput(NULL)
+,m_lexReorder(NULL)
,m_fLMsLoaded(false)
,m_inputType(0)
{
@@ -107,8 +108,10 @@ bool StaticData::LoadParameters(int argc, char* argv[])
}
// load Lexical Reordering model
// check to see if the lexical reordering parameter exists
+ //TODO: doesn't work for bidirectional: yet.
const vector<string> &lrFileVector =
m_parameter.GetParam("lexreordering-file");
+
if (lrFileVector.size() > 0)
{
// if there is a lexical reordering model, then parse the
@@ -118,7 +121,7 @@ bool StaticData::LoadParameters(int argc, char* argv[])
m_parameter.GetParam("lexreordering-type");
// if type values have been set in the .ini file, then use them;
// first initialize to the defaults (msd, bidirectional, fe).
- int orientation = LexReorderType::Msd,
+ int orientation = DistortionOrientationType::Msd,
direction = LexReorderType::Bidirectional,
condition = LexReorderType::Fe;
if (lrTypeVector.size() > 0)
@@ -136,9 +139,9 @@ bool StaticData::LoadParameters(int argc, char* argv[])
//TODO:Lowercase val!
//orientation
if(val == "monotone")
- orientation = LexReorderType::Monotone;
+ orientation = DistortionOrientationType::Monotone;
else if(val == "msd")
- orientation = LexReorderType::Msd;
+ orientation = DistortionOrientationType::Msd;
//direction
else if(val == "forward")
direction = LexReorderType::Forward;
@@ -163,9 +166,7 @@ bool StaticData::LoadParameters(int argc, char* argv[])
m_lexReorder = new LexicalReordering(lrFileVector[0], orientation, direction, condition);
timer.check("Finished loading lexical reorder table.");
}
-
- // load language models
- if (m_parameter.GetParam("lmodel-file").size() > 0)
+ if (m_parameter.GetParam("lmodel-file").size() > 0)
{
// weights
vector<float> weightAll = Scan<float>(m_parameter.GetParam("weight-l"));
@@ -286,6 +287,7 @@ bool StaticData::LoadParameters(int argc, char* argv[])
m_weightInput=Scan<float>(m_parameter.GetParam("weight-i")[0]);
return true;
+
}
StaticData::~StaticData()
diff --git a/moses/src/StaticData.h b/moses/src/StaticData.h
index 9320e5277..b0b05966b 100755
--- a/moses/src/StaticData.h
+++ b/moses/src/StaticData.h
@@ -147,6 +147,11 @@ public:
{
return m_languageModel[type];
}
+
+ LexicalReordering *GetLexReorder() const
+ {
+ return m_lexReorder;
+ }
float GetWeightDistortion() const
{
return m_weightDistortion;
diff --git a/moses/src/TypeDef.h b/moses/src/TypeDef.h
index 515a20e47..6e3bc97a1 100755
--- a/moses/src/TypeDef.h
+++ b/moses/src/TypeDef.h
@@ -126,9 +126,7 @@ namespace LexReorderType
{
enum LexReorderType
{
- Monotone //TODO what the jiggers do these symbols mean?
- ,Msd
- ,Forward
+ Forward
,Backward
,Bidirectional
,Fe
@@ -136,6 +134,19 @@ namespace LexReorderType
};
}
+namespace DistortionOrientationType
+{
+ enum DistortionOrientationOptions
+ {
+ Monotone
+ ,Msd
+ };
+ // Possible values for orientation.
+ enum ORIENTATIONS { MONO, NON_MONO, SWAP, DISC };
+
+
+};
+
enum IOMethod
{
IOMethodCommandLine