daily automatic beautifier

This commit is contained in:
MosesAdmin 2015-11-02 00:00:37 +00:00
parent 8424fb6e2a
commit f38976aba0
35 changed files with 216 additions and 218 deletions

View File

@ -202,8 +202,8 @@ int main(int argc, char* argv[])
<< " ||| ";
vector<Word> mbrBestHypo = doLatticeMBR(manager,nBestList);
manager.OutputBestHypo(mbrBestHypo, lineCount,
manager.options().output.ReportSegmentation,
manager.options().output.ReportAllFactors,
manager.options().output.ReportSegmentation,
manager.options().output.ReportAllFactors,
cout);
}
}

View File

@ -106,9 +106,9 @@ std::set<size_t> AlignmentInfo::GetAlignmentsForTarget(size_t targetPos) const
}
bool
compare_target(std::pair<size_t,size_t> const* a,
std::pair<size_t,size_t> const* b)
bool
compare_target(std::pair<size_t,size_t> const* a,
std::pair<size_t,size_t> const* b)
{
if(a->second < b->second) return true;
if(a->second == b->second) return (a->first < b->first);
@ -116,29 +116,29 @@ compare_target(std::pair<size_t,size_t> const* a,
}
std::vector< const std::pair<size_t,size_t>* >
std::vector< const std::pair<size_t,size_t>* >
AlignmentInfo::
GetSortedAlignments(WordAlignmentSort SortOrder) const
{
std::vector< const std::pair<size_t,size_t>* > ret;
CollType::const_iterator iter;
for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) {
const std::pair<size_t,size_t> &alignPair = *iter;
ret.push_back(&alignPair);
}
switch (SortOrder) {
case NoSort:
break;
case TargetOrder:
std::sort(ret.begin(), ret.end(), compare_target);
break;
default:
UTIL_THROW(util::Exception, "Unknown word alignment sort option: "
<< SortOrder);
UTIL_THROW(util::Exception, "Unknown word alignment sort option: "
<< SortOrder);
}
return ret;

View File

@ -83,7 +83,7 @@ public:
return m_collection.size();
}
std::vector< const std::pair<size_t,size_t>* >
std::vector< const std::pair<size_t,size_t>* >
GetSortedAlignments(WordAlignmentSort SortOrder) const;
std::vector<size_t> GetSourceIndex2PosMap() const;

View File

@ -65,12 +65,11 @@ bool ChartCell::AddHypothesis(ChartHypothesis *hypo)
{
const Word &targetLHS = hypo->GetTargetLHS();
MapType::iterator m = m_hypoColl.find(targetLHS);
if (m == m_hypoColl.end())
{
std::pair<Word, ChartHypothesisCollection>
e(targetLHS, ChartHypothesisCollection(m_manager.options()));
m = m_hypoColl.insert(e).first;
}
if (m == m_hypoColl.end()) {
std::pair<Word, ChartHypothesisCollection>
e(targetLHS, ChartHypothesisCollection(m_manager.options()));
m = m_hypoColl.insert(e).first;
}
return m->second.AddHypothesis(hypo, m_manager);
}

View File

