mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-17 23:40:50 +03:00
get ready to merge IOWrapper
This commit is contained in:
parent
23d0afcde1
commit
89f8c7d284
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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*/,
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user