don't skip empty lines

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1169 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
hieuhoang1972 2007-02-05 10:24:01 +00:00
parent 7168a3264c
commit 9cf7257d27
3 changed files with 35 additions and 35 deletions

View File

@ -113,44 +113,44 @@ int main(int argc, char* argv[])
InputType *source=0;
size_t lineCount = 0;
while(readInput(*ioStream,staticData.GetInputType(),source))
{
{
// note: source is only valid within this while loop!
ResetUserTime();
VERBOSE(2,"\nTRANSLATING(" << ++lineCount << "): " << *source);
staticData.InitializeBeforeSentenceProcessing(*source);
Manager manager(*source, staticData);
manager.ProcessSentence();
ioStream->OutputBestHypo(manager.GetBestHypothesis(), source->GetTranslationId(),
staticData.GetReportSegmentation(),
staticData.GetReportAllFactors()
);
IFVERBOSE(2) { PrintUserTime("Best Hypothesis Generation Time:"); }
staticData.InitializeBeforeSentenceProcessing(*source);
Manager manager(*source, staticData);
manager.ProcessSentence();
ioStream->OutputBestHypo(manager.GetBestHypothesis(), source->GetTranslationId(),
staticData.GetReportSegmentation(),
staticData.GetReportAllFactors()
);
IFVERBOSE(2) { PrintUserTime("Best Hypothesis Generation Time:"); }
// n-best
size_t nBestSize = staticData.GetNBestSize();
if (nBestSize > 0)
{
VERBOSE(2,"WRITING " << nBestSize << " TRANSLATION ALTERNATIVES TO " << staticData.GetNBestFilePath() << endl);
LatticePathList nBestList;
manager.CalcNBest(nBestSize, nBestList,staticData.GetDistinctNBest());
ioStream->OutputNBestList(nBestList, source->GetTranslationId());
//RemoveAllInColl(nBestList);
// n-best
size_t nBestSize = staticData.GetNBestSize();
if (nBestSize > 0)
{
VERBOSE(2,"WRITING " << nBestSize << " TRANSLATION ALTERNATIVES TO " << staticData.GetNBestFilePath() << endl);
LatticePathList nBestList;
manager.CalcNBest(nBestSize, nBestList,staticData.GetDistinctNBest());
ioStream->OutputNBestList(nBestList, source->GetTranslationId());
//RemoveAllInColl(nBestList);
IFVERBOSE(2) { PrintUserTime("N-Best Hypotheses Generation Time:"); }
}
if (staticData.IsDetailedTranslationReportingEnabled()) {
TranslationAnalysis::PrintTranslationAnalysis(std::cerr, manager.GetBestHypothesis());
}
IFVERBOSE(2) { PrintUserTime("Sentence Decoding Time:"); }
manager.CalcDecoderStatistics(staticData);
staticData.CleanUpAfterSentenceProcessing();
IFVERBOSE(2) { PrintUserTime("N-Best Hypotheses Generation Time:"); }
}
if (staticData.IsDetailedTranslationReportingEnabled()) {
TranslationAnalysis::PrintTranslationAnalysis(std::cerr, manager.GetBestHypothesis());
}
IFVERBOSE(2) { PrintUserTime("Sentence Decoding Time:"); }
manager.CalcDecoderStatistics(staticData);
staticData.CleanUpAfterSentenceProcessing();
}
delete ioStream;

View File

@ -46,6 +46,7 @@ Manager::Manager(InputType const& source, StaticData &staticData)
,m_possibleTranslations(source.CreateTranslationOptionCollection())
,m_initialTargetPhrase(Output)
{
TRACE_ERR("Translating: " << m_source << endl);
std::vector < HypothesisCollection >::iterator iterStack;
for (iterStack = m_hypoStack.begin() ; iterStack != m_hypoStack.end() ; ++iterStack)
{
@ -58,6 +59,7 @@ Manager::Manager(InputType const& source, StaticData &staticData)
Manager::~Manager()
{
delete m_possibleTranslations;
TRACE_ERR("Finished translating" << endl);
}
/**

View File

@ -31,11 +31,9 @@ int Sentence::Read(std::istream& in,const std::vector<FactorType>& factorOrder,
{
const std::string& factorDelimiter = StaticData::Instance()->GetFactorDelimiter();
std::string line;
do
{
if (getline(in, line, '\n').eof()) return 0;
line = Trim(line);
} while (line == "");
if (getline(in, line, '\n').eof())
return 0;
line = Trim(line);
Phrase::CreateFromString(factorOrder, line, factorCollection, factorDelimiter);
return 1;