mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 04:43:03 +03:00
beautify
This commit is contained in:
parent
5eef91c0ea
commit
441acf15e6
@ -206,10 +206,10 @@ void OutputSurface(std::ostream &out, const Hypothesis &edge, const std::vector<
|
||||
const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[0]);
|
||||
|
||||
if (placeholderFactor != NOT_FOUND) {
|
||||
const Factor *origFactor = phrase.GetFactor(pos, placeholderFactor);
|
||||
if (origFactor) {
|
||||
factor = origFactor;
|
||||
}
|
||||
const Factor *origFactor = phrase.GetFactor(pos, placeholderFactor);
|
||||
if (origFactor) {
|
||||
factor = origFactor;
|
||||
}
|
||||
}
|
||||
CHECK(factor);
|
||||
out << *factor;
|
||||
@ -348,7 +348,7 @@ void OutputBestHypo(const std::vector<Word>& mbrBestHypo, long /*translationId*
|
||||
void OutputInput(std::vector<const Phrase*>& map, const Hypothesis* hypo)
|
||||
{
|
||||
if (hypo->GetPrevHypo()) {
|
||||
OutputInput(map, hypo->GetPrevHypo());
|
||||
OutputInput(map, hypo->GetPrevHypo());
|
||||
map[hypo->GetCurrSourceWordsRange().GetStartPos()] = &hypo->GetTranslationOption().GetSourcePhrase();
|
||||
}
|
||||
}
|
||||
|
@ -232,6 +232,6 @@ size_t ChartParser::GetSize() const
|
||||
|
||||
long ChartParser::GetTranslationId() const
|
||||
{
|
||||
return m_source.GetTranslationId();
|
||||
return m_source.GetTranslationId();
|
||||
}
|
||||
} // namespace Moses
|
||||
|
@ -51,8 +51,9 @@ public:
|
||||
return m_cellCollection.GetBase(WordsRange(begin, end)).GetTargetLabelSet();
|
||||
}
|
||||
|
||||
const ChartParser &GetParser() const
|
||||
{ return m_parser; }
|
||||
const ChartParser &GetParser() const {
|
||||
return m_parser;
|
||||
}
|
||||
//const Sentence &GetSentence() const;
|
||||
|
||||
const ChartCellLabel &GetSourceAt(size_t at) const {
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
TranslationOptionCollection* CreateTranslationOptionCollection() const;
|
||||
|
||||
const NonTerminalSet &GetLabelSet(size_t /*startPos*/, size_t /*endPos*/) const {
|
||||
return m_defaultLabelSet;
|
||||
return m_defaultLabelSet;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -41,11 +41,11 @@ public:
|
||||
|
||||
|
||||
void Process(const TranslationOption &inputPartialTranslOpt
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const;
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const;
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -173,33 +173,33 @@ void DecodeStepTranslation::ProcessInitialTranslationLegacy(
|
||||
}
|
||||
|
||||
const InputPath &DecodeStepTranslation::GetInputPathLegacy(const TargetPhrase targetPhrase,
|
||||
const InputPathList &inputPathList) const
|
||||
const InputPathList &inputPathList) const
|
||||
{
|
||||
const Phrase &phraseFromTP = targetPhrase.GetSourcePhraseAA();
|
||||
const Word &wordTP = phraseFromTP.GetWord(0);
|
||||
const Phrase &phraseFromTP = targetPhrase.GetSourcePhraseAA();
|
||||
const Word &wordTP = phraseFromTP.GetWord(0);
|
||||
|
||||
InputPathList::const_iterator iter;
|
||||
for (iter = inputPathList.begin(); iter != inputPathList.end(); ++iter) {
|
||||
const InputPath &inputPath = **iter;
|
||||
const Phrase &phraseFromIP = inputPath.GetPhrase();
|
||||
const Word &wordIP = phraseFromIP.GetWord(0);
|
||||
InputPathList::const_iterator iter;
|
||||
for (iter = inputPathList.begin(); iter != inputPathList.end(); ++iter) {
|
||||
const InputPath &inputPath = **iter;
|
||||
const Phrase &phraseFromIP = inputPath.GetPhrase();
|
||||
const Word &wordIP = phraseFromIP.GetWord(0);
|
||||
|
||||
const WordsRange &range = inputPath.GetWordsRange();
|
||||
const WordsRange &range = inputPath.GetWordsRange();
|
||||
|
||||
if (wordTP == wordIP) {
|
||||
return inputPath;
|
||||
}
|
||||
}
|
||||
if (wordTP == wordIP) {
|
||||
return inputPath;
|
||||
}
|
||||
}
|
||||
|
||||
UTIL_THROW(util::Exception, "Input path not found");
|
||||
UTIL_THROW(util::Exception, "Input path not found");
|
||||
}
|
||||
|
||||
void DecodeStepTranslation::ProcessLegacy(const TranslationOption &inputPartialTranslOpt
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const
|
||||
{
|
||||
if (inputPartialTranslOpt.GetTargetPhrase().GetSize() == 0) {
|
||||
// word deletion
|
||||
@ -216,7 +216,7 @@ void DecodeStepTranslation::ProcessLegacy(const TranslationOption &inputPartialT
|
||||
const size_t tableLimit = phraseDictionary->GetTableLimit();
|
||||
|
||||
const TargetPhraseCollectionWithSourcePhrase *phraseColl
|
||||
= phraseDictionary->GetTargetPhraseCollectionLegacy(toc->GetSource(),sourceWordsRange);
|
||||
= phraseDictionary->GetTargetPhraseCollectionLegacy(toc->GetSource(),sourceWordsRange);
|
||||
|
||||
|
||||
if (phraseColl != NULL) {
|
||||
|
@ -61,22 +61,22 @@ public:
|
||||
|
||||
// legacy
|
||||
void ProcessInitialTranslationLegacy(const InputType &source
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, size_t startPos, size_t endPos, bool adhereTableLimit
|
||||
, const InputPathList &inputPathList) const;
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, size_t startPos, size_t endPos, bool adhereTableLimit
|
||||
, const InputPathList &inputPathList) const;
|
||||
void ProcessLegacy(const TranslationOption &inputPartialTranslOpt
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const;
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const;
|
||||
|
||||
private:
|
||||
// I'm not sure whether this actually works or not for binary phrase table.
|
||||
// The source phrase only appears to contain the 1st word, therefore, this function
|
||||
// only compares the 1st word
|
||||
const InputPath &GetInputPathLegacy(const TargetPhrase targetPhrase,
|
||||
const InputPathList &inputPathList) const;
|
||||
const InputPathList &inputPathList) const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -345,7 +345,7 @@ void Hypothesis::PrintHypothesis() const
|
||||
TRACE_ERR( ")"<<endl);
|
||||
TRACE_ERR( "\tbase score "<< (m_prevHypo->m_totalScore - m_prevHypo->m_futureScore) <<endl);
|
||||
TRACE_ERR( "\tcovering "<<m_currSourceWordsRange.GetStartPos()<<"-"<<m_currSourceWordsRange.GetEndPos()
|
||||
<<": " << m_transOpt.GetSourcePhrase() << endl);
|
||||
<<": " << m_transOpt.GetSourcePhrase() << endl);
|
||||
|
||||
TRACE_ERR( "\ttranslated as: "<<(Phrase&) GetCurrTargetPhrase()<<endl); // <<" => translation cost "<<m_score[ScoreType::PhraseTrans];
|
||||
|
||||
@ -398,7 +398,8 @@ void Hypothesis::CleanupArcList()
|
||||
}
|
||||
}
|
||||
|
||||
const TargetPhrase &Hypothesis::GetCurrTargetPhrase() const {
|
||||
const TargetPhrase &Hypothesis::GetCurrTargetPhrase() const
|
||||
{
|
||||
return m_transOpt.GetTargetPhrase();
|
||||
}
|
||||
|
||||
|
@ -3,18 +3,19 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Moses {
|
||||
std::ostream& operator<<(std::ostream &out, const NonTerminalSet &obj)
|
||||
{
|
||||
NonTerminalSet::const_iterator iter;
|
||||
for (iter = obj.begin(); iter != obj.end(); ++iter) {
|
||||
const Word &word = *iter;
|
||||
out << word << " ";
|
||||
}
|
||||
|
||||
|
||||
return out;
|
||||
namespace Moses
|
||||
{
|
||||
std::ostream& operator<<(std::ostream &out, const NonTerminalSet &obj)
|
||||
{
|
||||
NonTerminalSet::const_iterator iter;
|
||||
for (iter = obj.begin(); iter != obj.end(); ++iter) {
|
||||
const Word &word = *iter;
|
||||
out << word << " ";
|
||||
}
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -309,11 +309,13 @@ public:
|
||||
}
|
||||
|
||||
TargetPhraseCollectionWithSourcePhrase* PruneTargetCandidates
|
||||
(const std::vector<TargetPhrase> & tCands,
|
||||
std::vector<std::pair<float,size_t> >& costs,
|
||||
const std::vector<Phrase> &sourcePhrases) const {
|
||||
(const std::vector<TargetPhrase> & tCands,
|
||||
std::vector<std::pair<float,size_t> >& costs,
|
||||
const std::vector<Phrase> &sourcePhrases) const {
|
||||
// convert into TargetPhraseCollection
|
||||
TargetPhraseCollectionWithSourcePhrase *rv=new TargetPhraseCollectionWithSourcePhrase;
|
||||
CHECK(tCands.size() == sourcePhrases.size());
|
||||
|
||||
TargetPhraseCollectionWithSourcePhrase *rv=new TargetPhraseCollectionWithSourcePhrase;
|
||||
|
||||
|
||||
// set limit to tableLimit or actual size, whatever is smaller
|
||||
|
@ -8,9 +8,9 @@ namespace Moses
|
||||
{
|
||||
|
||||
Search::Search(Manager& manager)
|
||||
: m_manager(manager)
|
||||
,m_sourcePhrase(0)
|
||||
,m_initialTransOpt()
|
||||
: m_manager(manager)
|
||||
,m_sourcePhrase(0)
|
||||
,m_initialTransOpt()
|
||||
{
|
||||
m_initialTransOpt.SetSourcePhrase(m_sourcePhrase);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
void CleanUpAfterSentenceProcessing(const InputType &source);
|
||||
|
||||
virtual ChartRuleLookupManager *CreateRuleLookupManager(
|
||||
const ChartParser &,
|
||||
const ChartParser &,
|
||||
const ChartCellCollectionBase &) {
|
||||
assert(false);
|
||||
return 0;
|
||||
|
@ -110,8 +110,8 @@ PhraseDictionaryTreeAdaptor::GetTargetPhraseCollectionLegacy(InputType const& sr
|
||||
const TargetPhraseCollectionWithSourcePhrase *tpColl = GetImplementation().GetTargetPhraseCollection(src.GetSubString(range));
|
||||
return tpColl;
|
||||
} else {
|
||||
const TargetPhraseCollectionWithSourcePhrase *tpColl = GetImplementation().m_rangeCache[range.GetStartPos()][range.GetEndPos()];
|
||||
return tpColl;
|
||||
const TargetPhraseCollectionWithSourcePhrase *tpColl = GetImplementation().m_rangeCache[range.GetStartPos()][range.GetEndPos()];
|
||||
return tpColl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,9 @@ namespace Moses
|
||||
{
|
||||
|
||||
TranslationOption::TranslationOption()
|
||||
:m_targetPhrase()
|
||||
,m_sourcePhrase(NULL)
|
||||
,m_sourceWordsRange(NOT_FOUND, NOT_FOUND)
|
||||
:m_targetPhrase()
|
||||
,m_sourcePhrase(NULL)
|
||||
,m_sourceWordsRange(NOT_FOUND, NOT_FOUND)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,7 @@ public:
|
||||
/** returns source phrase */
|
||||
const Phrase &GetSourcePhrase() const;
|
||||
|
||||
void SetSourcePhrase(const Phrase &sourcePhrase)
|
||||
{
|
||||
void SetSourcePhrase(const Phrase &sourcePhrase) {
|
||||
m_sourcePhrase = &sourcePhrase;
|
||||
}
|
||||
|
||||
|
@ -262,9 +262,9 @@ void TranslationOptionCollection::ProcessOneUnknownWord(const Word &sourceWord,s
|
||||
}
|
||||
|
||||
// source phrase
|
||||
Phrase *unksrc = new Phrase(1);
|
||||
unksrc->AddWord() = sourceWord;
|
||||
m_unksrcs.push_back(unksrc);
|
||||
Phrase *unksrc = new Phrase(1);
|
||||
unksrc->AddWord() = sourceWord;
|
||||
m_unksrcs.push_back(unksrc);
|
||||
|
||||
targetPhrase.Evaluate(*unksrc);
|
||||
|
||||
@ -482,12 +482,12 @@ void TranslationOptionCollection::CreateTranslationOptionsForRange(
|
||||
} else {
|
||||
const DecodeStepGeneration *genStep = dynamic_cast<const DecodeStepGeneration*>(decodeStep);
|
||||
assert(genStep);
|
||||
genStep->Process(inputPartialTranslOpt
|
||||
, *decodeStep
|
||||
, *newPtoc
|
||||
, this
|
||||
, adhereTableLimit
|
||||
, *sourcePhrase);
|
||||
genStep->Process(inputPartialTranslOpt
|
||||
, *decodeStep
|
||||
, *newPtoc
|
||||
, this
|
||||
, adhereTableLimit
|
||||
, *sourcePhrase);
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,8 +530,8 @@ void TranslationOptionCollection::SetInputPath(const InputPath &inputPath, Parti
|
||||
transOpt.SetSourcePhrase(sourcePhrase);
|
||||
|
||||
if (inputScore) {
|
||||
ScoreComponentCollection &scores = transOpt.GetScoreBreakdown();
|
||||
scores.PlusEquals(*inputScore);
|
||||
ScoreComponentCollection &scores = transOpt.GetScoreBreakdown();
|
||||
scores.PlusEquals(*inputScore);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -663,7 +663,7 @@ void TranslationOptionCollection::CacheLexReordering()
|
||||
//Phrase sourcePhrase = m_source.GetSubString(WordsRange(startPos,endPos));
|
||||
const Phrase &sourcePhrase = transOpt.GetSourcePhrase();
|
||||
Scores score = lexreordering.GetProb(sourcePhrase
|
||||
, transOpt.GetTargetPhrase());
|
||||
, transOpt.GetTargetPhrase());
|
||||
if (!score.empty())
|
||||
transOpt.CacheLexReorderingScores(lexreordering, score);
|
||||
} // for(iterTransOpt
|
||||
|
@ -192,7 +192,7 @@ void TranslationOptionCollectionConfusionNet::CreateTranslationOptionsForRangeLe
|
||||
if ((StaticData::Instance().GetXmlInputType() != XmlExclusive) || !HasXmlOptionsOverlappingRange(startPos,endPos)) {
|
||||
Phrase *sourcePhrase = NULL; // can't initialise with substring, in case it's confusion network
|
||||
|
||||
InputPathList &inputPathList = GetInputPathList(startPos, endPos);
|
||||
InputPathList &inputPathList = GetInputPathList(startPos, endPos);
|
||||
|
||||
// partial trans opt stored in here
|
||||
PartialTranslOptColl* oldPtoc = new PartialTranslOptColl;
|
||||
@ -225,21 +225,20 @@ void TranslationOptionCollectionConfusionNet::CreateTranslationOptionsForRangeLe
|
||||
|
||||
if (transStep) {
|
||||
transStep->ProcessLegacy(inputPartialTranslOpt
|
||||
, *decodeStep
|
||||
, *newPtoc
|
||||
, this
|
||||
, adhereTableLimit
|
||||
, *sourcePhrase);
|
||||
} else {
|
||||
CHECK(genStep);
|
||||
genStep->Process(inputPartialTranslOpt
|
||||
, *decodeStep
|
||||
, *newPtoc
|
||||
, this
|
||||
, adhereTableLimit
|
||||
, *sourcePhrase);
|
||||
}
|
||||
else {
|
||||
CHECK(genStep);
|
||||
genStep->Process(inputPartialTranslOpt
|
||||
, *decodeStep
|
||||
, *newPtoc
|
||||
, this
|
||||
, adhereTableLimit
|
||||
, *sourcePhrase);
|
||||
}
|
||||
}
|
||||
|
||||
// last but 1 partial trans not required anymore
|
||||
|
Loading…
Reference in New Issue
Block a user