@ -29,7 +29,7 @@ namespace Moses
{
class ChartSearchGraphWriter;
class AllOptions;
class AllOptions;
//! functor to compare (chart) hypotheses by (descending) score
class ChartHypothesisScoreOrderer

View File

@ -108,12 +108,12 @@ void ChartParserUnknown::Process(const Word &sourceWord, const Range &range, Cha
targetPhrase->EvaluateInIsolation(*unksrc);
AllOptions const& opts = staticData.options();
if (!opts.output.detailed_tree_transrep_filepath.empty() ||
opts.nbest.print_trees || staticData.GetTreeStructure() != NULL) {
std::string prop = "[ ";
prop += (*targetLHS)[0]->GetString().as_string() + " ";
prop += sourceWord[0]->GetString().as_string() + " ]";
targetPhrase->SetProperty("Tree", prop);
if (!opts.output.detailed_tree_transrep_filepath.empty() ||
opts.nbest.print_trees || staticData.GetTreeStructure() != NULL) {
std::string prop = "[ ";
prop += (*targetLHS)[0]->GetString().as_string() + " ";
prop += sourceWord[0]->GetString().as_string() + " ]";
targetPhrase->SetProperty("Tree", prop);
}
// chart rule

View File

@ -68,7 +68,7 @@ public:
virtual void Print(std::ostream&) const;
int Read(std::istream& in,const std::vector<FactorType>& factorOrder,
AllOptions const& opts);
AllOptions const& opts);
Phrase GetSubString(const Range&) const; //TODO not defined
std::string GetStringRep(const std::vector<FactorType> factorsToPrint) const; //TODO not defined

View File

@ -100,14 +100,14 @@ void DecodeStepTranslation::Process(const TranslationOption &inputPartialTranslO
}
}
void
void
DecodeStepTranslation::
ProcessInitialTranslation(InputType const& source,
PartialTranslOptColl &outputPartialTranslOptColl,
size_t startPos, size_t endPos,
bool adhereTableLimit,
InputPath const& inputPath,
TargetPhraseCollection::shared_ptr phraseColl) const
PartialTranslOptColl &outputPartialTranslOptColl,
size_t startPos, size_t endPos,
bool adhereTableLimit,
InputPath const& inputPath,
TargetPhraseCollection::shared_ptr phraseColl) const
{
const PhraseDictionary* phraseDictionary = GetPhraseDictionaryFeature();
const size_t tableLimit = phraseDictionary->GetTableLimit();
@ -117,12 +117,12 @@ ProcessInitialTranslation(InputType const& source,
if (phraseColl != NULL) {
IFVERBOSE(3) {
if(source.GetType() == SentenceInput)
TRACE_ERR("[" << source.GetSubString(range) << "; "
<< startPos << "-" << endPos << "]\n");
TRACE_ERR("[" << source.GetSubString(range) << "; "
<< startPos << "-" << endPos << "]\n");
else
TRACE_ERR("[" << startPos << "-" << endPos << "]" << std::endl);
}
TargetPhraseCollection::const_iterator iterTargetPhrase, iterEnd;
iterEnd = (!adhereTableLimit || tableLimit == 0 || phraseColl->GetSize() < tableLimit) ? phraseColl->end() : phraseColl->begin() + tableLimit;
@ -140,13 +140,13 @@ ProcessInitialTranslation(InputType const& source,
}
}
void
void
DecodeStepTranslation::
ProcessInitialTransLEGACY(InputType const& source,
PartialTranslOptColl &outputPartialTranslOptColl,
size_t startPos, size_t endPos,
bool adhereTableLimit,
InputPathList const& inputPathList) const
PartialTranslOptColl &outputPartialTranslOptColl,
size_t startPos, size_t endPos,
bool adhereTableLimit,
InputPathList const& inputPathList) const
{
const PhraseDictionary* phraseDictionary = GetPhraseDictionaryFeature();
const size_t tableLimit = phraseDictionary->GetTableLimit();
@ -158,12 +158,12 @@ ProcessInitialTransLEGACY(InputType const& source,
if (phraseColl != NULL) {
IFVERBOSE(3) {
if(source.GetType() == SentenceInput)
TRACE_ERR("[" << source.GetSubString(range) << "; "
<< startPos << "-" << endPos << "]\n");
TRACE_ERR("[" << source.GetSubString(range) << "; "
<< startPos << "-" << endPos << "]\n");
else
TRACE_ERR("[" << startPos << "-" << endPos << "]" << std::endl);
}
const std::vector<Phrase> &sourcePhrases = phraseColl->GetSourcePhrases();
TargetPhraseCollection::const_iterator iterTargetPhrase, iterEnd;

View File

@ -61,12 +61,12 @@ public:
, TargetPhraseCollection::shared_ptr phraseColl) const;
// legacy
void
void
ProcessInitialTransLEGACY(InputType const& source,
PartialTranslOptColl &outputPartialTranslOptColl,
size_t startPos, size_t endPos,
bool adhereTableLimit,
InputPathList const& inputPathList) const;
PartialTranslOptColl &outputPartialTranslOptColl,
size_t startPos, size_t endPos,
bool adhereTableLimit,
InputPathList const& inputPathList) const;
void ProcessLEGACY(const TranslationOption &inputPartialTranslOpt
, const DecodeStep &decodeStep

View File

@ -28,9 +28,9 @@ public:
}
//! populate this InputType with data from in stream
virtual int
virtual int
Read(std::istream& in,
std::vector<FactorType> const& factorOrder,
std::vector<FactorType> const& factorOrder,
AllOptions const& opts);
//! Output debugging info to stream out

View File

@ -380,16 +380,16 @@ OutputAlignment(std::ostream &out) const
edges.push_back(currentHypo);
currentHypo = currentHypo->GetPrevHypo();
}
OutputAlignment(out, edges, m_manager.options().output.WA_SortOrder);
}
void
Hypothesis::
OutputAlignment(ostream &out,
vector<const Hypothesis *> const& edges,
WordAlignmentSort waso)
OutputAlignment(ostream &out,
vector<const Hypothesis *> const& edges,
WordAlignmentSort waso)
{
size_t targetOffset = 0;
@ -409,7 +409,7 @@ void
Hypothesis::
OutputAlignment(ostream &out, const AlignmentInfo &ai,
size_t sourceOffset, size_t targetOffset,
WordAlignmentSort waso)
WordAlignmentSort waso)
{
typedef std::vector< const std::pair<size_t,size_t>* > AlignVec;
AlignVec alignments = ai.GetSortedAlignments(waso);
@ -417,8 +417,8 @@ OutputAlignment(ostream &out, const AlignmentInfo &ai,
AlignVec::const_iterator it;
for (it = alignments.begin(); it != alignments.end(); ++it) {
const std::pair<size_t,size_t> &alignment = **it;
out << alignment.first + sourceOffset << "-"
<< alignment.second + targetOffset << " ";
out << alignment.first + sourceOffset << "-"
<< alignment.second + targetOffset << " ";
}
}
@ -608,7 +608,7 @@ OutputLocalWordAlignment(vector<xmlrpc_c::value>& dest) const
using namespace std;
Range const& src = this->GetCurrSourceWordsRange();
Range const& trg = this->GetCurrTargetWordsRange();
WordAlignmentSort waso = m_manager.options().output.WA_SortOrder;
vector<pair<size_t,size_t> const* > a
= this->GetCurrTargetPhrase().GetAlignTerm().GetSortedAlignments(waso);

View File

@ -251,18 +251,18 @@ public:
return m_transOpt;
}
void
void
OutputAlignment(std::ostream &out) const;
static void
OutputAlignment(std::ostream &out,
const std::vector<const Hypothesis *> &edges,
WordAlignmentSort waso);
static void
OutputAlignment(std::ostream &out,
const std::vector<const Hypothesis *> &edges,
WordAlignmentSort waso);
static void
OutputAlignment(std::ostream &out, const Moses::AlignmentInfo &ai,
size_t sourceOffset, size_t targetOffset,
WordAlignmentSort waso);
static void
OutputAlignment(std::ostream &out, const Moses::AlignmentInfo &ai,
size_t sourceOffset, size_t targetOffset,
WordAlignmentSort waso);
void OutputInput(std::ostream& os) const;
static void OutputInput(std::vector<const Phrase*>& map, const Hypothesis* hypo);

