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:
-rw-r--r--moses-chart-cmd/Main.cpp25
-rw-r--r--moses-cmd/LatticeMBRGrid.cpp2
-rw-r--r--moses-cmd/Main.cpp2
-rw-r--r--moses/IOWrapper.cpp44
-rw-r--r--moses/IOWrapper.h2
-rw-r--r--moses/IOWrapperChart.cpp24
-rw-r--r--moses/IOWrapperChart.h2
7 files changed, 55 insertions, 46 deletions
diff --git a/moses-chart-cmd/Main.cpp b/moses-chart-cmd/Main.cpp
index b24c10441..dc192e64e 100644
--- a/moses-chart-cmd/Main.cpp
+++ b/moses-chart-cmd/Main.cpp
@@ -69,29 +69,6 @@ POSSIBILITY OF SUCH DAMAGE.
using namespace std;
using namespace Moses;
-
-bool ReadInput(IOWrapperChart &ioWrapper, InputTypeEnum inputType, InputType*& source)
-{
- delete source;
- switch(inputType) {
- case SentenceInput:
- source = ioWrapper.GetInput(new Sentence);
- break;
- case ConfusionNetworkInput:
- source = ioWrapper.GetInput(new ConfusionNet);
- break;
- case WordLatticeInput:
- source = ioWrapper.GetInput(new WordLattice);
- break;
- case TreeInputType:
- source = ioWrapper.GetInput(new TreeInput);
- break;
- default:
- TRACE_ERR("Unknown input type: " << inputType << "\n");
- }
- return (source ? true : false);
-}
-
int main(int argc, char* argv[])
{
try {
@@ -147,7 +124,7 @@ int main(int argc, char* argv[])
// read each sentence & decode
InputType *source=NULL;
size_t lineCount = staticData.GetStartTranslationId();
- while(ReadInput(*ioWrapper,staticData.GetInputType(),source)) {
+ while(ioWrapper->ReadInput(*ioWrapper,staticData.GetInputType(),source)) {
source->SetTranslationId(lineCount);
IFVERBOSE(1)
ResetUserTime();
diff --git a/moses-cmd/LatticeMBRGrid.cpp b/moses-cmd/LatticeMBRGrid.cpp
index 9a3ccdff0..bbf5f2a8b 100644
--- a/moses-cmd/LatticeMBRGrid.cpp
+++ b/moses-cmd/LatticeMBRGrid.cpp
@@ -177,7 +177,7 @@ int main(int argc, char* argv[])
const vector<float>& prune_grid = grid.getGrid(lmbr_prune);
const vector<float>& scale_grid = grid.getGrid(lmbr_scale);
- while(ReadInput(*ioWrapper,staticData.GetInputType(),source)) {
+ while(ioWrapper->ReadInput(*ioWrapper,staticData.GetInputType(),source)) {
++lineCount;
source->SetTranslationId(lineCount);
diff --git a/moses-cmd/Main.cpp b/moses-cmd/Main.cpp
index 2e4a4ffdc..f7d9a44da 100644
--- a/moses-cmd/Main.cpp
+++ b/moses-cmd/Main.cpp
@@ -140,7 +140,7 @@ int main(int argc, char** argv)
// main loop over set of input sentences
InputType* source = NULL;
size_t lineCount = staticData.GetStartTranslationId();
- while(ReadInput(*ioWrapper,staticData.GetInputType(),source)) {
+ while(ioWrapper->ReadInput(*ioWrapper,staticData.GetInputType(),source)) {
source->SetTranslationId(lineCount);
IFVERBOSE(1) {
ResetUserTime();
diff --git a/moses/IOWrapper.cpp b/moses/IOWrapper.cpp
index b00e5abae..bbe16827f 100644
--- a/moses/IOWrapper.cpp
+++ b/moses/IOWrapper.cpp
@@ -46,6 +46,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "moses/InputFileStream.h"
#include "moses/FF/StatefulFeatureFunction.h"
#include "moses/FF/StatelessFeatureFunction.h"
+#include "moses/TreeInput.h"
+#include "moses/ConfusionNet.h"
+#include "moses/WordLattice.h"
#include "util/exception.hh"
#include "IOWrapper.h"
@@ -475,6 +478,28 @@ void IOWrapper::OutputBestHypo(const Hypothesis *hypo, long /*translationId*/, c
}
}
+bool IOWrapper::ReadInput(IOWrapper &ioWrapper, InputTypeEnum inputType, InputType*& source)
+{
+ delete source;
+ switch(inputType) {
+ case SentenceInput:
+ source = ioWrapper.GetInput(new Sentence);
+ break;
+ case ConfusionNetworkInput:
+ source = ioWrapper.GetInput(new ConfusionNet);
+ break;
+ case WordLatticeInput:
+ source = ioWrapper.GetInput(new WordLattice);
+ break;
+ case TreeInputType:
+ source = ioWrapper.GetInput(new TreeInput);
+ break;
+ default:
+ TRACE_ERR("Unknown input type: " << inputType << "\n");
+ }
+ return (source ? true : false);
+}
+
void OutputNBest(std::ostream& out
, const Moses::TrellisPathList &nBestList
, const std::vector<Moses::FactorType>& outputFactorOrder
@@ -652,25 +677,6 @@ IOWrapper *IOWrapper::GetIOWrapper(const StaticData &staticData)
}
-bool ReadInput(IOWrapper &ioWrapper, InputTypeEnum inputType, InputType*& source)
-{
- if (source) delete source;
- switch(inputType) {
- case SentenceInput:
- source = ioWrapper.GetInput(new Sentence);
- break;
- case ConfusionNetworkInput:
- source = ioWrapper.GetInput(new ConfusionNet);
- break;
- case WordLatticeInput:
- source = ioWrapper.GetInput(new WordLattice);
- break;
- default:
- TRACE_ERR("Unknown input type: " << inputType << "\n");
- source = NULL;
- }
- return (source ? true : false);
-}
}
diff --git a/moses/IOWrapper.h b/moses/IOWrapper.h
index 2da16ffb0..a67418e42 100644
--- a/moses/IOWrapper.h
+++ b/moses/IOWrapper.h
@@ -105,6 +105,7 @@ public:
~IOWrapper();
Moses::InputType* GetInput(Moses::InputType *inputType);
+ bool ReadInput(IOWrapper &ioWrapper, Moses::InputTypeEnum inputType, Moses::InputType*& source);
void OutputBestHypo(const Moses::Hypothesis *hypo, long translationId, char reportSegmentation, bool reportAllFactors);
void OutputLatticeMBRNBestList(const std::vector<LatticeMBRSolution>& solutions,long translationId);
@@ -144,7 +145,6 @@ public:
};
-bool ReadInput(IOWrapper &ioWrapper, Moses::InputTypeEnum inputType, Moses::InputType*& source);
void OutputBestSurface(std::ostream &out, const Moses::Hypothesis *hypo, const std::vector<Moses::FactorType> &outputFactorOrder, char reportSegmentation, bool reportAllFactors);
void OutputLatticeMBRNBest(std::ostream& out, const std::vector<LatticeMBRSolution>& solutions,long translationId);
void OutputBestHypo(const std::vector<Moses::Word>& mbrBestHypo, long /*translationId*/,
diff --git a/moses/IOWrapperChart.cpp b/moses/IOWrapperChart.cpp
index d3a23c1b6..eded16b32 100644
--- a/moses/IOWrapperChart.cpp
+++ b/moses/IOWrapperChart.cpp
@@ -49,6 +49,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "moses/FF/StatelessFeatureFunction.h"
#include "moses/FF/TreeStructureFeature.h"
#include "moses/PP/TreeStructurePhraseProperty.h"
+#include "moses/TreeInput.h"
+#include "moses/ConfusionNet.h"
+#include "moses/WordLattice.h"
#include "util/exception.hh"
using namespace std;
@@ -171,6 +174,27 @@ InputType*IOWrapperChart::GetInput(InputType* inputType)
}
}
+bool IOWrapperChart::ReadInput(IOWrapperChart &ioWrapper, InputTypeEnum inputType, InputType*& source)
+{
+ delete source;
+ switch(inputType) {
+ case SentenceInput:
+ source = ioWrapper.GetInput(new Sentence);
+ break;
+ case ConfusionNetworkInput:
+ source = ioWrapper.GetInput(new ConfusionNet);
+ break;
+ case WordLatticeInput:
+ source = ioWrapper.GetInput(new WordLattice);
+ break;
+ case TreeInputType:
+ source = ioWrapper.GetInput(new TreeInput);
+ break;
+ default:
+ TRACE_ERR("Unknown input type: " << inputType << "\n");
+ }
+ return (source ? true : false);
+}
/***
* print surface factor only for the given phrase
diff --git a/moses/IOWrapperChart.h b/moses/IOWrapperChart.h
index 3af35f979..91b57eb70 100644
--- a/moses/IOWrapperChart.h
+++ b/moses/IOWrapperChart.h
@@ -118,6 +118,8 @@ public:
~IOWrapperChart();
Moses::InputType* GetInput(Moses::InputType *inputType);
+ bool ReadInput(IOWrapperChart &ioWrapper, InputTypeEnum inputType, InputType*& source);
+
void OutputBestHypo(const Moses::ChartHypothesis *hypo, long translationId);
void OutputBestHypo(search::Applied applied, long translationId);
void OutputBestNone(long translationId);