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:
authorHieu Hoang <hieu@hoang.co.uk>2013-07-09 12:41:24 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-07-09 12:41:24 +0400
commit83cd85c8d3ed8094558d44b7a46fc278c597374e (patch)
treeb7487740d4195ff478c661e4d50bab69380c60cf
parenta602e2052f39670451a16a867791a847fb6253e8 (diff)
parentfad88a14515f15a41c53609a065f8985739d1ab1 (diff)
Merge branch 'hieu_opt_input2' of github.com:hieuhoang/mosesdecoder into hieu_opt_input2
-rw-r--r--OnDiskPt/OnDiskWrapper.cpp8
-rw-r--r--OnDiskPt/OnDiskWrapper.h10
-rw-r--r--OnDiskPt/TargetPhrase.cpp15
-rw-r--r--OnDiskPt/TargetPhrase.h3
-rw-r--r--OnDiskPt/TargetPhraseCollection.cpp7
-rw-r--r--OnDiskPt/TargetPhraseCollection.h4
-rw-r--r--contrib/other-builds/moses/.project8
-rw-r--r--misc/queryPhraseTableMin.cpp2
-rw-r--r--moses/DecodeStepTranslation.cpp60
-rw-r--r--moses/InputLatticeNode.cpp39
-rw-r--r--moses/InputPath.cpp55
-rw-r--r--moses/InputPath.h (renamed from moses/InputLatticeNode.h)33
-rw-r--r--moses/LVoc.h2
-rw-r--r--moses/StaticData.cpp2
-rw-r--r--moses/StaticData.h4
-rw-r--r--moses/TranslationModel/BilingualDynSuffixArray.h8
-rw-r--r--moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp20
-rw-r--r--moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp2
-rw-r--r--moses/TranslationModel/CompactPT/PhraseDecoder.cpp6
-rw-r--r--moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp2
-rw-r--r--moses/TranslationModel/CompactPT/PhraseTableCreator.cpp18
-rw-r--r--moses/TranslationModel/CompactPT/PhraseTableCreator.h2
-rw-r--r--moses/TranslationModel/PhraseDictionary.cpp10
-rw-r--r--moses/TranslationModel/PhraseDictionary.h4
-rw-r--r--moses/TranslationModel/PhraseDictionaryMemory.cpp56
-rw-r--r--moses/TranslationModel/PhraseDictionaryMemory.h2
-rw-r--r--moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp55
-rw-r--r--moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h2
-rw-r--r--moses/TranslationOptionCollection.cpp2
-rw-r--r--moses/TranslationOptionCollection.h4
-rw-r--r--moses/TranslationOptionCollectionText.cpp48
-rw-r--r--moses/TranslationOptionCollectionText.h6
-rw-r--r--moses/TypeDef.h54
-rw-r--r--moses/generic/sorting/VectorIndexSorter.h8
-rw-r--r--phrase-extract/relax-parse-main.cpp4
-rwxr-xr-xscripts/other/beautify.perl5
-rw-r--r--symal/cmd.h10
37 files changed, 329 insertions, 251 deletions
diff --git a/OnDiskPt/OnDiskWrapper.cpp b/OnDiskPt/OnDiskWrapper.cpp
index 8f90862be..6cb482051 100644
--- a/OnDiskPt/OnDiskWrapper.cpp
+++ b/OnDiskPt/OnDiskWrapper.cpp
@@ -191,13 +191,7 @@ UINT64 OnDiskWrapper::GetMisc(const std::string &key) const
return iter->second;
}
-PhraseNode &OnDiskWrapper::GetRootSourceNode()
-{
- return *m_rootSourceNode;
-}
-
-Word *OnDiskWrapper::ConvertFromMoses(Moses::FactorDirection /* direction */
- , const std::vector<Moses::FactorType> &factorsVec
+Word *OnDiskWrapper::ConvertFromMoses(const std::vector<Moses::FactorType> &factorsVec
, const Moses::Word &origWord) const
{
bool isNonTerminal = origWord.IsNonTerminal();
diff --git a/OnDiskPt/OnDiskWrapper.h b/OnDiskPt/OnDiskWrapper.h
index 8b786d346..5800857b2 100644
--- a/OnDiskPt/OnDiskWrapper.h
+++ b/OnDiskPt/OnDiskWrapper.h
@@ -95,12 +95,16 @@ public:
return 1;
}
- PhraseNode &GetRootSourceNode();
+ PhraseNode &GetRootSourceNode() {
+ return *m_rootSourceNode;
+ }
+ const PhraseNode &GetRootSourceNode() const {
+ return *m_rootSourceNode;
+ }
UINT64 GetMisc(const std::string &key) const;
- Word *ConvertFromMoses(Moses::FactorDirection direction
- , const std::vector<Moses::FactorType> &factorsVec
+ Word *ConvertFromMoses(const std::vector<Moses::FactorType> &factorsVec
, const Moses::Word &origWord) const;
};
diff --git a/OnDiskPt/TargetPhrase.cpp b/OnDiskPt/TargetPhrase.cpp
index 2e3e3511b..281fd139a 100644
--- a/OnDiskPt/TargetPhrase.cpp
+++ b/OnDiskPt/TargetPhrase.cpp
@@ -227,14 +227,17 @@ Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vector<Moses::Facto
, const std::vector<Moses::FactorType> &outputFactors
, const Vocab &vocab
, const Moses::PhraseDictionary &phraseDict
- , const std::vector<float> &weightT) const
+ , const std::vector<float> &weightT
+ , bool isSyntax) const
{
Moses::TargetPhrase *ret = new Moses::TargetPhrase();
// words
size_t phraseSize = GetSize();
CHECK(phraseSize > 0); // last word is lhs
- --phraseSize;
+ if (isSyntax) {
+ --phraseSize;
+ }
for (size_t pos = 0; pos < phraseSize; ++pos) {
GetWord(pos).ConvertToMoses(outputFactors, vocab, ret->AddWord());
@@ -261,9 +264,11 @@ Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vector<Moses::Facto
ret->SetAlignTerm(alignTerm);
ret->SetAlignNonTerm(alignNonTerm);
- Moses::Word *lhsTarget = new Moses::Word(true);
- GetWord(GetSize() - 1).ConvertToMoses(outputFactors, vocab, *lhsTarget);
- ret->SetTargetLHS(lhsTarget);
+ if (isSyntax) {
+ Moses::Word *lhsTarget = new Moses::Word(true);
+ GetWord(GetSize() - 1).ConvertToMoses(outputFactors, vocab, *lhsTarget);
+ ret->SetTargetLHS(lhsTarget);
+ }
// set source phrase
Moses::Phrase mosesSP(Moses::Input);
diff --git a/OnDiskPt/TargetPhrase.h b/OnDiskPt/TargetPhrase.h
index a73ab75e1..5b8a30296 100644
--- a/OnDiskPt/TargetPhrase.h
+++ b/OnDiskPt/TargetPhrase.h
@@ -103,7 +103,8 @@ public:
, const std::vector<Moses::FactorType> &outputFactors
, const Vocab &vocab
, const Moses::PhraseDictionary &phraseDict
- , const std::vector<float> &weightT) const;
+ , const std::vector<float> &weightT
+ , bool isSyntax) const;
UINT64 ReadOtherInfoFromFile(UINT64 filePos, std::fstream &fileTPColl);
UINT64 ReadFromFile(std::fstream &fileTP);
diff --git a/OnDiskPt/TargetPhraseCollection.cpp b/OnDiskPt/TargetPhraseCollection.cpp
index 368faa971..300dd4e99 100644
--- a/OnDiskPt/TargetPhraseCollection.cpp
+++ b/OnDiskPt/TargetPhraseCollection.cpp
@@ -117,8 +117,8 @@ Moses::TargetPhraseCollection *TargetPhraseCollection::ConvertToMoses(const std:
, const std::vector<Moses::FactorType> &outputFactors
, const Moses::PhraseDictionary &phraseDict
, const std::vector<float> &weightT
- , const std::string & /* filePath */
- , Vocab &vocab) const
+ , Vocab &vocab
+ , bool isSyntax) const
{
Moses::TargetPhraseCollection *ret = new Moses::TargetPhraseCollection();
@@ -128,7 +128,8 @@ Moses::TargetPhraseCollection *TargetPhraseCollection::ConvertToMoses(const std:
Moses::TargetPhrase *mosesPhrase = tp.ConvertToMoses(inputFactors, outputFactors
, vocab
, phraseDict
- , weightT);
+ , weightT
+ , isSyntax);
/*
// debugging output
diff --git a/OnDiskPt/TargetPhraseCollection.h b/OnDiskPt/TargetPhraseCollection.h
index d6086850f..72885ca12 100644
--- a/OnDiskPt/TargetPhraseCollection.h
+++ b/OnDiskPt/TargetPhraseCollection.h
@@ -73,8 +73,8 @@ public:
, const std::vector<Moses::FactorType> &outputFactors
, const Moses::PhraseDictionary &phraseDict
, const std::vector<float> &weightT
- , const std::string &filePath
- , Vocab &vocab) const;
+ , Vocab &vocab
+ , bool isSyntax) const;
void ReadFromFile(size_t tableLimit, UINT64 filePos, OnDiskWrapper &onDiskWrapper);
const std::string GetDebugStr() const;
diff --git a/contrib/other-builds/moses/.project b/contrib/other-builds/moses/.project
index 21b68ebbf..04dd7cbda 100644
--- a/contrib/other-builds/moses/.project
+++ b/contrib/other-builds/moses/.project
@@ -472,14 +472,14 @@
<locationURI>PARENT-3-PROJECT_LOC/moses/InputFileStream.h</locationURI>
</link>
<link>
- <name>InputLatticeNode.cpp</name>
+ <name>InputPath.cpp</name>
<type>1</type>
- <locationURI>PARENT-3-PROJECT_LOC/moses/InputLatticeNode.cpp</locationURI>
+ <locationURI>PARENT-3-PROJECT_LOC/moses/InputPath.cpp</locationURI>
</link>
<link>
- <name>InputLatticeNode.h</name>
+ <name>InputPath.h</name>
<type>1</type>
- <locationURI>PARENT-3-PROJECT_LOC/moses/InputLatticeNode.h</locationURI>
+ <locationURI>PARENT-3-PROJECT_LOC/moses/InputPath.h</locationURI>
</link>
<link>
<name>InputType.cpp</name>
diff --git a/misc/queryPhraseTableMin.cpp b/misc/queryPhraseTableMin.cpp
index 0b4324020..2f0caf910 100644
--- a/misc/queryPhraseTableMin.cpp
+++ b/misc/queryPhraseTableMin.cpp
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
sourcePhrase.CreateFromString(Input, input, line, "||dummy_string||", NULL);
TargetPhraseVectorPtr decodedPhraseColl
- = pdc.GetTargetPhraseCollectionRaw(sourcePhrase);
+ = pdc.GetTargetPhraseCollectionRaw(sourcePhrase);
if(decodedPhraseColl != NULL) {
if(reportCounts)
diff --git a/moses/DecodeStepTranslation.cpp b/moses/DecodeStepTranslation.cpp
index 7151c681c..b48daf7e5 100644
--- a/moses/DecodeStepTranslation.cpp
+++ b/moses/DecodeStepTranslation.cpp
@@ -101,57 +101,57 @@ void DecodeStepTranslation::Process(const TranslationOption &inputPartialTranslO
}
void DecodeStepTranslation::Process(const TranslationOption &inputPartialTranslOpt
- , const DecodeStep &decodeStep
- , PartialTranslOptColl &outputPartialTranslOptColl
- , TranslationOptionCollection *toc
- , bool adhereTableLimit
- , const Phrase &src
- , const TargetPhraseCollection *phraseColl) const
+ , const DecodeStep &decodeStep
+ , PartialTranslOptColl &outputPartialTranslOptColl
+ , TranslationOptionCollection *toc
+ , bool adhereTableLimit
+ , const Phrase &src
+ , const TargetPhraseCollection *phraseColl) const
{
if (inputPartialTranslOpt.GetTargetPhrase().GetSize() == 0) {
- // word deletion
- outputPartialTranslOptColl.Add(new TranslationOption(inputPartialTranslOpt));
- return;
+ // word deletion
+ outputPartialTranslOptColl.Add(new TranslationOption(inputPartialTranslOpt));
+ return;
}
// normal trans step
const WordsRange &sourceWordsRange = inputPartialTranslOpt.GetSourceWordsRange();
const PhraseDictionary* phraseDictionary =
- decodeStep.GetPhraseDictionaryFeature();
+ decodeStep.GetPhraseDictionaryFeature();
const TargetPhrase &inPhrase = inputPartialTranslOpt.GetTargetPhrase();
const size_t currSize = inPhrase.GetSize();
const size_t tableLimit = phraseDictionary->GetTableLimit();
if (phraseColl != NULL) {
- TargetPhraseCollection::const_iterator iterTargetPhrase, iterEnd;
- iterEnd = (!adhereTableLimit || tableLimit == 0 || phraseColl->GetSize() < tableLimit) ? phraseColl->end() : phraseColl->begin() + tableLimit;
+ TargetPhraseCollection::const_iterator iterTargetPhrase, iterEnd;
+ iterEnd = (!adhereTableLimit || tableLimit == 0 || phraseColl->GetSize() < tableLimit) ? phraseColl->end() : phraseColl->begin() + tableLimit;
- for (iterTargetPhrase = phraseColl->begin(); iterTargetPhrase != iterEnd; ++iterTargetPhrase) {
- const TargetPhrase& targetPhrase = **iterTargetPhrase;
- const ScoreComponentCollection &transScores = targetPhrase.GetScoreBreakdown();
- // skip if the
- if (targetPhrase.GetSize() != currSize) continue;
+ for (iterTargetPhrase = phraseColl->begin(); iterTargetPhrase != iterEnd; ++iterTargetPhrase) {
+ const TargetPhrase& targetPhrase = **iterTargetPhrase;
+ const ScoreComponentCollection &transScores = targetPhrase.GetScoreBreakdown();
+ // skip if the
+ if (targetPhrase.GetSize() != currSize) continue;
- TargetPhrase outPhrase(inPhrase);
+ TargetPhrase outPhrase(inPhrase);
- if (IsFilteringStep()) {
- if (!inputPartialTranslOpt.IsCompatible(targetPhrase, m_conflictFactors))
- continue;
- }
+ if (IsFilteringStep()) {
+ if (!inputPartialTranslOpt.IsCompatible(targetPhrase, m_conflictFactors))
+ continue;
+ }
- outPhrase.Merge(targetPhrase, m_newOutputFactors);
- outPhrase.Evaluate(src, m_featuresToApply); // need to do this as all non-transcores would be screwed up
+ outPhrase.Merge(targetPhrase, m_newOutputFactors);
+ outPhrase.Evaluate(src, m_featuresToApply); // need to do this as all non-transcores would be screwed up
- TranslationOption *newTransOpt = new TranslationOption(sourceWordsRange, outPhrase);
- assert(newTransOpt != NULL);
+ TranslationOption *newTransOpt = new TranslationOption(sourceWordsRange, outPhrase);
+ assert(newTransOpt != NULL);
- outputPartialTranslOptColl.Add(newTransOpt );
+ outputPartialTranslOptColl.Add(newTransOpt );
- }
+ }
} else if (sourceWordsRange.GetNumWordsCovered() == 1) {
- // unknown handler
- //toc->ProcessUnknownWord(sourceWordsRange.GetStartPos(), factorCollection);
+ // unknown handler
+ //toc->ProcessUnknownWord(sourceWordsRange.GetStartPos(), factorCollection);
}
}
diff --git a/moses/InputLatticeNode.cpp b/moses/InputLatticeNode.cpp
deleted file mode 100644
index 6c4347cf8..000000000
--- a/moses/InputLatticeNode.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "InputLatticeNode.h"
-
-namespace Moses
-{
-const TargetPhraseCollection *InputLatticeNode::GetTargetPhrases(const PhraseDictionary &phraseDictionary) const
-{
- std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, const void*> >::const_iterator iter;
- iter = m_targetPhrases.find(&phraseDictionary);
- if (iter == m_targetPhrases.end()) {
- return NULL;
- }
- return iter->second.first;
-}
-
-const void *InputLatticeNode::GetPtNode(const PhraseDictionary &phraseDictionary) const
-{
- std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, const void*> >::const_iterator iter;
- iter = m_targetPhrases.find(&phraseDictionary);
- if (iter == m_targetPhrases.end()) {
- return NULL;
- }
- return iter->second.second;
-}
-
-std::ostream& operator<<(std::ostream& out, const InputLatticeNode& obj)
-{
- out << &obj << " " << obj.GetWordsRange() << " " << obj.GetPrevNode() << " " << obj.GetPhrase();
-
- out << "pt: ";
- std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, const void*> >::const_iterator iter;
- for (iter = obj.m_targetPhrases.begin(); iter != obj.m_targetPhrases.end(); ++iter) {
- const PhraseDictionary *pt = iter->first;
- out << pt << " ";
- }
-
- return out;
-}
-
-}
diff --git a/moses/InputPath.cpp b/moses/InputPath.cpp
new file mode 100644
index 000000000..d1f130259
--- /dev/null
+++ b/moses/InputPath.cpp
@@ -0,0 +1,55 @@
+#include "InputPath.h"
+#include "ScoreComponentCollection.h"
+namespace Moses
+{
+InputPath::InputPath(const Phrase &phrase, const WordsRange &range, const InputPath *prevNode
+ ,const ScoreComponentCollection *inputScore)
+ :m_prevNode(prevNode)
+ ,m_phrase(phrase)
+ ,m_range(range)
+{
+ if (inputScore) {
+ m_inputScore = new ScoreComponentCollection(*inputScore);
+ }
+}
+
+InputPath::~InputPath()
+{
+ delete m_inputScore;
+}
+
+const TargetPhraseCollection *InputPath::GetTargetPhrases(const PhraseDictionary &phraseDictionary) const
+{
+ std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, const void*> >::const_iterator iter;
+ iter = m_targetPhrases.find(&phraseDictionary);
+ if (iter == m_targetPhrases.end()) {
+ return NULL;
+ }
+ return iter->second.first;
+}
+
+const void *InputPath::GetPtNode(const PhraseDictionary &phraseDictionary) const
+{
+ std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, const void*> >::const_iterator iter;
+ iter = m_targetPhrases.find(&phraseDictionary);
+ if (iter == m_targetPhrases.end()) {
+ return NULL;
+ }
+ return iter->second.second;
+}
+
+std::ostream& operator<<(std::ostream& out, const InputPath& obj)
+{
+ out << &obj << " " << obj.GetWordsRange() << " " << obj.GetPrevNode() << " " << obj.GetPhrase();
+
+ out << "pt: ";
+ std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, const void*> >::const_iterator iter;
+ for (iter = obj.m_targetPhrases.begin(); iter != obj.m_targetPhrases.end(); ++iter) {
+ const PhraseDictionary *pt = iter->first;
+ out << pt << " ";
+ }
+
+ return out;
+}
+
+}
diff --git a/moses/InputLatticeNode.h b/moses/InputPath.h
index f1ce96edc..e18ea62e7 100644
--- a/moses/InputLatticeNode.h
+++ b/moses/InputPath.h
@@ -10,53 +10,56 @@ namespace Moses
class PhraseDictionary;
class TargetPhraseCollection;
+class ScoreComponentCollection;
/** Each node contains
1. substring used to searching the phrase table
2. the source range it covers
-3. a list of InputLatticeNode that it is a prefix of
+3. a list of InputPath that it is a prefix of
This is for both sentence input, and confusion network/lattices
*/
-class InputLatticeNode
+class InputPath
{
- friend std::ostream& operator<<(std::ostream& out, const InputLatticeNode &obj);
+ friend std::ostream& operator<<(std::ostream& out, const InputPath &obj);
protected:
- const InputLatticeNode *m_prevNode;
+ const InputPath *m_prevNode;
Phrase m_phrase;
WordsRange m_range;
+ const ScoreComponentCollection *m_inputScore;
std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, const void*> > m_targetPhrases;
public:
- explicit InputLatticeNode()
+ explicit InputPath()
: m_prevNode(NULL)
, m_range(NOT_FOUND, NOT_FOUND)
- {}
-
- InputLatticeNode(const Phrase &phrase, const WordsRange &range, const InputLatticeNode *prevNode)
- :m_prevNode(prevNode)
- ,m_phrase(phrase)
- ,m_range(range) {
+ , m_inputScore(NULL) {
}
+ InputPath(const Phrase &phrase, const WordsRange &range, const InputPath *prevNode
+ ,const ScoreComponentCollection *inputScore);
+ ~InputPath();
+
const Phrase &GetPhrase() const {
return m_phrase;
}
const WordsRange &GetWordsRange() const {
return m_range;
}
- const InputLatticeNode *GetPrevNode() const {
+ const InputPath *GetPrevNode() const {
return m_prevNode;
}
void SetTargetPhrases(const PhraseDictionary &phraseDictionary
- , const TargetPhraseCollection *targetPhrases
- , const void *ptNode) {
- std::pair<const TargetPhraseCollection*, const void*> value(targetPhrases, ptNode);
+ , const TargetPhraseCollection *targetPhrases
+ , const void *ptNode) {
+ std::pair<const TargetPhraseCollection*, const void*> value(targetPhrases, ptNode);
m_targetPhrases[&phraseDictionary] = value;
}
const TargetPhraseCollection *GetTargetPhrases(const PhraseDictionary &phraseDictionary) const;
const void *GetPtNode(const PhraseDictionary &phraseDictionary) const;
+ const ScoreComponentCollection *GetInputScore() const
+ { return m_inputScore; }
};
diff --git a/moses/LVoc.h b/moses/LVoc.h
index 485e3f481..5f5423832 100644
--- a/moses/LVoc.h
+++ b/moses/LVoc.h
@@ -38,7 +38,7 @@ public:
}
LabelId add(const Key& k) {
std::pair<typename M::iterator,bool> p
- =m.insert(std::make_pair(k,data.size()));
+ =m.insert(std::make_pair(k,data.size()));
if(p.second) data.push_back(k);
CHECK(static_cast<size_t>(p.first->second)<data.size());
return p.first->second;
diff --git a/moses/StaticData.cpp b/moses/StaticData.cpp
index af52b5cbf..96108c9e3 100644
--- a/moses/StaticData.cpp
+++ b/moses/StaticData.cpp
@@ -948,7 +948,7 @@ const TranslationOptionList* StaticData::FindTransOptListInCache(const DecodeGra
boost::mutex::scoped_lock lock(m_transOptCacheMutex);
#endif
std::map<std::pair<std::pair<size_t, std::string>, Phrase>, std::pair<TranslationOptionList*,clock_t> >::iterator iter
- = m_transOptCache.find(key);
+ = m_transOptCache.find(key);
if (iter == m_transOptCache.end())
return NULL;
iter->second.second = clock(); // update last used time
diff --git a/moses/StaticData.h b/moses/StaticData.h
index c64b22940..8eba8c774 100644
--- a/moses/StaticData.h
+++ b/moses/StaticData.h
@@ -673,7 +673,7 @@ public:
return false;
}
std::map< std::string, std::set< std::string > >::const_iterator lookupIgnoreFF
- = m_weightSettingIgnoreFF.find( m_currentWeightSetting );
+ = m_weightSettingIgnoreFF.find( m_currentWeightSetting );
if (lookupIgnoreFF == m_weightSettingIgnoreFF.end()) {
return false;
}
@@ -691,7 +691,7 @@ public:
return false;
}
std::map< std::string, std::set< size_t > >::const_iterator lookupIgnoreDP
- = m_weightSettingIgnoreDP.find( m_currentWeightSetting );
+ = m_weightSettingIgnoreDP.find( m_currentWeightSetting );
if (lookupIgnoreDP == m_weightSettingIgnoreDP.end()) {
return false;
}
diff --git a/moses/TranslationModel/BilingualDynSuffixArray.h b/moses/TranslationModel/BilingualDynSuffixArray.h
index 71f032507..0dac64807 100644
--- a/moses/TranslationModel/BilingualDynSuffixArray.h
+++ b/moses/TranslationModel/BilingualDynSuffixArray.h
@@ -26,8 +26,8 @@ public:
vector<wordID_t> words;
SAPhrase(size_t phraseSize)
- :words(phraseSize)
- {}
+ :words(phraseSize) {
+ }
void SetId(size_t pos, wordID_t id) {
CHECK(pos < words.size());
@@ -49,8 +49,8 @@ public:
, m_endTarget(endTarget)
, m_startSource(startSource)
, m_endSource(endSource)
- , m_sntIndex(sntIndex)
- {}
+ , m_sntIndex(sntIndex) {
+ }
size_t GetTargetSize() const {
return m_endTarget - m_startTarget + 1;
diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp
index 5dde99ade..b7f19d4ff 100644
--- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp
+++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp
@@ -101,7 +101,7 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection(
// search for terminal symbol
if (startPos == absEndPos) {
- OnDiskPt::Word *sourceWordBerkeleyDb = m_dbWrapper.ConvertFromMoses(Input, m_inputFactorsVec, sourceWordLabel.GetLabel());
+ OnDiskPt::Word *sourceWordBerkeleyDb = m_dbWrapper.ConvertFromMoses(m_inputFactorsVec, sourceWordLabel.GetLabel());
if (sourceWordBerkeleyDb != NULL) {
const OnDiskPt::PhraseNode *node = prevNode.GetChild(*sourceWordBerkeleyDb, m_dbWrapper);
@@ -149,7 +149,7 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection(
for (iterSourceLHS = sourceLHSSet.begin(); iterSourceLHS != sourceLHSSet.end(); ++iterSourceLHS) {
const Word &sourceLHS = *iterSourceLHS;
- OnDiskPt::Word *sourceLHSBerkeleyDb = m_dbWrapper.ConvertFromMoses(Input, m_inputFactorsVec, sourceLHS);
+ OnDiskPt::Word *sourceLHSBerkeleyDb = m_dbWrapper.ConvertFromMoses(m_inputFactorsVec, sourceLHS);
if (sourceLHSBerkeleyDb == NULL) {
delete sourceLHSBerkeleyDb;
@@ -175,7 +175,7 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection(
if (doSearch) {
- OnDiskPt::Word *chartNonTermBerkeleyDb = m_dbWrapper.ConvertFromMoses(Output, m_outputFactorsVec, cellLabel.GetLabel());
+ OnDiskPt::Word *chartNonTermBerkeleyDb = m_dbWrapper.ConvertFromMoses(m_outputFactorsVec, cellLabel.GetLabel());
if (chartNonTermBerkeleyDb == NULL)
continue;
@@ -219,7 +219,7 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection(
for (iterLabelSet = lhsSet.begin(); iterLabelSet != lhsSet.end(); ++iterLabelSet) {
const Word &sourceLHS = *iterLabelSet;
- OnDiskPt::Word *sourceLHSBerkeleyDb = m_dbWrapper.ConvertFromMoses(Input, m_inputFactorsVec, sourceLHS);
+ OnDiskPt::Word *sourceLHSBerkeleyDb = m_dbWrapper.ConvertFromMoses(m_inputFactorsVec, sourceLHS);
if (sourceLHSBerkeleyDb == NULL)
continue;
@@ -234,12 +234,12 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection(
std::vector<float> weightT = staticData.GetWeights(&m_dictionary);
targetPhraseCollection
- = tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec
- ,m_outputFactorsVec
- ,m_dictionary
- ,weightT
- ,m_filePath
- , m_dbWrapper.GetVocab());
+ = tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec
+ ,m_outputFactorsVec
+ ,m_dictionary
+ ,weightT
+ ,m_dbWrapper.GetVocab()
+ ,true);
delete tpcollBerkeleyDb;
m_cache[tpCollFilePos] = targetPhraseCollection;
diff --git a/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp b/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp
index 655ed01ca..7e60dec7d 100644
--- a/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp
+++ b/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp
@@ -428,7 +428,7 @@ void CompressionTaskReordering::operator()()
while(scoresNum < m_encodedScores.size()) {
std::string scores = m_encodedScores[scoresNum];
std::string compressedScores
- = m_creator.CompressEncodedScores(scores);
+ = m_creator.CompressEncodedScores(scores);
std::string dummy;
PackedItem packedItem(scoresNum, dummy, compressedScores, 0);
diff --git a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp
index c0767dad9..057e49268 100644
--- a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp
+++ b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp
@@ -61,7 +61,7 @@ PhraseDecoder::~PhraseDecoder()
inline unsigned PhraseDecoder::GetSourceSymbolId(std::string& symbol)
{
boost::unordered_map<std::string, unsigned>::iterator it
- = m_sourceSymbolsMap.find(symbol);
+ = m_sourceSymbolsMap.find(symbol);
if(it != m_sourceSymbolsMap.end())
return it->second;
@@ -200,7 +200,7 @@ TargetPhraseVectorPtr PhraseDecoder::CreateTargetPhraseCollection(const Phrase &
if(m_coding == PREnc) {
std::pair<TargetPhraseVectorPtr, size_t> cachedPhraseColl
- = m_decodingCache.Retrieve(sourcePhrase);
+ = m_decodingCache.Retrieve(sourcePhrase);
// Has been cached and is complete or does not need to be completed
if(cachedPhraseColl.first != NULL && (!topLevel || cachedPhraseColl.second == 0))
@@ -255,7 +255,7 @@ TargetPhraseVectorPtr PhraseDecoder::DecodeCollection(
if(m_coding == REnc) {
for(size_t i = 0; i < sourcePhrase.GetSize(); i++) {
std::string sourceWord
- = sourcePhrase.GetWord(i).GetString(*m_input, false);
+ = sourcePhrase.GetWord(i).GetString(*m_input, false);
unsigned idx = GetSourceSymbolId(sourceWord);
sourceWords.push_back(idx);
}
diff --git a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp
index 8d0f9ff2f..60c1876ba 100644
--- a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp
+++ b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp
@@ -117,7 +117,7 @@ PhraseDictionaryCompact::GetTargetPhraseCollection(const Phrase &sourcePhrase) c
// Retrieve target phrase collection from phrase table
TargetPhraseVectorPtr decodedPhraseColl
- = m_phraseDecoder->CreateTargetPhraseCollection(sourcePhrase, true, true);
+ = m_phraseDecoder->CreateTargetPhraseCollection(sourcePhrase, true, true);
if(decodedPhraseColl != NULL && decodedPhraseColl->size()) {
TargetPhraseVectorPtr tpv(new TargetPhraseVector(*decodedPhraseColl));
diff --git a/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp b/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp
index f2192ee36..25e232eec 100644
--- a/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp
+++ b/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp
@@ -426,7 +426,7 @@ void PhraseTableCreator::AddTargetSymbolId(std::string& symbol)
unsigned PhraseTableCreator::GetSourceSymbolId(std::string& symbol)
{
boost::unordered_map<std::string, unsigned>::iterator it
- = m_sourceSymbolsMap.find(symbol);
+ = m_sourceSymbolsMap.find(symbol);
if(it != m_sourceSymbolsMap.end())
return it->second;
@@ -437,7 +437,7 @@ unsigned PhraseTableCreator::GetSourceSymbolId(std::string& symbol)
unsigned PhraseTableCreator::GetTargetSymbolId(std::string& symbol)
{
boost::unordered_map<std::string, unsigned>::iterator it
- = m_targetSymbolsMap.find(symbol);
+ = m_targetSymbolsMap.find(symbol);
if(it != m_targetSymbolsMap.end())
return it->second;
@@ -451,7 +451,7 @@ unsigned PhraseTableCreator::GetOrAddTargetSymbolId(std::string& symbol)
boost::mutex::scoped_lock lock(m_mutex);
#endif
boost::unordered_map<std::string, unsigned>::iterator it
- = m_targetSymbolsMap.find(symbol);
+ = m_targetSymbolsMap.find(symbol);
if(it != m_targetSymbolsMap.end())
return it->second;
@@ -1034,16 +1034,16 @@ void RankingTask::operator()()
for(size_t i = 0; i < lines.size(); i++) {
std::vector<std::string> tokens;
Moses::TokenizeMultiCharSeparator(tokens, lines[i], m_creator.m_separator);
-
+
for(std::vector<std::string>::iterator it = tokens.begin(); it != tokens.end(); it++)
*it = Moses::Trim(*it);
-
+
if(tokens.size() < 4) {
std::cerr << "Error: It seems the following line has a wrong format:" << std::endl;
std::cerr << "Line " << i << ": " << lines[i] << std::endl;
abort();
}
-
+
if(tokens[3].size() <= 1 && m_creator.m_coding != PhraseTableCreator::None) {
std::cerr << "Error: It seems the following line contains no alignment information, " << std::endl;
std::cerr << "but you are using ";
@@ -1134,13 +1134,13 @@ void EncodingTask::operator()()
for(std::vector<std::string>::iterator it = tokens.begin(); it != tokens.end(); it++)
*it = Moses::Trim(*it);
-
+
if(tokens.size() < 3) {
std::cerr << "Error: It seems the following line has a wrong format:" << std::endl;
std::cerr << "Line " << i << ": " << lines[i] << std::endl;
abort();
}
-
+
if(tokens[3].size() <= 1 && m_creator.m_coding != PhraseTableCreator::None) {
std::cerr << "Error: It seems the following line contains no alignment information, " << std::endl;
std::cerr << "but you are using ";
@@ -1212,7 +1212,7 @@ void CompressionTask::operator()()
while(collectionNum < m_encodedCollections.size()) {
std::string collection = m_encodedCollections[collectionNum];
std::string compressedCollection
- = m_creator.CompressEncodedCollection(collection);
+ = m_creator.CompressEncodedCollection(collection);
std::string dummy;
PackedItem packedItem(collectionNum, dummy, compressedCollection, 0);
diff --git a/moses/TranslationModel/CompactPT/PhraseTableCreator.h b/moses/TranslationModel/CompactPT/PhraseTableCreator.h
index fd5fc1581..b92df1697 100644
--- a/moses/TranslationModel/CompactPT/PhraseTableCreator.h
+++ b/moses/TranslationModel/CompactPT/PhraseTableCreator.h
@@ -143,7 +143,7 @@ public:
return data;
else {
typename std::vector<DataType>::iterator it
- = std::lower_bound(m_bestVec.begin(), m_bestVec.end(), data);
+ = std::lower_bound(m_bestVec.begin(), m_bestVec.end(), data);
if(it != m_bestVec.end())
return *it;
else
diff --git a/moses/TranslationModel/PhraseDictionary.cpp b/moses/TranslationModel/PhraseDictionary.cpp
index ce923e1b4..e0dfa18cd 100644
--- a/moses/TranslationModel/PhraseDictionary.cpp
+++ b/moses/TranslationModel/PhraseDictionary.cpp
@@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "moses/InputType.h"
#include "moses/TranslationOption.h"
#include "moses/UserMessage.h"
-#include "moses/InputLatticeNode.h"
+#include "moses/InputPath.h"
#include "util/exception.hh"
using namespace std;
@@ -69,15 +69,15 @@ void PhraseDictionary::SetFeaturesToApply()
}
}
-void PhraseDictionary::SetTargetPhraseFromPtMatrix(const std::vector<InputLatticeNode*> &phraseDictionaryQueue) const
+void PhraseDictionary::SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const
{
// UTIL_THROW(util::Exception, "SetTargetPhraseFromPtMatrix() not implemented");
for (size_t i = 0; i < phraseDictionaryQueue.size(); ++i) {
- InputLatticeNode &node = *phraseDictionaryQueue[i];
+ InputPath &node = *phraseDictionaryQueue[i];
const Phrase &phrase = node.GetPhrase();
- const TargetPhraseCollection *targetPhrases = this->GetTargetPhraseCollection(phrase);
- node.SetTargetPhrases(*this, targetPhrases, NULL);
+ const TargetPhraseCollection *targetPhrases = this->GetTargetPhraseCollection(phrase);
+ node.SetTargetPhrases(*this, targetPhrases, NULL);
}
}
diff --git a/moses/TranslationModel/PhraseDictionary.h b/moses/TranslationModel/PhraseDictionary.h
index d140a4cb9..85d17ae8e 100644
--- a/moses/TranslationModel/PhraseDictionary.h
+++ b/moses/TranslationModel/PhraseDictionary.h
@@ -47,7 +47,7 @@ class InputType;
class WordsRange;
class ChartCellCollectionBase;
class ChartRuleLookupManager;
-class InputLatticeNode;
+class InputPath;
/**
* Abstract base class for phrase dictionaries (tables).
@@ -94,7 +94,7 @@ public:
void SetParameter(const std::string& key, const std::string& value);
- virtual void SetTargetPhraseFromPtMatrix(const std::vector<InputLatticeNode*> &phraseDictionaryQueue) const;
+ virtual void SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const;
protected:
size_t m_tableLimit;
diff --git a/moses/TranslationModel/PhraseDictionaryMemory.cpp b/moses/TranslationModel/PhraseDictionaryMemory.cpp
index 2091847e1..bbff04c3d 100644
--- a/moses/TranslationModel/PhraseDictionaryMemory.cpp
+++ b/moses/TranslationModel/PhraseDictionaryMemory.cpp
@@ -34,7 +34,7 @@
#include "moses/TranslationModel/RuleTable/LoaderFactory.h"
#include "moses/TranslationModel/RuleTable/Loader.h"
#include "moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h"
-#include "moses/InputLatticeNode.h"
+#include "moses/InputPath.h"
using namespace std;
@@ -134,38 +134,36 @@ void PhraseDictionaryMemory::SortAndPrune()
}
}
-void PhraseDictionaryMemory::SetTargetPhraseFromPtMatrix(const std::vector<InputLatticeNode*> &phraseDictionaryQueue) const
+void PhraseDictionaryMemory::SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const
{
// UTIL_THROW(util::Exception, "SetTargetPhraseFromPtMatrix() not implemented");
for (size_t i = 0; i < phraseDictionaryQueue.size(); ++i) {
- InputLatticeNode &node = *phraseDictionaryQueue[i];
+ InputPath &node = *phraseDictionaryQueue[i];
const Phrase &phrase = node.GetPhrase();
- const InputLatticeNode *prevNode = node.GetPrevNode();
-
- const PhraseDictionaryNodeMemory *prevPtNode = NULL;
-
- if (prevNode) {
- prevPtNode = static_cast<const PhraseDictionaryNodeMemory*>(prevNode->GetPtNode(*this));
- }
- else {
- // Starting subphrase.
- assert(phrase.GetSize() == 1);
- prevPtNode = &GetRootNode();
- }
-
- if (prevPtNode) {
- Word lastWord = phrase.GetWord(phrase.GetSize() - 1);
- lastWord.OnlyTheseFactors(m_inputFactors);
-
- const PhraseDictionaryNodeMemory *ptNode = prevPtNode->GetChild(lastWord);
- if (ptNode) {
- const TargetPhraseCollection *targetPhrases = ptNode->GetTargetPhraseCollection();
- node.SetTargetPhrases(*this, targetPhrases, ptNode);
- }
- else {
- node.SetTargetPhrases(*this, NULL, NULL);
- }
- }
+ const InputPath *prevNode = node.GetPrevNode();
+
+ const PhraseDictionaryNodeMemory *prevPtNode = NULL;
+
+ if (prevNode) {
+ prevPtNode = static_cast<const PhraseDictionaryNodeMemory*>(prevNode->GetPtNode(*this));
+ } else {
+ // Starting subphrase.
+ assert(phrase.GetSize() == 1);
+ prevPtNode = &GetRootNode();
+ }
+
+ if (prevPtNode) {
+ Word lastWord = phrase.GetWord(phrase.GetSize() - 1);
+ lastWord.OnlyTheseFactors(m_inputFactors);
+
+ const PhraseDictionaryNodeMemory *ptNode = prevPtNode->GetChild(lastWord);
+ if (ptNode) {
+ const TargetPhraseCollection *targetPhrases = ptNode->GetTargetPhraseCollection();
+ node.SetTargetPhrases(*this, targetPhrases, ptNode);
+ } else {
+ node.SetTargetPhrases(*this, NULL, NULL);
+ }
+ }
}
}
diff --git a/moses/TranslationModel/PhraseDictionaryMemory.h b/moses/TranslationModel/PhraseDictionaryMemory.h
index 8ec6ee8cf..02279b56e 100644
--- a/moses/TranslationModel/PhraseDictionaryMemory.h
+++ b/moses/TranslationModel/PhraseDictionaryMemory.h
@@ -53,7 +53,7 @@ public:
const InputType &,
const ChartCellCollectionBase &);
- void SetTargetPhraseFromPtMatrix(const std::vector<InputLatticeNode*> &phraseDictionaryQueue) const;
+ void SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const;
TO_STRING();
diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp
index 06e931fab..8fe0d092a 100644
--- a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp
+++ b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp
@@ -22,9 +22,13 @@
#include "moses/InputFileStream.h"
#include "moses/StaticData.h"
#include "moses/TargetPhraseCollection.h"
+#include "moses/InputPath.h"
#include "moses/TranslationModel/CYKPlusParser/DotChartOnDisk.h"
#include "moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.h"
+#include "OnDiskPt/OnDiskWrapper.h"
+#include "OnDiskPt/Word.h"
+
using namespace std;
@@ -92,8 +96,57 @@ void PhraseDictionaryOnDisk::InitializeForInput(InputType const& source)
CHECK(obj->GetMisc("NumScores") == m_numScoreComponents);
m_implementation.reset(obj);
+}
- return;
+void PhraseDictionaryOnDisk::SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const
+{
+ OnDiskPt::OnDiskWrapper &wrapper = const_cast<OnDiskPt::OnDiskWrapper&>(GetImplementation());
+
+ for (size_t i = 0; i < phraseDictionaryQueue.size(); ++i) {
+ InputPath &node = *phraseDictionaryQueue[i];
+ const Phrase &phrase = node.GetPhrase();
+ const InputPath *prevNode = node.GetPrevNode();
+
+ const OnDiskPt::PhraseNode *prevPtNode = NULL;
+
+ if (prevNode) {
+ prevPtNode = static_cast<const OnDiskPt::PhraseNode*>(prevNode->GetPtNode(*this));
+ } else {
+ // Starting subphrase.
+ assert(phrase.GetSize() == 1);
+ prevPtNode = &wrapper.GetRootSourceNode();
+ }
+
+ if (prevPtNode) {
+ Word lastWord = phrase.GetWord(phrase.GetSize() - 1);
+ lastWord.OnlyTheseFactors(m_inputFactors);
+ OnDiskPt::Word *lastWordOnDisk = wrapper.ConvertFromMoses(m_input, lastWord);
+
+ if (lastWordOnDisk == NULL) {
+ // OOV according to this phrase table. Not possible to extend
+ node.SetTargetPhrases(*this, NULL, NULL);
+ } else {
+ const OnDiskPt::PhraseNode *ptNode = prevPtNode->GetChild(*lastWordOnDisk, wrapper);
+ if (ptNode) {
+ vector<float> weightT = StaticData::Instance().GetWeights(this);
+ OnDiskPt::Vocab &vocab = wrapper.GetVocab();
+
+ const OnDiskPt::TargetPhraseCollection *targetPhrasesOnDisk = ptNode->GetTargetPhraseCollection(m_tableLimit, wrapper);
+ TargetPhraseCollection *targetPhrases
+ = targetPhrasesOnDisk->ConvertToMoses(m_input, m_output, *this, weightT, vocab, false);
+
+ node.SetTargetPhrases(*this, targetPhrases, ptNode);
+
+ delete targetPhrasesOnDisk;
+
+ } else {
+ node.SetTargetPhrases(*this, NULL, NULL);
+ }
+
+ delete lastWordOnDisk;
+ }
+ }
+ }
}
}
diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h
index e3eb52b48..d58a72eea 100644
--- a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h
+++ b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h
@@ -40,6 +40,7 @@ namespace Moses
{
class TargetPhraseCollection;
class DottedRuleStackOnDisk;
+class InputPath;
/** Implementation of on-disk phrase table for hierarchical/syntax model.
*/
@@ -76,6 +77,7 @@ public:
const ChartCellCollectionBase &);
virtual void InitializeForInput(InputType const& source);
+ void SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const;
};
diff --git a/moses/TranslationOptionCollection.cpp b/moses/TranslationOptionCollection.cpp
index 7bcad4464..6417bf04d 100644
--- a/moses/TranslationOptionCollection.cpp
+++ b/moses/TranslationOptionCollection.cpp
@@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "DecodeStepTranslation.h"
#include "DecodeGraph.h"
#include "moses/FF/UnknownWordPenaltyProducer.h"
-#include "InputLatticeNode.h"
+#include "InputPath.h"
using namespace std;
diff --git a/moses/TranslationOptionCollection.h b/moses/TranslationOptionCollection.h
index 968eefc08..9c91663b1 100644
--- a/moses/TranslationOptionCollection.h
+++ b/moses/TranslationOptionCollection.h
@@ -43,7 +43,7 @@ class FactorMask;
class Word;
class DecodeGraph;
class PhraseDictionary;
-class InputLatticeNode;
+class InputPath;
/** Contains all phrase translations applicable to current input type (a sentence or confusion network).
* A key insight into efficient decoding is that various input
@@ -69,7 +69,7 @@ protected:
const size_t m_maxNoTransOptPerCoverage; /*< maximum number of translation options per input span */
const float m_translationOptionThreshold; /*< threshold for translation options with regard to best option for input span */
std::vector<Phrase*> m_unksrcs;
- std::vector<InputLatticeNode*> m_phraseDictionaryQueue;
+ std::vector<InputPath*> m_phraseDictionaryQueue;
TranslationOptionCollection(InputType const& src, size_t maxNoTransOptPerCoverage,
float translationOptionThreshold);
diff --git a/moses/TranslationOptionCollectionText.cpp b/moses/TranslationOptionCollectionText.cpp
index 50803262f..b3f695c03 100644
--- a/moses/TranslationOptionCollectionText.cpp
+++ b/moses/TranslationOptionCollectionText.cpp
@@ -40,19 +40,18 @@ TranslationOptionCollectionText::TranslationOptionCollectionText(Sentence const
for (size_t phaseSize = 1; phaseSize <= size; ++phaseSize) {
for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) {
size_t endPos = startPos + phaseSize -1;
- std::vector<InputLatticeNode*> &vec = m_targetPhrasesfromPt[startPos];
+ std::vector<InputPath*> &vec = m_targetPhrasesfromPt[startPos];
Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos)));
WordsRange range(startPos, endPos);
if (range.GetNumWordsCovered() == 1) {
- InputLatticeNode *node = new InputLatticeNode(subphrase, range, NULL);
+ InputPath *node = new InputPath(subphrase, range, NULL, NULL);
+ vec.push_back(node);
+ } else {
+ const InputPath &prevNode = GetInputPath(startPos, endPos - 1);
+ InputPath *node = new InputPath(subphrase, range, &prevNode, NULL);
vec.push_back(node);
- }
- else {
- const InputLatticeNode &prevNode = GetInputLatticeNode(startPos, endPos - 1);
- InputLatticeNode *node = new InputLatticeNode(subphrase, range, &prevNode);
- vec.push_back(node);
}
}
}
@@ -61,7 +60,7 @@ TranslationOptionCollectionText::TranslationOptionCollectionText(Sentence const
for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) {
size_t endPos = startPos + phaseSize -1;
//cerr << startPos << "-" << endPos << "=" << GetPhrase(startPos, endPos) << endl;
- InputLatticeNode &node = GetInputLatticeNode(startPos, endPos);
+ InputPath &node = GetInputPath(startPos, endPos);
m_phraseDictionaryQueue.push_back(&node);
}
}
@@ -103,7 +102,7 @@ void TranslationOptionCollectionText::CreateXmlOptionsForRange(size_t startPosit
};
-InputLatticeNode &TranslationOptionCollectionText::GetInputLatticeNode(size_t startPos, size_t endPos)
+InputPath &TranslationOptionCollectionText::GetInputPath(size_t startPos, size_t endPos)
{
size_t offset = endPos - startPos;
CHECK(offset < m_targetPhrasesfromPt[startPos].size());
@@ -131,7 +130,7 @@ void TranslationOptionCollectionText::CreateTranslationOptionsForRange(
, bool adhereTableLimit
, size_t graphInd)
{
- InputLatticeNode &inputLatticeNode = GetInputLatticeNode(startPos, endPos);
+ InputPath &InputPath = GetInputPath(startPos, endPos);
if ((StaticData::Instance().GetXmlInputType() != XmlExclusive) || !HasXmlOptionsOverlappingRange(startPos,endPos)) {
Phrase *sourcePhrase = NULL; // can't initialise with substring, in case it's confusion network
@@ -165,7 +164,7 @@ void TranslationOptionCollectionText::CreateTranslationOptionsForRange(
const DecodeStep &decodeStep = **iterStep;
const PhraseDictionary &phraseDictionary = *decodeStep.GetPhraseDictionaryFeature();
- const TargetPhraseCollection *targetPhrases = inputLatticeNode.GetTargetPhrases(phraseDictionary);
+ const TargetPhraseCollection *targetPhrases = InputPath.GetTargetPhrases(phraseDictionary);
static_cast<const DecodeStepTranslation&>(decodeStep).ProcessInitialTranslation
(m_source, *oldPtoc
@@ -188,22 +187,21 @@ void TranslationOptionCollectionText::CreateTranslationOptionsForRange(
if (const DecodeStepTranslation *translateStep = dynamic_cast<const DecodeStepTranslation*>(decodeStep) ) {
const PhraseDictionary &phraseDictionary = *translateStep->GetPhraseDictionaryFeature();
- const TargetPhraseCollection *targetPhrases = inputLatticeNode.GetTargetPhrases(phraseDictionary);
+ const TargetPhraseCollection *targetPhrases = InputPath.GetTargetPhrases(phraseDictionary);
translateStep->Process(inputPartialTranslOpt
- , *decodeStep
- , *newPtoc
- , this
- , adhereTableLimit
- , *sourcePhrase
- , targetPhrases);
- }
- else {
+ , *decodeStep
+ , *newPtoc
+ , this
+ , adhereTableLimit
+ , *sourcePhrase
+ , targetPhrases);
+ } else {
decodeStep->Process(inputPartialTranslOpt
- , *decodeStep
- , *newPtoc
- , this
- , adhereTableLimit
- , *sourcePhrase);
+ , *decodeStep
+ , *newPtoc
+ , this
+ , adhereTableLimit
+ , *sourcePhrase);
}
}
diff --git a/moses/TranslationOptionCollectionText.h b/moses/TranslationOptionCollectionText.h
index 3ae062b00..930368c6f 100644
--- a/moses/TranslationOptionCollectionText.h
+++ b/moses/TranslationOptionCollectionText.h
@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#define moses_TranslationOptionCollectionText_h
#include "TranslationOptionCollection.h"
-#include "InputLatticeNode.h"
+#include "InputPath.h"
#include <map>
#include <vector>
@@ -38,12 +38,12 @@ class Sentence;
class TranslationOptionCollectionText : public TranslationOptionCollection
{
public:
- typedef std::vector< std::vector<InputLatticeNode*> > TargetPhraseMatrix;
+ typedef std::vector< std::vector<InputPath*> > TargetPhraseMatrix;
protected:
TargetPhraseMatrix m_targetPhrasesfromPt; /*< contains translation options */
- InputLatticeNode &GetInputLatticeNode(size_t startPos, size_t endPos);
+ InputPath &GetInputPath(size_t startPos, size_t endPos);
public:
void ProcessUnknownWord(size_t sourcePos);
diff --git a/moses/TypeDef.h b/moses/TypeDef.h
index af3a47b23..a49a3feb9 100644
--- a/moses/TypeDef.h
+++ b/moses/TypeDef.h
@@ -108,28 +108,28 @@ enum DistortionOrientationOptions {
enum PhraseTableImplementation {
Memory = 0
- ,Binary = 1
- ,OnDisk = 2
- //,GlueRule = 3
- //,Joshua = 4
- //,MemorySourceLabel = 5
- ,SCFG = 6
- //,BerkeleyDb = 7
- ,SuffixArray = 8
- ,Hiero = 9
- ,ALSuffixArray = 10
- ,FuzzyMatch = 11
- ,Compact = 12
- ,Interpolated = 13
- ,DSuffixArray = 14
+ ,Binary = 1
+ ,OnDisk = 2
+ //,GlueRule = 3
+ //,Joshua = 4
+ //,MemorySourceLabel = 5
+ ,SCFG = 6
+ //,BerkeleyDb = 7
+ ,SuffixArray = 8
+ ,Hiero = 9
+ ,ALSuffixArray = 10
+ ,FuzzyMatch = 11
+ ,Compact = 12
+ ,Interpolated = 13
+ ,DSuffixArray = 14
};
enum InputTypeEnum {
SentenceInput = 0
- ,ConfusionNetworkInput = 1
- ,WordLatticeInput = 2
- ,TreeInputType = 3
- ,WordLatticeInput2 = 4
+ ,ConfusionNetworkInput = 1
+ ,WordLatticeInput = 2
+ ,TreeInputType = 3
+ ,WordLatticeInput2 = 4
};
@@ -142,7 +142,7 @@ enum XmlInputType {
enum DictionaryFind {
Best = 0
- ,All = 1
+ ,All = 1
};
enum ParsingAlgorithm {
@@ -152,22 +152,22 @@ enum ParsingAlgorithm {
enum SearchAlgorithm {
Normal = 0
- ,CubePruning = 1
- ,CubeGrowing = 2
- ,ChartDecoding= 3
- ,NormalBatch = 4
- ,ChartIncremental = 5
+ ,CubePruning = 1
+ ,CubeGrowing = 2
+ ,ChartDecoding= 3
+ ,NormalBatch = 4
+ ,ChartIncremental = 5
};
enum SourceLabelOverlap {
SourceLabelOverlapAdd = 0
- ,SourceLabelOverlapReplace = 1
- ,SourceLabelOverlapDiscard = 2
+ ,SourceLabelOverlapReplace = 1
+ ,SourceLabelOverlapDiscard = 2
};
enum WordAlignmentSort {
NoSort = 0
- ,TargetOrder = 1
+ ,TargetOrder = 1
};
enum FormatType {
diff --git a/moses/generic/sorting/VectorIndexSorter.h b/moses/generic/sorting/VectorIndexSorter.h
index a689c417b..996a67877 100644
--- a/moses/generic/sorting/VectorIndexSorter.h
+++ b/moses/generic/sorting/VectorIndexSorter.h
@@ -24,12 +24,12 @@ public:
COMP const& Compare;
VectorIndexSorter(vector<VAL> const& v, COMP const& comp)
- : m_vecref(v), Compare(comp)
- { }
+ : m_vecref(v), Compare(comp) {
+ }
VectorIndexSorter(vector<VAL> const& v)
- : m_vecref(v), m_comp(new COMP()), Compare(*m_comp)
- { }
+ : m_vecref(v), m_comp(new COMP()), Compare(*m_comp) {
+ }
bool operator()(IDX_T const & a, IDX_T const & b) const {
bool fwd = Compare(m_vecref.at(a) ,m_vecref.at(b));
diff --git a/phrase-extract/relax-parse-main.cpp b/phrase-extract/relax-parse-main.cpp
index a58d4d97f..d3cb4c527 100644
--- a/phrase-extract/relax-parse-main.cpp
+++ b/phrase-extract/relax-parse-main.cpp
@@ -137,7 +137,7 @@ void LeftBinarize( SyntaxTree &tree, ParentNodes &parents )
const SplitPoints &point = *p;
if (point.size() > 3) {
const vector< SyntaxNode* >& topNodes
- = tree.GetNodes( point[0], point[point.size()-1]-1);
+ = tree.GetNodes( point[0], point[point.size()-1]-1);
string topLabel = topNodes[0]->GetLabel();
for(size_t i=2; i<point.size()-1; i++) {
@@ -155,7 +155,7 @@ void RightBinarize( SyntaxTree &tree, ParentNodes &parents )
if (point.size() > 3) {
int endPoint = point[point.size()-1]-1;
const vector< SyntaxNode* >& topNodes
- = tree.GetNodes( point[0], endPoint);
+ = tree.GetNodes( point[0], endPoint);
string topLabel = topNodes[0]->GetLabel();
for(size_t i=1; i<point.size()-2; i++) {
diff --git a/scripts/other/beautify.perl b/scripts/other/beautify.perl
index 521ac4931..e23f7e2a4 100755
--- a/scripts/other/beautify.perl
+++ b/scripts/other/beautify.perl
@@ -2,10 +2,13 @@
use strict;
use File::Basename;
+use FindBin qw($RealBin);
sub Beautify($);
-Beautify("/home/hieu/workspace/github/hh");
+print STDERR "RealBin=$RealBin \n\n";
+
+Beautify("$RealBin/../..");
sub Beautify($)
{
diff --git a/symal/cmd.h b/symal/cmd.h
index 01a00abc0..a728dda78 100644
--- a/symal/cmd.h
+++ b/symal/cmd.h
@@ -33,14 +33,14 @@ extern "C" {
#endif
#if defined(__STDC__)
- int DeclareParams(char *, ...);
+int DeclareParams(char *, ...);
#else
- int DeclareParams();
+int DeclareParams();
#endif
- int GetParams(int *n, char ***a,char *CmdFileName),
- SPrintParams(),
- PrintParams();
+int GetParams(int *n, char ***a,char *CmdFileName),
+ SPrintParams(),
+ PrintParams();
#ifdef __cplusplus
}