View File

@ -95,7 +95,7 @@ IOWrapper::IOWrapper()
m_look_back = staticData.options().context.look_back;
m_inputType = staticData.options().input.input_type;
UTIL_THROW_IF2((m_look_ahead || m_look_back) && m_inputType != SentenceInput,
"Context-sensitive decoding currently works only with sentence input.");

View File

@ -320,15 +320,15 @@ void Manager::OutputNBest(OutputCollector *collector) const
OutputNBestList(collector, *completed_nbest_, m_source.GetTranslationId());
}
void
void
Manager::
OutputNBestList(OutputCollector *collector,
std::vector<search::Applied> const& nbest,
long translationId) const
OutputNBestList(OutputCollector *collector,
std::vector<search::Applied> const& nbest,
long translationId) const
{
const StaticData &staticData = StaticData::Instance();
const std::vector<Moses::FactorType> &outputFactorOrder
= staticData.GetOutputFactorOrder();
const std::vector<Moses::FactorType> &outputFactorOrder
= staticData.GetOutputFactorOrder();
std::ostringstream out;
// wtf? copied from the original OutputNBestList
@ -337,13 +337,13 @@ OutputNBestList(OutputCollector *collector,
}
Phrase outputPhrase;
ScoreComponentCollection features;
for (std::vector<search::Applied>::const_iterator i = nbest.begin();
for (std::vector<search::Applied>::const_iterator i = nbest.begin();
i != nbest.end(); ++i) {
Incremental::PhraseAndFeatures(*i, outputPhrase, features);
// <s> and </s>
UTIL_THROW_IF2(outputPhrase.GetSize() < 2,
"Output phrase should have contained at least 2 words "
<< "(beginning and end-of-sentence)");
<< "(beginning and end-of-sentence)");
outputPhrase.RemoveWord(0);
outputPhrase.RemoveWord(outputPhrase.GetSize() - 1);
@ -359,7 +359,7 @@ OutputNBestList(OutputCollector *collector,
collector->Write(translationId, out.str());
}
void
void
Manager::
OutputDetailedTranslationReport(OutputCollector *collector) const
{
@ -525,7 +525,7 @@ void Manager::OutputBestHypo(OutputCollector *collector, search::Applied applied
VERBOSE(1,"BEST TRANSLATION: " << outPhrase << "[total=" << applied.GetScore() << "]" << std::endl);
}
void
void
Manager::
OutputBestNone(OutputCollector *collector, long translationId) const
{

View File

@ -184,8 +184,8 @@ public:
}
//! populate this InputType with data from in stream
virtual int
Read(std::istream& in,
virtual int
Read(std::istream& in,
std::vector<FactorType> const& factorOrder,
AllOptions const& opts) =0;

View File

@ -97,11 +97,11 @@ public:
virtual void CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore, size_t &oovCount) const;
virtual FFState *EvaluateWhenApplied(const Hypothesis &hypo, const FFState *ps, ScoreComponentCollection *out) const;
/*
virtual FFState *EvaluateWhenApplied(const ChartHypothesis& cur_hypo, int featureID, ScoreComponentCollection *accumulator) const;
/*
virtual FFState *EvaluateWhenApplied(const ChartHypothesis& cur_hypo, int featureID, ScoreComponentCollection *accumulator) const;
virtual FFState *EvaluateWhenApplied(const Syntax::SHyperedge& hyperedge, int featureID, ScoreComponentCollection *accumulator) const;
*/
virtual FFState *EvaluateWhenApplied(const Syntax::SHyperedge& hyperedge, int featureID, ScoreComponentCollection *accumulator) const;
*/
void InitializeForInput(ttasksptr const& ttask);
void CleanUpAfterSentenceProcessing(const InputType& source);

View File

@ -100,8 +100,8 @@ Manager::GetSource() const
void Manager::Decode()
{
std::cerr << options().nbest.nbest_size << " "
<< options().nbest.enabled << " " << std::endl;
std::cerr << options().nbest.nbest_size << " "
<< options().nbest.enabled << " " << std::endl;
// initialize statistics
ResetSentenceStats(m_source);
@ -128,8 +128,8 @@ void Manager::Decode()
// some reporting on how long this took
IFVERBOSE(1) {
GetSentenceStats().StopTimeCollectOpts();
TRACE_ERR("Line "<< m_source.GetTranslationId()
<< ": Collecting options took "
TRACE_ERR("Line "<< m_source.GetTranslationId()
<< ": Collecting options took "
<< GetSentenceStats().GetTimeCollectOpts() << " seconds at "
<< __FILE__ << ":" << __LINE__ << endl);
}
@ -1118,10 +1118,10 @@ void Manager::OutputSearchGraphAsSLF(long translationId, std::ostream &outputSea
}
void
OutputSearchNode(AllOptions const& opts, long translationId,
std::ostream &outputSearchGraphStream,
SearchGraphNode const& searchNode)
void
OutputSearchNode(AllOptions const& opts, long translationId,
std::ostream &outputSearchGraphStream,
SearchGraphNode const& searchNode)
{
const vector<FactorType> &outputFactorOrder = StaticData::Instance().GetOutputFactorOrder();
bool extendedFormat = opts.output.SearchGraphExtended.size();
@ -1377,7 +1377,7 @@ void Manager::SerializeSearchGraphPB(
}
#endif
void
void
Manager::
OutputSearchGraph(long translationId, std::ostream &out) const
{
@ -1388,12 +1388,12 @@ OutputSearchGraph(long translationId, std::ostream &out) const
}
}
void
void
Manager::
GetForwardBackwardSearchGraph
( std::map< int, bool >* pConnected,
std::vector<Hypothesis const* >* pConnectedList,
std::map<Hypothesis const*, set<Hypothesis const*> >* pOutgoingHyps,
std::vector<Hypothesis const* >* pConnectedList,
std::map<Hypothesis const*, set<Hypothesis const*> >* pOutgoingHyps,
vector< float>* pFwdBwdScores) const
{
std::map < int, bool > &connected = *pConnected;
@ -1401,8 +1401,8 @@ GetForwardBackwardSearchGraph
std::map < int, int > forward;
std::map < int, double > forwardScore;
std::map < const Hypothesis*, set <const Hypothesis*> > & outgoingHyps
= *pOutgoingHyps;
std::map < const Hypothesis*, set <const Hypothesis*> > & outgoingHyps
= *pOutgoingHyps;
vector< float> & estimatedScores = *pFwdBwdScores;
// *** find connected hypotheses ***
@ -1411,8 +1411,8 @@ GetForwardBackwardSearchGraph
// ** compute best forward path for each hypothesis *** //
// forward cost of hypotheses on final stack is 0
const std::vector < HypothesisStack* > &hypoStackColl
= m_search->GetHypothesisStacks();
const std::vector < HypothesisStack* > &hypoStackColl
= m_search->GetHypothesisStacks();
const HypothesisStack &finalStack = *hypoStackColl.back();
HypothesisStack::const_iterator iterHypo;
for (iterHypo = finalStack.begin() ; iterHypo != finalStack.end() ; ++iterHypo) {
@ -1531,12 +1531,12 @@ void Manager::OutputBest(OutputCollector *collector) const
// const PARAM_VEC *params = staticData.GetParameter().GetParam("print-id");
if (options().output.PrintID) {
out << translationId << " ";
}
// VN : I put back the code for OutputPassthroughInformation
if (options().output.PrintPassThrough) {
OutputPassthroughInformation(out, bestHypo);
out << translationId << " ";
}
// VN : I put back the code for OutputPassthroughInformation
if (options().output.PrintPassThrough) {
OutputPassthroughInformation(out, bestHypo);
}
// end of add back
@ -1589,8 +1589,8 @@ void Manager::OutputBest(OutputCollector *collector) const
} else {
//Lattice MBR decoding
vector<Word> mbrBestHypo = doLatticeMBR(*this,nBestList);
OutputBestHypo(mbrBestHypo, translationId,
options().output.ReportSegmentation,
OutputBestHypo(mbrBestHypo, translationId,
options().output.ReportSegmentation,
options().output.ReportAllFactors, out);
IFVERBOSE(2) {
PrintUserTime("finished Lattice MBR decoding");
@ -1614,7 +1614,7 @@ void Manager::OutputBest(OutputCollector *collector) const
else {
const TrellisPath &mbrBestHypo = doMBR(nBestList);
OutputBestHypo(mbrBestHypo, translationId,
options().output.ReportSegmentation,
options().output.ReportSegmentation,
options().output.ReportAllFactors, out);
OutputAlignment(m_alignmentOut, mbrBestHypo);
IFVERBOSE(2) {
@ -1650,8 +1650,8 @@ void Manager::OutputNBest(OutputCollector *collector) const
ostringstream out;
CalcNBest(options().nbest.nbest_size, nBestList,
options().nbest.only_distinct);
OutputNBest(out, nBestList,
staticData.GetOutputFactorOrder(),
OutputNBest(out, nBestList,
staticData.GetOutputFactorOrder(),
m_source.GetTranslationId(),
options().output.ReportSegmentation);
collector->Write(m_source.GetTranslationId(), out.str());
@ -1659,12 +1659,12 @@ void Manager::OutputNBest(OutputCollector *collector) const
}
void
void
Manager::
OutputNBest(std::ostream& out,
const Moses::TrellisPathList &nBestList,
const std::vector<Moses::FactorType>& outputFactorOrder,
long translationId, char reportSegmentation) const
const Moses::TrellisPathList &nBestList,
const std::vector<Moses::FactorType>& outputFactorOrder,
long translationId, char reportSegmentation) const
{
const StaticData &staticData = StaticData::Instance();
NBestOptions const& nbo = options().nbest;
@ -1681,8 +1681,8 @@ OutputNBest(std::ostream& out,
out << translationId << " ||| ";
for (int currEdge = (int)edges.size() - 1 ; currEdge >= 0 ; currEdge--) {
const Hypothesis &edge = *edges[currEdge];
OutputSurface(out, edge, outputFactorOrder, reportSegmentation,
reportAllFactors);
OutputSurface(out, edge, outputFactorOrder, reportSegmentation,
reportAllFactors);
}
out << " |||";
@ -1741,11 +1741,11 @@ OutputNBest(std::ostream& out,
/***
* print surface factor only for the given phrase
*/
void
void
Manager::
OutputSurface(std::ostream &out, const Hypothesis &edge,
const std::vector<FactorType> &outputFactorOrder,
char reportSegmentation, bool reportAllFactors) const
OutputSurface(std::ostream &out, const Hypothesis &edge,
const std::vector<FactorType> &outputFactorOrder,
char reportSegmentation, bool reportAllFactors) const
{
UTIL_THROW_IF2(outputFactorOrder.size() == 0,
"Must specific at least 1 output factor");
@ -1820,10 +1820,10 @@ OutputSurface(std::ostream &out, const Hypothesis &edge,
}
}
void
void
Manager::
OutputAlignment(ostream &out, const AlignmentInfo &ai,
size_t sourceOffset, size_t targetOffset) const
OutputAlignment(ostream &out, const AlignmentInfo &ai,
size_t sourceOffset, size_t targetOffset) const
{
typedef std::vector< const std::pair<size_t,size_t>* > AlignVec;
AlignVec alignments = ai.GetSortedAlignments(options().output.WA_SortOrder);
@ -1831,13 +1831,13 @@ OutputAlignment(ostream &out, const AlignmentInfo &ai,
AlignVec::const_iterator it;
for (it = alignments.begin(); it != alignments.end(); ++it) {
const std::pair<size_t,size_t> &alignment = **it;
out << alignment.first + sourceOffset << "-"
<< alignment.second + targetOffset << " ";
out << alignment.first + sourceOffset << "-"
<< alignment.second + targetOffset << " ";
}
}
void
void
Manager::
OutputInput(std::ostream& os, const Hypothesis* hypo) const
{
@ -1883,9 +1883,9 @@ void Manager::OutputLatticeSamples(OutputCollector *collector) const
TrellisPathList latticeSamples;
ostringstream out;
CalcLatticeSamples(staticData.GetLatticeSamplesSize(), latticeSamples);
OutputNBest(out,latticeSamples,
staticData.GetOutputFactorOrder(),
m_source.GetTranslationId(),
OutputNBest(out,latticeSamples,
staticData.GetOutputFactorOrder(),
m_source.GetTranslationId(),
options().output.ReportSegmentation);
collector->Write(m_source.GetTranslationId(), out.str());
}
@ -2075,11 +2075,11 @@ void Manager::OutputBestHypo(const std::vector<Word>& mbrBestHypo, long /*trans
out << endl;
}
void
void
Manager::
OutputBestHypo(const Moses::TrellisPath &path, long /*translationId*/,
char reportSegmentation, bool reportAllFactors,
std::ostream &out) const
OutputBestHypo(const Moses::TrellisPath &path, long /*translationId*/,
char reportSegmentation, bool reportAllFactors,
std::ostream &out) const
{
const std::vector<const Hypothesis *> &edges = path.GetEdges();

View File

@ -131,7 +131,7 @@ protected:
// nbest
mutable std::ostringstream m_latticeNBestOut;
mutable std::ostringstream m_alignmentOut;
public:
public:
void OutputNBest(std::ostream& out
, const Moses::TrellisPathList &nBestList
, const std::vector<Moses::FactorType>& outputFactorOrder

View File

@ -45,13 +45,13 @@ MockHypothesisGuard
m_manager.reset(new Manager(m_ttask));
//Initial empty hypothesis
Bitmaps bitmaps(m_sentence.get()->GetSize(),
m_sentence.get()->m_sourceCompleted);
Bitmaps bitmaps(m_sentence.get()->GetSize(),
m_sentence.get()->m_sourceCompleted);
m_manager->ResetSentenceStats(*m_sentence);
const Bitmap &initBitmap = bitmaps.GetInitialBitmap();
m_hypothesis = new Hypothesis(*m_manager, *m_sentence, m_initialTransOpt,
initBitmap);
m_hypothesis = new Hypothesis(*m_manager, *m_sentence, m_initialTransOpt,
initBitmap);
//create the chain
vector<Alignment>::const_iterator ai = alignments.begin();
@ -59,8 +59,8 @@ MockHypothesisGuard
for (; ti != targetSegments.end() && ai != alignments.end(); ++ti,++ai) {
Hypothesis* prevHypo = m_hypothesis;
Range range(ai->first,ai->second);
const Bitmap &newBitmap = bitmaps.GetBitmap(prevHypo->GetWordsBitmap(),
range);
const Bitmap &newBitmap = bitmaps.GetBitmap(prevHypo->GetWordsBitmap(),
range);
m_targetPhrases.push_back(TargetPhrase(NULL));
// m_targetPhrases.back().CreateFromString(Input, factors, *ti, "|", NULL);

View File

@ -1620,7 +1620,7 @@ SetParameter<bool>(bool &parameter, std::string const& parameterName,
}
}
void
void
Parameter::
SetParameter(bool& var, std::string const& name)
{

View File

@ -155,14 +155,13 @@ public:
// issues a warning if format is wrong
const PARAM_VEC *params = GetParam(name);
val = (params && params->size());
if (val && params->size() != 1)
{
TRACE_ERR("ERROR: wrong format for switch -" << name);
return false;
}
if (val && params->size() != 1) {
TRACE_ERR("ERROR: wrong format for switch -" << name);
return false;
}
return true;
}
};
template<>

View File

@ -280,7 +280,7 @@ void ScoreComponentCollection::ZeroDenseFeatures(const FeatureFunction* sp)
}
//! get subset of scores that belong to a certain sparse ScoreProducer
FVector
FVector
ScoreComponentCollection::
GetVectorForProducer(const FeatureFunction* sp) const
{
@ -307,21 +307,21 @@ void ScoreComponentCollection::PlusEquals(const FeatureFunction* sp, const Score
}
}
void
void
ScoreComponentCollection::
OutputAllFeatureScores(std::ostream &out, bool with_labels) const
{
std::string lastName = "";
const vector<const StatefulFeatureFunction*>& sff
= StatefulFeatureFunction::GetStatefulFeatureFunctions();
const vector<const StatefulFeatureFunction*>& sff
= StatefulFeatureFunction::GetStatefulFeatureFunctions();
for( size_t i=0; i<sff.size(); i++ ) {
const StatefulFeatureFunction *ff = sff[i];
if (ff->IsTuneable()) {
OutputFeatureScores(out, ff, lastName, with_labels);
}
}
const vector<const StatelessFeatureFunction*>& slf
= StatelessFeatureFunction::GetStatelessFeatureFunctions();
const vector<const StatelessFeatureFunction*>& slf
= StatelessFeatureFunction::GetStatelessFeatureFunctions();
for( size_t i=0; i<slf.size(); i++ ) {
const StatelessFeatureFunction *ff = slf[i];
if (ff->IsTuneable()) {
@ -330,10 +330,10 @@ OutputAllFeatureScores(std::ostream &out, bool with_labels) const
}
}
void
void
ScoreComponentCollection::
OutputFeatureScores(std::ostream& out, FeatureFunction const* ff,
std::string &lastName, bool with_labels) const
std::string &lastName, bool with_labels) const
{
// const StaticData &staticData = StaticData::Instance();
// bool labeledOutput = staticData.options().nbest.include_feature_labels;

View File

@ -88,7 +88,7 @@ class ScoreComponentCollection
{
friend std::ostream& operator<<(std::ostream& os, const ScoreComponentCollection& rhs);
friend void swap(ScoreComponentCollection &first, ScoreComponentCollection &second);
private:
FVector m_scores;
@ -433,7 +433,7 @@ public:
void OutputAllFeatureScores(std::ostream &out, bool with_labels) const;
void OutputFeatureScores(std::ostream& out, Moses::FeatureFunction const* ff,
std::string &lastName, bool with_labels) const;
std::string &lastName, bool with_labels) const;
#ifdef MPI_ENABLE
public:

View File

@ -183,7 +183,7 @@ init(string line, std::vector<FactorType> const& factorOrder,
aux_interpret_dlt(line); // some poorly documented cache-based stuff
// if sentences is specified as "<passthrough tag1=""/>"
if (SD.options().output.PrintPassThrough ||
if (SD.options().output.PrintPassThrough ||
SD.options().nbest.include_passthrough) {
string pthru = PassthroughSGML(line,"passthrough");
this->SetPassthroughInformation(pthru);
@ -232,7 +232,7 @@ init(string line, std::vector<FactorType> const& factorOrder,
int
Sentence::
Read(std::istream& in,
Read(std::istream& in,
const std::vector<FactorType>& factorOrder,
AllOptions const& opts)
{
@ -370,9 +370,9 @@ CreateFromString(vector<FactorType> const& FOrder, string const& phraseString)
}
Sentence::
Sentence(size_t const transId,
string const& stext,
AllOptions const& opts,
Sentence(size_t const transId,
string const& stext,
AllOptions const& opts,
vector<FactorType> const* IFO)
: InputType(transId)
{

View File

@ -65,8 +65,8 @@ protected:
public:
Sentence();
Sentence(size_t const transId, std::string const& stext,
AllOptions const& opts,
std::vector<FactorType> const* IFO = NULL);
AllOptions const& opts,
std::vector<FactorType> const* IFO = NULL);
// Sentence(size_t const transId, std::string const& stext);
~Sentence();
@ -97,7 +97,7 @@ public:
void GetXmlTranslationOptions(std::vector<TranslationOption*> &list, size_t startPos, size_t endPos) const;
std::vector<ChartTranslationOptions*> GetXmlChartTranslationOptions() const;
virtual int
virtual int
Read(std::istream& in, const std::vector<FactorType>& factorOrder,
AllOptions const& opts);

View File

@ -63,7 +63,7 @@ StaticData StaticData::s_instance;
StaticData::StaticData()
: m_sourceStartPosMattersForRecombination(false)
, m_requireSortingAfterSourceContext(false)
// , m_inputType(SentenceInput)
// , m_inputType(SentenceInput)
, m_lmEnableOOVFeature(false)
, m_isAlwaysCreateDirectTranslationOption(false)
, m_currentWeightSetting("default")
@ -169,21 +169,21 @@ StaticData
m_parameter->SetParameter(m_verboseLevel, "verbose", (size_t) 1);
m_parameter->SetParameter(m_includeLHSInSearchGraph,
m_parameter->SetParameter(m_includeLHSInSearchGraph,
"include-lhs-in-search-graph", false );
m_parameter->SetParameter<string>(m_outputUnknownsFile,
m_parameter->SetParameter<string>(m_outputUnknownsFile,
"output-unknowns", "");
//Print Translation Options
m_parameter->SetParameter(m_printTranslationOptions,
m_parameter->SetParameter(m_printTranslationOptions,
"print-translation-option", false );
//Print All Derivations
m_parameter->SetParameter(m_printAllDerivations ,
m_parameter->SetParameter(m_printAllDerivations ,
"print-all-derivations", false );
m_parameter->SetParameter<long>(m_startTranslationId,
m_parameter->SetParameter<long>(m_startTranslationId,
"start-translation-id", 0);
//lattice samples
@ -340,9 +340,9 @@ bool StaticData::LoadData(Parameter *parameter)
ini_zombie_options(); // probably dead, or maybe not
m_parameter->SetParameter(m_placeHolderFactor, "placeholder-factor",
m_parameter->SetParameter(m_placeHolderFactor, "placeholder-factor",
NOT_FOUND);
// FEATURE FUNCTION INITIALIZATION HAPPENS HERE ===============================
initialize_features();
@ -393,7 +393,7 @@ void StaticData::SetWeight(const FeatureFunction* sp, float weight)
m_allWeights.Assign(sp,weight);
}
void StaticData::SetWeights(const FeatureFunction* sp,
void StaticData::SetWeights(const FeatureFunction* sp,
const std::vector<float>& weights)
{
m_allWeights.Resize();
@ -444,9 +444,9 @@ void StaticData::LoadChartDecodingParameters()
LoadNonTerminals();
// source label overlap
m_parameter->SetParameter(m_sourceLabelOverlap, "source-label-overlap",
m_parameter->SetParameter(m_sourceLabelOverlap, "source-label-overlap",
SourceLabelOverlapAdd);
m_parameter->SetParameter(m_ruleLimit, "rule-limit",
m_parameter->SetParameter(m_ruleLimit, "rule-limit",
DEFAULT_MAX_TRANS_OPT_SIZE);
}
@ -485,16 +485,16 @@ void StaticData::LoadDecodeGraphs()
}
}
void
void
StaticData::
LoadDecodeGraphsOld(const vector<string> &mappingVector,
LoadDecodeGraphsOld(const vector<string> &mappingVector,
const vector<size_t> &maxChartSpans)
{
const vector<PhraseDictionary*>& pts = PhraseDictionary::GetColl();
const vector<GenerationDictionary*>& gens = GenerationDictionary::GetColl();
const std::vector<FeatureFunction*> *featuresRemaining
= &FeatureFunction::GetFeatureFunctions();
const std::vector<FeatureFunction*> *featuresRemaining
= &FeatureFunction::GetFeatureFunctions();
DecodeStep *prev = 0;
size_t prevDecodeGraphInd = 0;
@ -513,7 +513,7 @@ LoadDecodeGraphsOld(const vector<string> &mappingVector,
// For specifying multiple translation model
decodeGraphInd = Scan<size_t>(token[0]);
//the vectorList index can only increment by one
UTIL_THROW_IF2(decodeGraphInd != prevDecodeGraphInd
UTIL_THROW_IF2(decodeGraphInd != prevDecodeGraphInd
&& decodeGraphInd != prevDecodeGraphInd + 1,
"Malformed mapping");
if (decodeGraphInd > prevDecodeGraphInd) {
@ -601,7 +601,7 @@ void StaticData::LoadDecodeGraphsNew(const std::vector<std::string> &mappingVect
decodeGraphInd = Scan<size_t>(token[0]);
//the vectorList index can only increment by one
UTIL_THROW_IF2(decodeGraphInd != prevDecodeGraphInd
UTIL_THROW_IF2(decodeGraphInd != prevDecodeGraphInd
&& decodeGraphInd != prevDecodeGraphInd + 1,
"Malformed mapping");
if (decodeGraphInd > prevDecodeGraphInd) {
@ -702,14 +702,14 @@ StaticData::
InitializeForInput(ttasksptr const& ttask) const
{
const std::vector<FeatureFunction*> &producers
= FeatureFunction::GetFeatureFunctions();
= FeatureFunction::GetFeatureFunctions();
for(size_t i=0; i<producers.size(); ++i) {
FeatureFunction &ff = *producers[i];
if (! IsFeatureFunctionIgnored(ff)) {
Timer iTime;
iTime.start();
ff.InitializeForInput(ttask);
VERBOSE(3,"InitializeForInput( " << ff.GetScoreProducerDescription()
VERBOSE(3,"InitializeForInput( " << ff.GetScoreProducerDescription()
<< " )" << "= " << iTime << endl);
}
}
@ -720,7 +720,7 @@ StaticData::
CleanUpAfterSentenceProcessing(ttasksptr const& ttask) const
{
const std::vector<FeatureFunction*> &producers
= FeatureFunction::GetFeatureFunctions();
= FeatureFunction::GetFeatureFunctions();
for(size_t i=0; i<producers.size(); ++i) {
FeatureFunction &ff = *producers[i];
if (! IsFeatureFunctionIgnored(ff)) {

View File

@ -470,15 +470,15 @@ public:
// m_outputSearchGraph = outputSearchGraph;
// }
// bool GetOutputSearchGraphExtended() const {
// return m_outputSearchGraphExtended;
// }
// GetOutputSearchGraphSLF() const {
// return m_outputSearchGraphSLF;
// }
// bool GetOutputSearchGraphHypergraph() const {
// return m_outputSearchGraphHypergraph;
// }
// bool GetOutputSearchGraphExtended() const {
// return m_outputSearchGraphExtended;
// }
// GetOutputSearchGraphSLF() const {
// return m_outputSearchGraphSLF;
// }
// bool GetOutputSearchGraphHypergraph() const {
// return m_outputSearchGraphHypergraph;
// }
// #ifdef HAVE_PROTOBUF
// bool GetOutputSearchGraphPB() const {

View File

@ -45,9 +45,9 @@ void TabbedSentence::CreateFromString(const std::vector<FactorType> &factorOrder
}
}
int
int
TabbedSentence::
Read(std::istream& in,
Read(std::istream& in,
std::vector<FactorType> const& factorOrder,
AllOptions const& opts)
{

View File

@ -67,7 +67,7 @@ public:
virtual void CreateFromString(const std::vector<FactorType> &factorOrder
, const std::string &tabbedString);
virtual int
virtual int
Read(std::istream& in,const std::vector<FactorType>& factorOrder,
AllOptions const& opts);

View File

@ -234,10 +234,10 @@ CreateTranslationOptionsForRangeLEGACY(const DecodeGraph &decodeGraph, size_t st
list <const DecodeStep* >::const_iterator iterStep = decodeGraph.begin();
const DecodeStep &decodeStep = **iterStep;
DecodeStepTranslation const& dstep
= static_cast<const DecodeStepTranslation&>(decodeStep);
dstep.ProcessInitialTransLEGACY(m_source, *oldPtoc, startPos, endPos,
adhereTableLimit, inputPathList);
DecodeStepTranslation const& dstep
= static_cast<const DecodeStepTranslation&>(decodeStep);
dstep.ProcessInitialTransLEGACY(m_source, *oldPtoc, startPos, endPos,
adhereTableLimit, inputPathList);
// do rest of decode steps
int indexStep = 0;

View File

@ -186,8 +186,8 @@ void TranslationTask::Run()
// report thread number
#if defined(WITH_THREADS) && defined(BOOST_HAS_PTHREADS)
VERBOSE(2, "Translating line " << translationId << " in thread id "
<< pthread_self() << endl);
VERBOSE(2, "Translating line " << translationId << " in thread id "
<< pthread_self() << endl);
#endif

View File

@ -237,7 +237,7 @@ bool TreeInput::ProcessAndStripXMLTags(string &line, std::vector<XMLParseOutput>
}
//! populate this InputType with data from in stream
int
int
TreeInput::
Read(std::istream& in, const std::vector<FactorType>& factorOrder,
AllOptions const& opts)
@ -258,7 +258,7 @@ Read(std::istream& in, const std::vector<FactorType>& factorOrder,
strme << line << endl;
Sentence::Read(strme, factorOrder, opts);
// size input chart
size_t sourceSize = GetSize();
m_sourceChart.resize(sourceSize);

View File

@ -53,8 +53,8 @@ public:
}
//! populate this InputType with data from in stream
virtual int
Read(std::istream& in,
virtual int
Read(std::istream& in,
const std::vector<FactorType>& factorOrder,
AllOptions const& opts);

View File

@ -147,9 +147,9 @@ InitializeFromPCNDataType
return !cn.empty();
}
int
int
WordLattice::
Read(std::istream& in,
Read(std::istream& in,
std::vector<FactorType> const& factorOrder,
AllOptions const& opts)
{

View File

@ -43,10 +43,10 @@ public:
int InitializeFromPCNDataType(const PCN::CN& cn, const std::vector<FactorType>& factorOrder, const std::string& debug_line = "");
/** Read from PLF format (1 lattice per line)
*/
int Read(std::istream& in,
std::vector<FactorType> const& factorOrder,
AllOptions const& opts);
int Read(std::istream& in,
std::vector<FactorType> const& factorOrder,
AllOptions const& opts);
/** Convert internal representation into an edge matrix
* @note edges[1][2] means there is an edge from 1 to 2
*/