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 <hieuhoang@gmail.com>2016-06-28 13:15:40 +0300
committerHieu Hoang <hieuhoang@gmail.com>2016-06-28 13:15:40 +0300
commitebae7ce52063612b18ec169b397376f6b876f4d0 (patch)
tree88c97a958bf7466390050ef86cdaf893bc3db6dd /OnDiskPt
parentad240a9f5b13c807e3e5dbe3a6d51f4e40e5ad53 (diff)
move ConvertFromMoses() to Moses
Diffstat (limited to 'OnDiskPt')
-rw-r--r--OnDiskPt/OnDiskWrapper.cpp39
-rw-r--r--OnDiskPt/OnDiskWrapper.h4
-rw-r--r--OnDiskPt/Vocab.cpp1
3 files changed, 2 insertions, 42 deletions
diff --git a/OnDiskPt/OnDiskWrapper.cpp b/OnDiskPt/OnDiskWrapper.cpp
index 57fae5162..c132d2c4a 100644
--- a/OnDiskPt/OnDiskWrapper.cpp
+++ b/OnDiskPt/OnDiskWrapper.cpp
@@ -23,7 +23,7 @@
#include <sys/stat.h>
#include <string>
#include "OnDiskWrapper.h"
-#include "moses/Factor.h"
+#include "moses/Util.h"
#include "util/exception.hh"
#include "util/string_stream.hh"
@@ -219,42 +219,5 @@ uint64_t OnDiskWrapper::GetMisc(const std::string &key) const
return iter->second;
}
-Word *OnDiskWrapper::ConvertFromMoses(const std::vector<Moses::FactorType> &factorsVec
- , const Moses::Word &origWord) const
-{
- bool isNonTerminal = origWord.IsNonTerminal();
- Word *newWord = new Word(isNonTerminal);
-
- util::StringStream strme;
-
- size_t factorType = factorsVec[0];
- const Moses::Factor *factor = origWord.GetFactor(factorType);
- UTIL_THROW_IF2(factor == NULL, "Expecting factor " << factorType);
- strme << factor->GetString();
-
- for (size_t ind = 1 ; ind < factorsVec.size() ; ++ind) {
- size_t factorType = factorsVec[ind];
- const Moses::Factor *factor = origWord.GetFactor(factorType);
- if (factor == NULL) {
- // can have less factors than factorType.size()
- break;
- }
- UTIL_THROW_IF2(factor == NULL,
- "Expecting factor " << factorType << " at position " << ind);
- strme << "|" << factor->GetString();
- } // for (size_t factorType
-
- bool found;
- uint64_t vocabId = m_vocab.GetVocabId(strme.str(), found);
- if (!found) {
- // factor not in phrase table -> phrse definately not in. exit
- delete newWord;
- return NULL;
- } else {
- newWord->SetVocabId(vocabId);
- return newWord;
- }
-}
-
}
diff --git a/OnDiskPt/OnDiskWrapper.h b/OnDiskPt/OnDiskWrapper.h
index bf398506c..445357fe2 100644
--- a/OnDiskPt/OnDiskWrapper.h
+++ b/OnDiskPt/OnDiskWrapper.h
@@ -22,7 +22,6 @@
#include <fstream>
#include "Vocab.h"
#include "PhraseNode.h"
-#include "moses/Word.h"
namespace OnDiskPt
{
@@ -107,9 +106,6 @@ public:
uint64_t GetMisc(const std::string &key) const;
- Word *ConvertFromMoses(const std::vector<Moses::FactorType> &factorsVec
- , const Moses::Word &origWord) const;
-
};
}
diff --git a/OnDiskPt/Vocab.cpp b/OnDiskPt/Vocab.cpp
index dbe7b2e2f..0a95f5180 100644
--- a/OnDiskPt/Vocab.cpp
+++ b/OnDiskPt/Vocab.cpp
@@ -21,6 +21,7 @@
#include <fstream>
#include "OnDiskWrapper.h"
#include "Vocab.h"
+#include "moses/Util.h"
#include "util/exception.hh"
using namespace std;