diff options
-rw-r--r-- | moses-cmd/IOWrapper.cpp | 7 | ||||
-rw-r--r-- | moses/ChartParser.cpp | 46 | ||||
-rw-r--r-- | moses/Sentence.cpp | 54 | ||||
-rw-r--r-- | moses/Sentence.h | 4 | ||||
-rw-r--r-- | moses/StaticData.cpp | 8 | ||||
-rw-r--r-- | moses/TranslationModel/BilingualDynSuffixArray.cpp | 14 | ||||
-rw-r--r-- | phrase-extract/extract-main.cpp | 30 |
7 files changed, 81 insertions, 82 deletions
diff --git a/moses-cmd/IOWrapper.cpp b/moses-cmd/IOWrapper.cpp index 3d9e5c034..177a13403 100644 --- a/moses-cmd/IOWrapper.cpp +++ b/moses-cmd/IOWrapper.cpp @@ -206,10 +206,9 @@ void OutputSurface(std::ostream &out, const Hypothesis &edge, const std::vector< const Factor *factor; if (placeholderFactor == NOT_FOUND) { - factor = phrase.GetFactor(pos, outputFactorOrder[0]); - } - else { - factor = phrase.GetFactor(pos, placeholderFactor); + factor = phrase.GetFactor(pos, outputFactorOrder[0]); + } else { + factor = phrase.GetFactor(pos, placeholderFactor); } out << *factor; CHECK(factor); diff --git a/moses/ChartParser.cpp b/moses/ChartParser.cpp index a91fe2009..fde1757e1 100644 --- a/moses/ChartParser.cpp +++ b/moses/ChartParser.cpp @@ -181,29 +181,29 @@ void ChartParser::Create(const WordsRange &wordsRange, ChartParserCallback &to) void ChartParser::CreateInputPaths(const InputType &input) { - size_t size = input.GetSize(); - m_targetPhrasesfromPt.resize(size); - for (size_t phaseSize = 1; phaseSize <= size; ++phaseSize) { - for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) { - size_t endPos = startPos + phaseSize -1; - vector<InputPath*> &vec = m_targetPhrasesfromPt[startPos]; - - Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos))); - WordsRange range(startPos, endPos); - - InputPath *node; - if (range.GetNumWordsCovered() == 1) { - node = new InputPath(subphrase, range, NULL, NULL); - vec.push_back(node); - } else { - const InputPath &prevNode = GetInputPath(startPos, endPos - 1); - node = new InputPath(subphrase, range, &prevNode, NULL); - vec.push_back(node); - } - - m_phraseDictionaryQueue.push_back(node); - } - } + size_t size = input.GetSize(); + m_targetPhrasesfromPt.resize(size); + for (size_t phaseSize = 1; phaseSize <= size; ++phaseSize) { + for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) { + size_t endPos = startPos + phaseSize -1; + vector<InputPath*> &vec = m_targetPhrasesfromPt[startPos]; + + Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos))); + WordsRange range(startPos, endPos); + + InputPath *node; + if (range.GetNumWordsCovered() == 1) { + node = new InputPath(subphrase, range, NULL, NULL); + vec.push_back(node); + } else { + const InputPath &prevNode = GetInputPath(startPos, endPos - 1); + node = new InputPath(subphrase, range, &prevNode, NULL); + vec.push_back(node); + } + + m_phraseDictionaryQueue.push_back(node); + } + } } InputPath &ChartParser::GetInputPath(size_t startPos, size_t endPos) diff --git a/moses/Sentence.cpp b/moses/Sentence.cpp index 0368c430a..ca8838b48 100644 --- a/moses/Sentence.cpp +++ b/moses/Sentence.cpp @@ -46,7 +46,7 @@ Sentence::Sentence() Sentence::~Sentence() { - RemoveAllInColl(m_xmlOptions); + RemoveAllInColl(m_xmlOptions); } int Sentence::Read(std::istream& in,const std::vector<FactorType>& factorOrder) @@ -129,14 +129,14 @@ int Sentence::Read(std::istream& in,const std::vector<FactorType>& factorOrder) std::vector< std::pair<size_t, std::string> > placeholders; if (staticData.GetXmlInputType() != XmlPassThrough) { - int offset = 0; + int offset = 0; if (staticData.IsChart()) { offset = 1; - } + } if (!ProcessAndStripXMLTags(line, m_xmlOptions, m_reorderingConstraint, xmlWalls, placeholders, offset, - staticData.GetXmlBrackets().first, + staticData.GetXmlBrackets().first, staticData.GetXmlBrackets().second)) { const string msg("Unable to parse XML in line: " + line); TRACE_ERR(msg << endl); @@ -256,11 +256,11 @@ void Sentence::GetXmlTranslationOptions(std::vector <TranslationOption*> &list, for (std::vector<XmlOption*>::const_iterator iterXMLOpts = m_xmlOptions.begin(); iterXMLOpts != m_xmlOptions.end(); ++iterXMLOpts) { - const XmlOption &xmlOption = **iterXMLOpts; + const XmlOption &xmlOption = **iterXMLOpts; const WordsRange &range = xmlOption.range; if (startPos == range.GetStartPos() - && endPos == range.GetEndPos()) { + && endPos == range.GetEndPos()) { const TargetPhrase &targetPhrase = xmlOption.targetPhrase; TranslationOption *transOpt = new TranslationOption(range, targetPhrase); @@ -279,33 +279,33 @@ std::vector <ChartTranslationOptions*> Sentence::GetXmlChartTranslationOptions() //only fill the vector if we are parsing XML if (staticData.GetXmlInputType() != XmlPassThrough ) { - //TODO: needed to handle exclusive - //for (size_t i=0; i<GetSize(); i++) { - // m_xmlCoverageMap.push_back(false); - //} + //TODO: needed to handle exclusive + //for (size_t i=0; i<GetSize(); i++) { + // m_xmlCoverageMap.push_back(false); + //} - //iterXMLOpts will be empty for XmlIgnore - //look at each column - for(std::vector<XmlOption*>::const_iterator iterXmlOpts = m_xmlOptions.begin(); - iterXmlOpts != m_xmlOptions.end(); iterXmlOpts++) { + //iterXMLOpts will be empty for XmlIgnore + //look at each column + for(std::vector<XmlOption*>::const_iterator iterXmlOpts = m_xmlOptions.begin(); + iterXmlOpts != m_xmlOptions.end(); iterXmlOpts++) { - const XmlOption &xmlOption = **iterXmlOpts; - TargetPhrase *targetPhrase = new TargetPhrase(xmlOption.targetPhrase); + const XmlOption &xmlOption = **iterXmlOpts; + TargetPhrase *targetPhrase = new TargetPhrase(xmlOption.targetPhrase); - WordsRange *range = new WordsRange(xmlOption.range); - const StackVec emptyStackVec; // hmmm... maybe dangerous, but it is never consulted + WordsRange *range = new WordsRange(xmlOption.range); + const StackVec emptyStackVec; // hmmm... maybe dangerous, but it is never consulted - TargetPhraseCollection *tpc = new TargetPhraseCollection; - tpc->Add(targetPhrase); + TargetPhraseCollection *tpc = new TargetPhraseCollection; + tpc->Add(targetPhrase); - ChartTranslationOptions *transOpt = new ChartTranslationOptions(*tpc, emptyStackVec, *range, 0.0f); - ret.push_back(transOpt); + ChartTranslationOptions *transOpt = new ChartTranslationOptions(*tpc, emptyStackVec, *range, 0.0f); + ret.push_back(transOpt); - //TODO: needed to handle exclusive - //for(size_t j=transOpt->GetSourceWordsRange().GetStartPos(); j<=transOpt->GetSourceWordsRange().GetEndPos(); j++) { - // m_xmlCoverageMap[j]=true; - //} - } + //TODO: needed to handle exclusive + //for(size_t j=transOpt->GetSourceWordsRange().GetStartPos(); j<=transOpt->GetSourceWordsRange().GetEndPos(); j++) { + // m_xmlCoverageMap[j]=true; + //} + } } return ret; diff --git a/moses/Sentence.h b/moses/Sentence.h index f3ce0d68c..97db5aff8 100644 --- a/moses/Sentence.h +++ b/moses/Sentence.h @@ -53,8 +53,8 @@ protected: * Utility method that takes in a string representing an XML tag and the name of the attribute, * and returns the value of that tag if present, empty string otherwise */ - std::vector<XmlOption*> m_xmlOptions; - std::vector <bool> m_xmlCoverageMap; + std::vector<XmlOption*> m_xmlOptions; + std::vector <bool> m_xmlCoverageMap; NonTerminalSet m_defaultLabelSet; diff --git a/moses/StaticData.cpp b/moses/StaticData.cpp index 56ac0691f..dfdfc5719 100644 --- a/moses/StaticData.cpp +++ b/moses/StaticData.cpp @@ -506,11 +506,11 @@ bool StaticData::LoadData(Parameter *parameter) } if (m_parameter->GetParam("placeholder-factor").size() > 0) { - CHECK(m_parameter->GetParam("placeholder-factor").size() == 2); + CHECK(m_parameter->GetParam("placeholder-factor").size() == 2); m_placeHolderFactor = std::pair<FactorType, FactorType>( - Scan<FactorType>(m_parameter->GetParam("placeholder-factor")[0]), - Scan<FactorType>(m_parameter->GetParam("placeholder-factor")[1]) - ); + Scan<FactorType>(m_parameter->GetParam("placeholder-factor")[0]), + Scan<FactorType>(m_parameter->GetParam("placeholder-factor")[1]) + ); } else { m_placeHolderFactor = std::pair<FactorType, FactorType>(NOT_FOUND, NOT_FOUND); } diff --git a/moses/TranslationModel/BilingualDynSuffixArray.cpp b/moses/TranslationModel/BilingualDynSuffixArray.cpp index 070000314..a936d95f2 100644 --- a/moses/TranslationModel/BilingualDynSuffixArray.cpp +++ b/moses/TranslationModel/BilingualDynSuffixArray.cpp @@ -301,13 +301,13 @@ GetLexicalWeight(const PhrasePair& pp) const ++sc[sx]; ++tc[tx]; #if 0 - cout << m_srcVocab->GetWord(sw[s]) << " -> " - << m_trgVocab->GetWord(tw[t]) << " " - << m_wrd_cooc.pfwd(sw[s],tw[t]) << " " - << m_wrd_cooc.pbwd(sw[s],tw[t]) << " " - << sp[sx] << " (" << sc[sx] << ") " - << tp[tx] << " (" << tc[tx] << ") " - << endl; + cout << m_srcVocab->GetWord(sw[s]) << " -> " + << m_trgVocab->GetWord(tw[t]) << " " + << m_wrd_cooc.pfwd(sw[s],tw[t]) << " " + << m_wrd_cooc.pbwd(sw[s],tw[t]) << " " + << sp[sx] << " (" << sc[sx] << ") " + << tp[tx] << " (" << tc[tx] << ") " + << endl; #endif } pair<float,float> ret(1,1); diff --git a/phrase-extract/extract-main.cpp b/phrase-extract/extract-main.cpp index 53e4b804d..4804f83b8 100644 --- a/phrase-extract/extract-main.cpp +++ b/phrase-extract/extract-main.cpp @@ -78,7 +78,7 @@ bool isAligned (SentenceAlignment &, int, int); int sentenceOffset = 0; std::vector<std::string> Tokenize(const std::string& str, - const std::string& delimiters = " \t"); + const std::string& delimiters = " \t"); } @@ -687,7 +687,7 @@ void ExtractTask::addPhrase( SentenceAlignment &sentence, int startE, int endE, } if (!checkPlaceholders(sentence, startE, endE, startF, endF)) { - return; + return; } for(int fi=startF; fi<=endF; fi++) { @@ -816,19 +816,19 @@ bool ExtractTask::checkPlaceholders (const SentenceAlignment &sentence, int star for (size_t pos = startF; pos <= endF; ++pos) { const string &word = sentence.source[pos]; if (isPlaceholder(word)) { - if (sentence.alignedCountS[pos] != 1) { - return false; - } + if (sentence.alignedCountS[pos] != 1) { + return false; + } } } for (size_t pos = startE; pos <= endE; ++pos) { - const string &word = sentence.target[pos]; - if (isPlaceholder(word)) { - if (sentence.alignedToT[pos].size() != 1) { - return false; - } + const string &word = sentence.target[pos]; + if (isPlaceholder(word)) { + if (sentence.alignedToT[pos].size() != 1) { + return false; } + } } return true; @@ -837,10 +837,10 @@ bool ExtractTask::checkPlaceholders (const SentenceAlignment &sentence, int star bool ExtractTask::isPlaceholder(const string &word) { for (size_t i = 0; i < m_options.placeholders.size(); ++i) { - const string &placeholder = m_options.placeholders[i]; - if (word == placeholder) { - return true; - } + const string &placeholder = m_options.placeholders[i]; + if (word == placeholder) { + return true; + } } return false; } @@ -848,7 +848,7 @@ bool ExtractTask::isPlaceholder(const string &word) The separator can only be 1 character long. The default delimiters are space or tab */ std::vector<std::string> Tokenize(const std::string& str, - const std::string& delimiters) + const std::string& delimiters) { std::vector<std::string> tokens; // Skip delimiters at beginning. |