From 97b2aa5663e97079145fb494bf97e1b2997b4161 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Sun, 25 Oct 2015 13:37:59 +0000 Subject: [PATCH] WordsRange -> Range --- contrib/other-builds/moses/.project | 12 +++++----- contrib/other-builds/moses/moses.project | 4 ++-- moses/BaseManager.h | 2 +- moses/Bitmap.h | 6 ++--- moses/BitmapContainer.cpp | 8 +++---- moses/Bitmaps.cpp | 4 ++-- moses/Bitmaps.h | 6 ++--- moses/ChartCell.cpp | 2 +- moses/ChartCell.h | 6 ++--- moses/ChartCellCollection.cpp | 2 +- moses/ChartCellCollection.h | 12 +++++----- moses/ChartCellLabel.h | 8 +++---- moses/ChartCellLabelSet.h | 4 ++-- moses/ChartHypothesis.h | 6 ++--- moses/ChartManager.cpp | 22 +++++++++---------- moses/ChartManager.h | 2 +- moses/ChartParser.cpp | 22 +++++++++---------- moses/ChartParser.h | 8 +++---- moses/ChartParserCallback.h | 6 ++--- moses/ChartRuleLookupManager.h | 4 ++-- moses/ChartTranslationOptionList.cpp | 6 ++--- moses/ChartTranslationOptionList.h | 6 ++--- moses/ChartTranslationOptions.cpp | 4 ++-- moses/ChartTranslationOptions.h | 10 ++++----- moses/ConfusionNet.cpp | 2 +- moses/ConfusionNet.h | 2 +- moses/DecodeStepGeneration.cpp | 2 +- moses/DecodeStepTranslation.cpp | 20 ++++++++--------- moses/FF/BleuScoreFeature.cpp | 14 ++++++------ moses/FF/DistortionScoreProducer.cpp | 10 ++++----- moses/FF/DistortionScoreProducer.h | 4 ++-- moses/FF/DynamicCacheBasedLanguageModel.h | 2 +- moses/FF/FeatureFunction.h | 2 +- moses/FF/GlobalLexicalModel.h | 2 +- moses/FF/GlobalLexicalModelUnlimited.h | 2 +- .../FF/LexicalReordering/LexicalReordering.h | 2 +- .../LexicalReorderingState.cpp | 20 ++++++++--------- .../LexicalReorderingState.h | 20 ++++++++--------- .../LexicalReorderingTable.cpp | 4 ++-- .../FF/LexicalReordering/ReorderingStack.cpp | 16 +++++++------- moses/FF/LexicalReordering/ReorderingStack.h | 8 +++---- .../FF/LexicalReordering/SparseReordering.cpp | 4 ++-- moses/FF/MaxSpanFreeNonTermSource.cpp | 2 +- moses/FF/NieceTerminal.cpp | 4 ++-- moses/FF/NieceTerminal.h | 4 ++-- moses/FF/OSM-Feature/OpSequenceModel.cpp | 2 +- moses/FF/PhraseOrientationFeature.cpp | 4 ++-- .../SoftSourceSyntacticConstraintsFeature.cpp | 10 ++++----- moses/FF/SourceGHKMTreeInputMatchFeature.cpp | 6 ++--- moses/FF/SpanLength.cpp | 4 ++-- moses/FF/SparseHieroReorderingFeature.cpp | 12 +++++----- moses/FF/SparseHieroReorderingFeature.h | 2 +- moses/FF/TargetNgramFeature.h | 2 +- moses/FF/UnknownWordPenaltyProducer.h | 2 +- moses/ForestInput.cpp | 12 +++++----- moses/Hypothesis.cpp | 8 +++---- moses/Hypothesis.h | 10 ++++----- moses/HypothesisStackCubePruning.cpp | 2 +- moses/HypothesisStackCubePruning.h | 2 +- moses/IOWrapper.cpp | 2 +- moses/Incremental.cpp | 18 +++++++-------- moses/InputPath.cpp | 2 +- moses/InputPath.h | 8 +++---- moses/InputType.cpp | 2 +- moses/InputType.h | 10 ++++----- moses/LM/BilingualLM.cpp | 4 ++-- moses/LM/BilingualLM.h | 2 +- moses/Manager.cpp | 10 ++++----- moses/MockHypothesis.cpp | 6 ++--- moses/Phrase.cpp | 12 +++++----- moses/Phrase.h | 6 ++--- moses/{WordsRange.cpp => Range.cpp} | 6 ++--- moses/{WordsRange.h => Range.h} | 18 +++++++-------- moses/RuleCube.cpp | 2 +- moses/RuleCubeItem.cpp | 2 +- moses/SearchCubePruning.cpp | 10 ++++----- moses/SearchCubePruning.h | 4 ++-- moses/SearchNormal.cpp | 12 +++++----- moses/Sentence.cpp | 10 ++++----- moses/Sentence.h | 4 ++-- moses/Syntax/F2S/DerivationWriter.cpp | 2 +- moses/Syntax/F2S/HyperTreeLoader.cpp | 2 +- moses/Syntax/PVertex.h | 6 ++--- moses/Syntax/S2T/DerivationWriter.cpp | 2 +- moses/Syntax/S2T/Manager-inl.h | 4 ++-- moses/Syntax/S2T/ParserCallback.h | 4 ++-- moses/Syntax/S2T/Parsers/Parser.h | 2 +- .../RecursiveCYKPlusParser-inl.h | 2 +- .../RecursiveCYKPlusParser.h | 4 ++-- .../S2T/Parsers/Scope3Parser/Parser-inl.h | 2 +- .../Syntax/S2T/Parsers/Scope3Parser/Parser.h | 4 ++-- moses/Syntax/S2T/RuleTrieLoader.cpp | 2 +- moses/Syntax/T2S/InputTreeBuilder.cpp | 8 +++---- moses/Syntax/T2S/RuleTrieLoader.cpp | 2 +- moses/TranslationAnalysis.cpp | 4 ++-- .../ChartRuleLookupManagerCYKPlus.cpp | 2 +- .../ChartRuleLookupManagerCYKPlus.h | 4 ++-- .../ChartRuleLookupManagerMemory.cpp | 2 +- .../ChartRuleLookupManagerMemory.h | 2 +- ...hartRuleLookupManagerMemoryPerSentence.cpp | 2 +- .../ChartRuleLookupManagerMemoryPerSentence.h | 2 +- .../ChartRuleLookupManagerOnDisk.cpp | 2 +- .../ChartRuleLookupManagerSkeleton.cpp | 2 +- .../ChartRuleLookupManagerSkeleton.h | 2 +- .../TranslationModel/CYKPlusParser/DotChart.h | 2 +- .../LexicalReorderingTableCompact.cpp | 2 +- .../CompactPT/PhraseDecoder.cpp | 2 +- .../CompactPT/PhraseDecoder.h | 2 +- .../CompactPT/PhraseDictionaryCompact.cpp | 2 +- moses/TranslationModel/PhraseDictionary.cpp | 2 +- moses/TranslationModel/PhraseDictionary.h | 4 ++-- .../PhraseDictionaryMemory.cpp | 2 +- .../PhraseDictionaryScope3.cpp | 2 +- .../PhraseDictionaryTreeAdaptor.cpp | 2 +- .../PhraseDictionaryTreeAdaptor.h | 4 ++-- .../RuleTable/LoaderStandard.cpp | 2 +- .../RuleTable/PhraseDictionaryFuzzyMatch.cpp | 2 +- .../TranslationModel/Scope3Parser/Parser.cpp | 2 +- moses/TranslationModel/Scope3Parser/Parser.h | 6 ++--- .../Scope3Parser/VarSpanNode.h | 2 +- .../TranslationModel/UG/spe-check-coverage.cc | 2 +- moses/TranslationOption.cpp | 4 ++-- moses/TranslationOption.h | 8 +++---- moses/TranslationOptionCollection.cpp | 4 ++-- moses/TranslationOptionCollection.h | 2 +- ...ranslationOptionCollectionConfusionNet.cpp | 4 ++-- moses/TranslationOptionCollectionLattice.cpp | 6 ++--- moses/TranslationOptionCollectionText.cpp | 8 +++---- moses/TreeInput.cpp | 8 +++---- moses/TreeInput.h | 4 ++-- moses/TrellisPath.cpp | 6 ++--- moses/TrellisPath.h | 4 ++-- moses/WordLattice.cpp | 2 +- moses/WordLattice.h | 2 +- moses/XmlOption.cpp | 4 ++-- moses/XmlOption.h | 6 ++--- moses/server/TranslationRequest.cpp | 6 ++--- search/applied.hh | 2 +- search/header.hh | 14 ++++++------ 139 files changed, 376 insertions(+), 376 deletions(-) rename moses/{WordsRange.cpp => Range.cpp} (89%) rename moses/{WordsRange.h => Range.h} (82%) diff --git a/contrib/other-builds/moses/.project b/contrib/other-builds/moses/.project index de1fc48ce..85e27e694 100644 --- a/contrib/other-builds/moses/.project +++ b/contrib/other-builds/moses/.project @@ -1146,14 +1146,14 @@ PARENT-3-PROJECT_LOC/moses/Bitmap.h - WordsRange.cpp + Range.cpp 1 - PARENT-3-PROJECT_LOC/moses/WordsRange.cpp + PARENT-3-PROJECT_LOC/moses/Range.cpp - WordsRange.h + Range.h 1 - PARENT-3-PROJECT_LOC/moses/WordsRange.h + PARENT-3-PROJECT_LOC/moses/Range.h XmlOption.cpp @@ -4956,9 +4956,9 @@ PARENT-3-PROJECT_LOC/moses/bin/gcc-4.8/release/debug-symbols-on/link-static/threading-multi/Bitmap.o - bin/gcc-4.8/release/debug-symbols-on/link-static/threading-multi/WordsRange.o + bin/gcc-4.8/release/debug-symbols-on/link-static/threading-multi/Range.o 1 - PARENT-3-PROJECT_LOC/moses/bin/gcc-4.8/release/debug-symbols-on/link-static/threading-multi/WordsRange.o + PARENT-3-PROJECT_LOC/moses/bin/gcc-4.8/release/debug-symbols-on/link-static/threading-multi/Range.o bin/gcc-4.8/release/debug-symbols-on/link-static/threading-multi/XmlOption.o diff --git a/contrib/other-builds/moses/moses.project b/contrib/other-builds/moses/moses.project index a9cf931ed..a4817283d 100644 --- a/contrib/other-builds/moses/moses.project +++ b/contrib/other-builds/moses/moses.project @@ -771,8 +771,8 @@ - - + + diff --git a/moses/BaseManager.h b/moses/BaseManager.h index ed9ccaffb..5206412db 100644 --- a/moses/BaseManager.h +++ b/moses/BaseManager.h @@ -22,7 +22,7 @@ protected: BaseManager(ttasksptr const& ttask); // output - typedef std::vector > ApplicationContext; + typedef std::vector > ApplicationContext; typedef std::set< std::pair > Alignments; void OutputSurface(std::ostream &out, diff --git a/moses/Bitmap.h b/moses/Bitmap.h index ba2c7f941..178845185 100644 --- a/moses/Bitmap.h +++ b/moses/Bitmap.h @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include "TypeDef.h" -#include "WordsRange.h" +#include "Range.h" namespace Moses { @@ -162,7 +162,7 @@ public: } void - SetValue(WordsRange const& range, bool val) { + SetValue(Range const& range, bool val) { SetValue(range.GetStartPos(), range.GetEndPos(), val); } @@ -171,7 +171,7 @@ public: return GetSize() == GetNumWordsCovered(); } //! whether the wordrange overlaps with any translated word in this bitmap - bool Overlap(const WordsRange &compare) const { + bool Overlap(const Range &compare) const { for (size_t pos = compare.GetStartPos() ; pos <= compare.GetEndPos() ; pos++) { if (m_bitmap[pos]) return true; diff --git a/moses/BitmapContainer.cpp b/moses/BitmapContainer.cpp index 794ea81ed..54207ba07 100644 --- a/moses/BitmapContainer.cpp +++ b/moses/BitmapContainer.cpp @@ -52,7 +52,7 @@ public: class HypothesisScoreOrdererWithDistortion { public: - HypothesisScoreOrdererWithDistortion(const WordsRange* transOptRange) : + HypothesisScoreOrdererWithDistortion(const Range* transOptRange) : m_transOptRange(transOptRange) { m_totalWeightDistortion = 0; const StaticData &staticData = StaticData::Instance(); @@ -67,7 +67,7 @@ public: } } - const WordsRange* m_transOptRange; + const Range* m_transOptRange; float m_totalWeightDistortion; bool operator()(const Hypothesis* hypoA, const Hypothesis* hypoB) const { @@ -136,7 +136,7 @@ BackwardsEdge::BackwardsEdge(const BitmapContainer &prevBitmapContainer return; } - const WordsRange &transOptRange = translations.Get(0)->GetSourceWordsRange(); + const Range &transOptRange = translations.Get(0)->GetSourceWordsRange(); HypothesisSet::const_iterator iterHypo = m_prevBitmapContainer.GetHypotheses().begin(); HypothesisSet::const_iterator iterEnd = m_prevBitmapContainer.GetHypotheses().end(); @@ -196,7 +196,7 @@ BackwardsEdge::Initialize() } const Bitmap &bm = m_hypotheses[0]->GetWordsBitmap(); - const WordsRange &newRange = m_translations.Get(0)->GetSourceWordsRange(); + const Range &newRange = m_translations.Get(0)->GetSourceWordsRange(); m_futureScore = m_futureScores.CalcFutureScore2(bm, newRange.GetStartPos(), newRange.GetEndPos()); Hypothesis *expanded = CreateHypothesis(*m_hypotheses[0], *m_translations.Get(0)); diff --git a/moses/Bitmaps.cpp b/moses/Bitmaps.cpp index 9f59fac1c..e6be28cd2 100644 --- a/moses/Bitmaps.cpp +++ b/moses/Bitmaps.cpp @@ -20,7 +20,7 @@ Bitmaps::~Bitmaps() } } -const Bitmap &Bitmaps::GetNextBitmap(const Bitmap &bm, const WordsRange &range) +const Bitmap &Bitmaps::GetNextBitmap(const Bitmap &bm, const Range &range) { Bitmap *newBM = new Bitmap(bm); newBM->SetValue(range, true); @@ -35,7 +35,7 @@ const Bitmap &Bitmaps::GetNextBitmap(const Bitmap &bm, const WordsRange &range) } } -const Bitmap &Bitmaps::GetBitmap(const Bitmap &bm, const WordsRange &range) +const Bitmap &Bitmaps::GetBitmap(const Bitmap &bm, const Range &range) { Coll::iterator iter = m_coll.find(&bm); assert(iter != m_coll.end()); diff --git a/moses/Bitmaps.h b/moses/Bitmaps.h index ce43c6a03..1c49fd884 100644 --- a/moses/Bitmaps.h +++ b/moses/Bitmaps.h @@ -11,13 +11,13 @@ namespace Moses class Bitmaps { - typedef boost::unordered_map NextBitmaps; + typedef boost::unordered_map NextBitmaps; typedef boost::unordered_map, UnorderedComparer > Coll; //typedef std::set > Coll; Coll m_coll; const Bitmap *m_initBitmap; - const Bitmap &GetNextBitmap(const Bitmap &bm, const WordsRange &range); + const Bitmap &GetNextBitmap(const Bitmap &bm, const Range &range); public: Bitmaps(size_t inputSize, const std::vector &initSourceCompleted); virtual ~Bitmaps(); @@ -25,7 +25,7 @@ public: const Bitmap &GetInitialBitmap() const { return *m_initBitmap; } - const Bitmap &GetBitmap(const Bitmap &bm, const WordsRange &range); + const Bitmap &GetBitmap(const Bitmap &bm, const Range &range); }; diff --git a/moses/ChartCell.cpp b/moses/ChartCell.cpp index 02f132bae..f0a25986a 100644 --- a/moses/ChartCell.cpp +++ b/moses/ChartCell.cpp @@ -25,7 +25,7 @@ #include "HypergraphOutput.h" #include "RuleCubeQueue.h" #include "RuleCube.h" -#include "WordsRange.h" +#include "Range.h" #include "Util.h" #include "StaticData.h" #include "ChartTranslationOptions.h" diff --git a/moses/ChartCell.h b/moses/ChartCell.h index 348bfd336..9bd21f585 100644 --- a/moses/ChartCell.h +++ b/moses/ChartCell.h @@ -26,7 +26,7 @@ #include #include #include "Word.h" -#include "WordsRange.h" +#include "Range.h" #include "NonTerminal.h" #include "ChartHypothesis.h" #include "ChartHypothesisCollection.h" @@ -60,12 +60,12 @@ public: return m_targetLabelSet; } - const WordsRange &GetCoverage() const { + const Range &GetCoverage() const { return m_coverage; } protected: - const WordsRange m_coverage; + const Range m_coverage; ChartCellLabelSet m_targetLabelSet; }; diff --git a/moses/ChartCellCollection.cpp b/moses/ChartCellCollection.cpp index 55c50a449..dbb4526ee 100644 --- a/moses/ChartCellCollection.cpp +++ b/moses/ChartCellCollection.cpp @@ -21,7 +21,7 @@ #include "ChartCellCollection.h" #include "InputType.h" -#include "WordsRange.h" +#include "Range.h" #include "ChartManager.h" namespace Moses diff --git a/moses/ChartCellCollection.h b/moses/ChartCellCollection.h index ac8e0fd38..deac97c4a 100644 --- a/moses/ChartCellCollection.h +++ b/moses/ChartCellCollection.h @@ -23,7 +23,7 @@ #include #include "InputType.h" #include "ChartCell.h" -#include "WordsRange.h" +#include "Range.h" #include "InputPath.h" namespace Moses @@ -51,7 +51,7 @@ public: * gets it from there :-(. The span is actually stored as a reference, * which needs to point somewhere, so I have it refer to the ChartCell. */ - const WordsRange &range = inner[0]->GetCoverage(); + const Range &range = inner[0]->GetCoverage(); m_source.push_back(new ChartCellLabel(range, input.GetWord(startPos))); } @@ -60,11 +60,11 @@ public: virtual ~ChartCellCollectionBase(); - const ChartCellBase &GetBase(const WordsRange &coverage) const { + const ChartCellBase &GetBase(const Range &coverage) const { return *m_cells[coverage.GetStartPos()][coverage.GetEndPos() - coverage.GetStartPos()]; } - ChartCellBase &MutableBase(const WordsRange &coverage) { + ChartCellBase &MutableBase(const Range &coverage) { return *m_cells[coverage.GetStartPos()][coverage.GetEndPos() - coverage.GetStartPos()]; } @@ -88,12 +88,12 @@ public: ChartCellCollection(const InputType &input, ChartManager &manager); //! get a chart cell for a particular range - ChartCell &Get(const WordsRange &coverage) { + ChartCell &Get(const Range &coverage) { return static_cast(MutableBase(coverage)); } //! get a chart cell for a particular range - const ChartCell &Get(const WordsRange &coverage) const { + const ChartCell &Get(const Range &coverage) const { return static_cast(GetBase(coverage)); } }; diff --git a/moses/ChartCellLabel.h b/moses/ChartCellLabel.h index 18fa8b850..60773895a 100644 --- a/moses/ChartCellLabel.h +++ b/moses/ChartCellLabel.h @@ -21,7 +21,7 @@ #include "HypoList.h" #include "Word.h" -#include "WordsRange.h" +#include "Range.h" #include "ChartParserCallback.h" namespace search @@ -49,7 +49,7 @@ public: }; - ChartCellLabel(const WordsRange &coverage, const Word &label, + ChartCellLabel(const Range &coverage, const Word &label, Stack stack=Stack()) : m_coverage(coverage) , m_label(label) @@ -57,7 +57,7 @@ public: , m_bestScore(0) { } - const WordsRange &GetCoverage() const { + const Range &GetCoverage() const { return m_coverage; } const Word &GetLabel() const { @@ -79,7 +79,7 @@ public: } private: - const WordsRange &m_coverage; + const Range &m_coverage; const Word &m_label; //const InputPath &m_inputPath; Stack m_stack; diff --git a/moses/ChartCellLabelSet.h b/moses/ChartCellLabelSet.h index 4977c941f..b4e071443 100644 --- a/moses/ChartCellLabelSet.h +++ b/moses/ChartCellLabelSet.h @@ -44,7 +44,7 @@ public: typedef MapType::const_iterator const_iterator; typedef MapType::iterator iterator; - ChartCellLabelSet(const WordsRange &coverage) + ChartCellLabelSet(const Range &coverage) : m_coverage(coverage) , m_map(FactorCollection::Instance().GetNumNonTerminals(), NULL) , m_size(0) { } @@ -139,7 +139,7 @@ public: } private: - const WordsRange &m_coverage; + const Range &m_coverage; MapType m_map; size_t m_size; }; diff --git a/moses/ChartHypothesis.h b/moses/ChartHypothesis.h index 776fcd61c..63f59c31e 100644 --- a/moses/ChartHypothesis.h +++ b/moses/ChartHypothesis.h @@ -23,7 +23,7 @@ #include #include #include "Util.h" -#include "WordsRange.h" +#include "Range.h" #include "ScoreComponentCollection.h" #include "Phrase.h" #include "ChartTranslationOptions.h" @@ -52,7 +52,7 @@ protected: boost::shared_ptr m_transOpt; - WordsRange m_currSourceWordsRange; + Range m_currSourceWordsRange; std::vector m_ffStates; /*! stateful feature function states */ /*! sum of scores of this hypothesis, and previous hypotheses. Lazily initialised. */ mutable boost::scoped_ptr m_scoreBreakdown; @@ -100,7 +100,7 @@ public: } //! the source range that this hypothesis spans - const WordsRange &GetCurrSourceRange() const { + const Range &GetCurrSourceRange() const { return m_currSourceWordsRange; } diff --git a/moses/ChartManager.cpp b/moses/ChartManager.cpp index 504cf605b..9c672e00a 100644 --- a/moses/ChartManager.cpp +++ b/moses/ChartManager.cpp @@ -82,7 +82,7 @@ void ChartManager::Decode() for (int startPos = size-1; startPos >= 0; --startPos) { for (size_t width = 1; width <= size-startPos; ++width) { size_t endPos = startPos + width - 1; - WordsRange range(startPos, endPos); + Range range(startPos, endPos); // create trans opt m_translationOptionList.Clear(); @@ -115,7 +115,7 @@ void ChartManager::Decode() cerr << " "; } for (size_t startPos = 0; startPos <= size-width; ++startPos) { - WordsRange range(startPos, startPos+width-1); + Range range(startPos, startPos+width-1); cerr.width(3); cerr << m_hypoStackColl.Get(range).GetSize() << " "; } @@ -142,7 +142,7 @@ void ChartManager::AddXmlChartOptions() i != xmlChartOptionsList.end(); ++i) { ChartTranslationOptions* opt = *i; - const WordsRange &range = opt->GetSourceWordsRange(); + const Range &range = opt->GetSourceWordsRange(); RuleCubeItem* item = new RuleCubeItem( *opt, m_hypoStackColl ); ChartHypothesis* hypo = new ChartHypothesis(*opt, *item, *this); @@ -162,7 +162,7 @@ const ChartHypothesis *ChartManager::GetBestHypothesis() const if (size == 0) // empty source return NULL; else { - WordsRange range(0, size-1); + Range range(0, size-1); const ChartCell &lastCell = m_hypoStackColl.Get(range); return lastCell.GetBestHypothesis(); } @@ -185,7 +185,7 @@ void ChartManager::CalcNBest( } // Get the list of top-level hypotheses, sorted by score. - WordsRange range(0, m_source.GetSize()-1); + Range range(0, m_source.GetSize()-1); const ChartCell &lastCell = m_hypoStackColl.Get(range); boost::scoped_ptr > topLevelHypos( lastCell.GetAllSortedHypotheses()); @@ -234,7 +234,7 @@ void ChartManager::WriteSearchGraph(const ChartSearchGraphWriter& writer) const // which hypotheses are reachable? std::map reachable; - WordsRange fullRange(0, size-1); + Range fullRange(0, size-1); const ChartCell &lastCell = m_hypoStackColl.Get(fullRange); const ChartHypothesis *hypo = lastCell.GetBestHypothesis(); @@ -251,7 +251,7 @@ void ChartManager::WriteSearchGraph(const ChartSearchGraphWriter& writer) const for (size_t width = 1; width <= size; ++width) { for (size_t startPos = 0; startPos <= size-width; ++startPos) { size_t endPos = startPos + width - 1; - WordsRange range(startPos, endPos); + Range range(startPos, endPos); TRACE_ERR(" " << range << "="); const ChartCell &cell = m_hypoStackColl.Get(range); @@ -674,18 +674,18 @@ void ChartManager::ReconstructApplicationContext(const ChartHypothesis &hypo, const std::vector &prevHypos = hypo.GetPrevHypos(); std::vector::const_iterator p = prevHypos.begin(); std::vector::const_iterator end = prevHypos.end(); - const WordsRange &span = hypo.GetCurrSourceRange(); + const Range &span = hypo.GetCurrSourceRange(); size_t i = span.GetStartPos(); while (i <= span.GetEndPos()) { if (p == end || i < (*p)->GetCurrSourceRange().GetStartPos()) { // Symbol is a terminal. const Word &symbol = sentence.GetWord(i); - context.push_back(std::make_pair(symbol, WordsRange(i, i))); + context.push_back(std::make_pair(symbol, Range(i, i))); ++i; } else { // Symbol is a non-terminal. const Word &symbol = (*p)->GetTargetLHS(); - const WordsRange &range = (*p)->GetCurrSourceRange(); + const Range &range = (*p)->GetCurrSourceRange(); context.push_back(std::make_pair(symbol, range)); i = range.GetEndPos()+1; ++p; @@ -797,7 +797,7 @@ void ChartManager::OutputDetailedAllTranslationReport( for (size_t width = 1; width <= size; ++width) { for (size_t startPos = 0; startPos <= size-width; ++startPos) { size_t endPos = startPos + width - 1; - WordsRange range(startPos, endPos); + Range range(startPos, endPos); const ChartCell& cell = cells.Get(range); const HypoList* hyps = cell.GetAllSortedHypotheses(); out << "Chart Cell [" << startPos << ".." << endPos << "]" << endl; diff --git a/moses/ChartManager.h b/moses/ChartManager.h index 9d5485fb9..bd3dbef08 100644 --- a/moses/ChartManager.h +++ b/moses/ChartManager.h @@ -25,7 +25,7 @@ #include #include "ChartCell.h" #include "ChartCellCollection.h" -#include "WordsRange.h" +#include "Range.h" #include "SentenceStats.h" #include "ChartTranslationOptionList.h" #include "ChartParser.h" diff --git a/moses/ChartParser.cpp b/moses/ChartParser.cpp index b129419f6..897f1828f 100644 --- a/moses/ChartParser.cpp +++ b/moses/ChartParser.cpp @@ -47,7 +47,7 @@ ChartParserUnknown::~ChartParserUnknown() // RemoveAllInColl(m_cacheTargetPhraseCollection); } -void ChartParserUnknown::Process(const Word &sourceWord, const WordsRange &range, ChartParserCallback &to) +void ChartParserUnknown::Process(const Word &sourceWord, const Range &range, ChartParserCallback &to) { // unknown word, add as trans opt const StaticData &staticData = StaticData::Instance(); @@ -183,7 +183,7 @@ ChartParser::~ChartParser() } } -void ChartParser::Create(const WordsRange &wordsRange, ChartParserCallback &to) +void ChartParser::Create(const Range &range, ChartParserCallback &to) { assert(m_decodeGraphList.size() == m_ruleLookupManagers.size()); @@ -196,20 +196,20 @@ void ChartParser::Create(const WordsRange &wordsRange, ChartParserCallback &to) size_t maxSpan = decodeGraph.GetMaxChartSpan(); size_t last = m_source.GetSize()-1; if (maxSpan != 0) { - last = min(last, wordsRange.GetStartPos()+maxSpan); + last = min(last, range.GetStartPos()+maxSpan); } - if (maxSpan == 0 || wordsRange.GetNumWordsCovered() <= maxSpan) { - const InputPath &inputPath = GetInputPath(wordsRange); + if (maxSpan == 0 || range.GetNumWordsCovered() <= maxSpan) { + const InputPath &inputPath = GetInputPath(range); ruleLookupManager.GetChartRuleCollection(inputPath, last, to); } } - if (wordsRange.GetNumWordsCovered() == 1 && wordsRange.GetStartPos() != 0 && wordsRange.GetStartPos() != m_source.GetSize()-1) { + if (range.GetNumWordsCovered() == 1 && range.GetStartPos() != 0 && range.GetStartPos() != m_source.GetSize()-1) { bool alwaysCreateDirectTranslationOption = StaticData::Instance().IsAlwaysCreateDirectTranslationOption(); if (to.Empty() || alwaysCreateDirectTranslationOption) { // create unknown words for 1 word coverage where we don't have any trans options - const Word &sourceWord = m_source.GetWord(wordsRange.GetStartPos()); - m_unknown.Process(sourceWord, wordsRange, to); + const Word &sourceWord = m_source.GetWord(range.GetStartPos()); + m_unknown.Process(sourceWord, range, to); } } } @@ -226,8 +226,8 @@ void ChartParser::CreateInputPaths(const InputType &input) size_t endPos = startPos + phaseSize -1; vector &vec = m_inputPathMatrix[startPos]; - WordsRange range(startPos, endPos); - Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos))); + Range range(startPos, endPos); + Phrase subphrase(input.GetSubString(Range(startPos, endPos))); const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos); InputPath *node; @@ -245,7 +245,7 @@ void ChartParser::CreateInputPaths(const InputType &input) } } -const InputPath &ChartParser::GetInputPath(const WordsRange &range) const +const InputPath &ChartParser::GetInputPath(const Range &range) const { return GetInputPath(range.GetStartPos(), range.GetEndPos()); } diff --git a/moses/ChartParser.h b/moses/ChartParser.h index a1d0752c2..d6f20b6d6 100644 --- a/moses/ChartParser.h +++ b/moses/ChartParser.h @@ -24,7 +24,7 @@ #include #include -#include "WordsRange.h" +#include "Range.h" #include "StackVec.h" #include "InputPath.h" #include "TargetPhraseCollection.h" @@ -48,7 +48,7 @@ public: ChartParserUnknown(ttasksptr const& ttask); ~ChartParserUnknown(); - void Process(const Word &sourceWord, const WordsRange &range, ChartParserCallback &to); + void Process(const Word &sourceWord, const Range &range, ChartParserCallback &to); const std::vector &GetUnknownSources() const { return m_unksrcs; @@ -66,14 +66,14 @@ public: ChartParser(ttasksptr const& ttask, ChartCellCollectionBase &cells); ~ChartParser(); - void Create(const WordsRange &range, ChartParserCallback &to); + void Create(const Range &range, ChartParserCallback &to); //! the sentence being decoded //const Sentence &GetSentence() const; long GetTranslationId() const; size_t GetSize() const; const InputPath &GetInputPath(size_t startPos, size_t endPos) const; - const InputPath &GetInputPath(const WordsRange &range) const; + const InputPath &GetInputPath(const Range &range) const; const std::vector &GetUnknownSources() const { return m_unknown.GetUnknownSources(); } diff --git a/moses/ChartParserCallback.h b/moses/ChartParserCallback.h index 7c53654a6..04cf32e94 100644 --- a/moses/ChartParserCallback.h +++ b/moses/ChartParserCallback.h @@ -9,7 +9,7 @@ namespace Moses { class TargetPhraseCollection; -class WordsRange; +class Range; class TargetPhrase; class InputPath; class InputType; @@ -20,11 +20,11 @@ class ChartParserCallback public: virtual ~ChartParserCallback() {} - virtual void Add(const TargetPhraseCollection &, const StackVec &, const WordsRange &) = 0; + virtual void Add(const TargetPhraseCollection &, const StackVec &, const Range &) = 0; virtual bool Empty() const = 0; - virtual void AddPhraseOOV(TargetPhrase &phrase, std::list &waste_memory, const WordsRange &range) = 0; + virtual void AddPhraseOOV(TargetPhrase &phrase, std::list &waste_memory, const Range &range) = 0; virtual void EvaluateWithSourceContext(const InputType &input, const InputPath &inputPath) = 0; diff --git a/moses/ChartRuleLookupManager.h b/moses/ChartRuleLookupManager.h index b62ec157d..65fe6f3a4 100644 --- a/moses/ChartRuleLookupManager.h +++ b/moses/ChartRuleLookupManager.h @@ -28,7 +28,7 @@ namespace Moses { class ChartParser; class ChartParserCallback; -class WordsRange; +class Range; class Sentence; /** Defines an interface for looking up rules in a rule table. Concrete @@ -48,7 +48,7 @@ public: virtual ~ChartRuleLookupManager(); const ChartCellLabelSet &GetTargetLabelSet(size_t begin, size_t end) const { - return m_cellCollection.GetBase(WordsRange(begin, end)).GetTargetLabelSet(); + return m_cellCollection.GetBase(Range(begin, end)).GetTargetLabelSet(); } const ChartParser &GetParser() const { diff --git a/moses/ChartTranslationOptionList.cpp b/moses/ChartTranslationOptionList.cpp index 1d5c261bc..91a534098 100644 --- a/moses/ChartTranslationOptionList.cpp +++ b/moses/ChartTranslationOptionList.cpp @@ -24,7 +24,7 @@ #include "ChartTranslationOptionList.h" #include "ChartTranslationOptions.h" #include "ChartCellCollection.h" -#include "WordsRange.h" +#include "Range.h" #include "InputType.h" #include "InputPath.h" @@ -61,7 +61,7 @@ public: void ChartTranslationOptionList::Add(const TargetPhraseCollection &tpc, const StackVec &stackVec, - const WordsRange &range) + const Range &range) { if (tpc.IsEmpty()) { return; @@ -119,7 +119,7 @@ void ChartTranslationOptionList:: AddPhraseOOV(TargetPhrase &phrase, std::list &waste_memory, - const WordsRange &range) + const Range &range) { TargetPhraseCollection::shared_ptr tpc(new TargetPhraseCollection); tpc->Add(&phrase); diff --git a/moses/ChartTranslationOptionList.h b/moses/ChartTranslationOptionList.h index c8ca5760c..a9d31d774 100644 --- a/moses/ChartTranslationOptionList.h +++ b/moses/ChartTranslationOptionList.h @@ -29,7 +29,7 @@ namespace Moses { class TargetPhraseCollection; -class WordsRange; +class Range; class InputType; class InputPath; class ChartCellLabel; @@ -53,9 +53,9 @@ public: } void Add(const TargetPhraseCollection &, const StackVec &, - const WordsRange &); + const Range &); - void AddPhraseOOV(TargetPhrase &phrase, std::list &waste_memory, const WordsRange &range); + void AddPhraseOOV(TargetPhrase &phrase, std::list &waste_memory, const Range &range); bool Empty() const { return m_size == 0; diff --git a/moses/ChartTranslationOptions.cpp b/moses/ChartTranslationOptions.cpp index 03a869109..8c35a0de1 100644 --- a/moses/ChartTranslationOptions.cpp +++ b/moses/ChartTranslationOptions.cpp @@ -31,10 +31,10 @@ namespace Moses ChartTranslationOptions::ChartTranslationOptions(const TargetPhraseCollection &targetPhraseColl, const StackVec &stackVec, - const WordsRange &wordsRange, + const Range &range, float score) : m_stackVec(stackVec) - , m_wordsRange(&wordsRange) + , m_wordsRange(&range) , m_estimateOfBestScore(score) { TargetPhraseCollection::const_iterator iter; diff --git a/moses/ChartTranslationOptions.h b/moses/ChartTranslationOptions.h index 73c378eb0..0c95a22aa 100644 --- a/moses/ChartTranslationOptions.h +++ b/moses/ChartTranslationOptions.h @@ -22,7 +22,7 @@ #include "StackVec.h" #include "TargetPhrase.h" #include "TargetPhraseCollection.h" -#include "WordsRange.h" +#include "Range.h" #include #include @@ -47,12 +47,12 @@ public: /** Constructor \param targetPhraseColl @todo dunno \param stackVec @todo dunno - \param wordsRange the range in the source sentence this translation option covers + \param range the range in the source sentence this translation option covers \param score @todo dunno */ ChartTranslationOptions(const TargetPhraseCollection &targetPhraseColl, const StackVec &stackVec, - const WordsRange &wordsRange, + const Range &range, float score); ~ChartTranslationOptions(); @@ -74,7 +74,7 @@ public: } //! the range in the source sentence this translation option covers - const WordsRange &GetSourceWordsRange() const { + const Range &GetSourceWordsRange() const { return *m_wordsRange; } @@ -97,7 +97,7 @@ private: StackVec m_stackVec; //! vector of hypothesis list! CollType m_collection; - const WordsRange *m_wordsRange; + const Range *m_wordsRange; float m_estimateOfBestScore; }; diff --git a/moses/ConfusionNet.cpp b/moses/ConfusionNet.cpp index 671f0d166..41522268d 100644 --- a/moses/ConfusionNet.cpp +++ b/moses/ConfusionNet.cpp @@ -261,7 +261,7 @@ void ConfusionNet::Print(std::ostream& out) const #endif Phrase ConfusionNet:: -GetSubString(const WordsRange&) const +GetSubString(const Range&) const { UTIL_THROW2("ERROR: call to ConfusionNet::GetSubString\n"); //return Phrase(Input); diff --git a/moses/ConfusionNet.h b/moses/ConfusionNet.h index e274f2491..85e5f338d 100644 --- a/moses/ConfusionNet.h +++ b/moses/ConfusionNet.h @@ -69,7 +69,7 @@ public: int Read(std::istream& in,const std::vector& factorOrder); - Phrase GetSubString(const WordsRange&) const; //TODO not defined + Phrase GetSubString(const Range&) const; //TODO not defined std::string GetStringRep(const std::vector factorsToPrint) const; //TODO not defined const Word& GetWord(size_t pos) const; diff --git a/moses/DecodeStepGeneration.cpp b/moses/DecodeStepGeneration.cpp index 26b95cdb5..dacde52ed 100644 --- a/moses/DecodeStepGeneration.cpp +++ b/moses/DecodeStepGeneration.cpp @@ -150,7 +150,7 @@ void DecodeStepGeneration::Process(const TranslationOption &inputPartialTranslOp outPhrase.MergeFactors(genPhrase, m_newOutputFactors); outPhrase.EvaluateInIsolation(inputPath.GetPhrase(), m_featuresToApply); - const WordsRange &sourceWordsRange = inputPartialTranslOpt.GetSourceWordsRange(); + const Range &sourceWordsRange = inputPartialTranslOpt.GetSourceWordsRange(); TranslationOption *newTransOpt = new TranslationOption(sourceWordsRange, outPhrase); assert(newTransOpt); diff --git a/moses/DecodeStepTranslation.cpp b/moses/DecodeStepTranslation.cpp index 071dd1cab..c593f8ebc 100644 --- a/moses/DecodeStepTranslation.cpp +++ b/moses/DecodeStepTranslation.cpp @@ -58,7 +58,7 @@ void DecodeStepTranslation::Process(const TranslationOption &inputPartialTranslO } // normal trans step - const WordsRange &sourceWordsRange = inputPartialTranslOpt.GetSourceWordsRange(); + const Range &sourceWordsRange = inputPartialTranslOpt.GetSourceWordsRange(); const InputPath &inputPath = inputPartialTranslOpt.GetInputPath(); const PhraseDictionary* phraseDictionary = decodeStep.GetPhraseDictionaryFeature(); @@ -110,12 +110,12 @@ void DecodeStepTranslation::ProcessInitialTranslation( const PhraseDictionary* phraseDictionary = GetPhraseDictionaryFeature(); const size_t tableLimit = phraseDictionary->GetTableLimit(); - const WordsRange wordsRange(startPos, endPos); + const Range range(startPos, endPos); if (phraseColl != NULL) { IFVERBOSE(3) { if(StaticData::Instance().GetInputType() == SentenceInput) - TRACE_ERR("[" << source.GetSubString(wordsRange) << "; " << startPos << "-" << endPos << "]\n"); + TRACE_ERR("[" << source.GetSubString(range) << "; " << startPos << "-" << endPos << "]\n"); else TRACE_ERR("[" << startPos << "-" << endPos << "]" << std::endl); } @@ -125,7 +125,7 @@ void DecodeStepTranslation::ProcessInitialTranslation( for (iterTargetPhrase = phraseColl->begin() ; iterTargetPhrase != iterEnd ; ++iterTargetPhrase) { const TargetPhrase &targetPhrase = **iterTargetPhrase; - TranslationOption *transOpt = new TranslationOption(wordsRange, targetPhrase); + TranslationOption *transOpt = new TranslationOption(range, targetPhrase); transOpt->SetInputPath(inputPath); @@ -146,14 +146,14 @@ void DecodeStepTranslation::ProcessInitialTranslationLEGACY( const PhraseDictionary* phraseDictionary = GetPhraseDictionaryFeature(); const size_t tableLimit = phraseDictionary->GetTableLimit(); - const WordsRange wordsRange(startPos, endPos); + const Range range(startPos, endPos); TargetPhraseCollectionWithSourcePhrase::shared_ptr phraseColl - = phraseDictionary->GetTargetPhraseCollectionLEGACY(source,wordsRange); + = phraseDictionary->GetTargetPhraseCollectionLEGACY(source,range); if (phraseColl != NULL) { IFVERBOSE(3) { if(StaticData::Instance().GetInputType() == SentenceInput) - TRACE_ERR("[" << source.GetSubString(wordsRange) << "; " << startPos << "-" << endPos << "]\n"); + TRACE_ERR("[" << source.GetSubString(range) << "; " << startPos << "-" << endPos << "]\n"); else TRACE_ERR("[" << startPos << "-" << endPos << "]" << std::endl); } @@ -174,7 +174,7 @@ void DecodeStepTranslation::ProcessInitialTranslationLEGACY( const InputPath &inputPath = GetInputPathLEGACY(targetPhrase, sourcePhrase, inputPathList); - TranslationOption *transOpt = new TranslationOption(wordsRange, targetPhrase); + TranslationOption *transOpt = new TranslationOption(range, targetPhrase); transOpt->SetInputPath(inputPath); outputPartialTranslOptColl.Add (transOpt); @@ -206,7 +206,7 @@ const InputPath &DecodeStepTranslation::GetInputPathLEGACY( } } - // const WordsRange &range = inputPath.GetWordsRange(); + // const Range &range = inputPath.GetWordsRange(); if (wordIP && *wordIP == wordFromPt) { return inputPath; @@ -231,7 +231,7 @@ ProcessLEGACY(TranslationOption const& in, } // normal trans step - WordsRange const& srcRange = in.GetSourceWordsRange(); + Range const& srcRange = in.GetSourceWordsRange(); InputPath const& inputPath = in.GetInputPath(); PhraseDictionary const* pdict = decodeStep.GetPhraseDictionaryFeature(); TargetPhrase const& inPhrase = in.GetTargetPhrase(); diff --git a/moses/FF/BleuScoreFeature.cpp b/moses/FF/BleuScoreFeature.cpp index 983dcac41..eaecd59af 100644 --- a/moses/FF/BleuScoreFeature.cpp +++ b/moses/FF/BleuScoreFeature.cpp @@ -380,7 +380,7 @@ void BleuScoreFeature::GetNgramMatchCounts(Phrase& phrase, ngram_end_idx = end_idx; ngram_start_idx = end_idx - order; - Phrase ngram = phrase.GetSubString(WordsRange(ngram_start_idx, ngram_end_idx), 0); + Phrase ngram = phrase.GetSubString(Range(ngram_start_idx, ngram_end_idx), 0); ret_counts[order]++; ref_ngram_counts_iter = ref_ngram_counts.find(ngram); @@ -409,7 +409,7 @@ void BleuScoreFeature::GetNgramMatchCounts_prefix(Phrase& phrase, if (order > ngram_end_idx) break; if (ngram_end_idx > last_end_index) break; - Phrase ngram = phrase.GetSubString(WordsRange(ngram_start_idx, ngram_end_idx), 0); + Phrase ngram = phrase.GetSubString(Range(ngram_start_idx, ngram_end_idx), 0); ret_counts[order]++; ref_ngram_counts_iter = ref_ngram_counts.find(ngram); @@ -439,7 +439,7 @@ void BleuScoreFeature::GetNgramMatchCounts_overlap(Phrase& phrase, ngram_start_idx = end_idx - order; if (ngram_start_idx >= overlap_index) continue; // only score ngrams that span the overlap point - Phrase ngram = phrase.GetSubString(WordsRange(ngram_start_idx, ngram_end_idx), 0); + Phrase ngram = phrase.GetSubString(Range(ngram_start_idx, ngram_end_idx), 0); ret_counts[order]++; ref_ngram_counts_iter = ref_ngram_counts.find(ngram); @@ -466,7 +466,7 @@ void BleuScoreFeature::GetClippedNgramMatchesAndCounts(Phrase& phrase, ngram_end_idx = end_idx; ngram_start_idx = end_idx - order; - Phrase ngram = phrase.GetSubString(WordsRange(ngram_start_idx, ngram_end_idx), 0); + Phrase ngram = phrase.GetSubString(Range(ngram_start_idx, ngram_end_idx), 0); ret_counts[order]++; ref_ngram_counts_iter = ref_ngram_counts.find(ngram); @@ -541,7 +541,7 @@ FFState* BleuScoreFeature::EvaluateWhenApplied(const Hypothesis& cur_hypo, Bitmap coverageVector = cur_hypo.GetWordsBitmap(); new_state->m_source_length = coverageVector.GetNumWordsCovered(); - new_state->m_words = new_words.GetSubString(WordsRange(ctx_start_idx, + new_state->m_words = new_words.GetSubString(Range(ctx_start_idx, ctx_end_idx)); new_state->m_target_length += cur_hypo.GetCurrTargetLength(); @@ -672,7 +672,7 @@ FFState* BleuScoreFeature::EvaluateWhenApplied(const ChartHypothesis& cur_hypo, } new_state->m_source_length = cur_hypo.GetCurrSourceRange().GetNumWordsCovered(); - new_state->m_words = new_words.GetSubString(WordsRange(ctx_start_idx, ctx_end_idx)); + new_state->m_words = new_words.GetSubString(Range(ctx_start_idx, ctx_end_idx)); new_state->m_target_length = cur_hypo.GetOutputPhrase().GetSize(); // we need a scaled reference length to compare the current target phrase to the corresponding @@ -699,7 +699,7 @@ float BleuScoreFeature::CalculateBleu(Phrase translation) const Phrase normTranslation = translation; // remove start and end symbol for chart decoding if (m_cur_source_length != m_cur_norm_source_length) { - WordsRange* range = new WordsRange(1, translation.GetSize()-2); + Range* range = new Range(1, translation.GetSize()-2); normTranslation = translation.GetSubString(*range); } diff --git a/moses/FF/DistortionScoreProducer.cpp b/moses/FF/DistortionScoreProducer.cpp index a565d2b75..02002e860 100644 --- a/moses/FF/DistortionScoreProducer.cpp +++ b/moses/FF/DistortionScoreProducer.cpp @@ -1,7 +1,7 @@ #include "DistortionScoreProducer.h" #include "FFState.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/StaticData.h" #include "moses/Hypothesis.h" @@ -10,9 +10,9 @@ using namespace std; namespace Moses { struct DistortionState_traditional : public FFState { - WordsRange range; + Range range; int first_gap; - DistortionState_traditional(const WordsRange& wr, int fg) : range(wr), first_gap(fg) {} + DistortionState_traditional(const Range& wr, int fg) : range(wr), first_gap(fg) {} size_t hash() const { return range.GetEndPos(); @@ -45,12 +45,12 @@ const FFState* DistortionScoreProducer::EmptyHypothesisState(const InputType &in end = input.m_frontSpanCoveredLength -1; } return new DistortionState_traditional( - WordsRange(start, end), + Range(start, end), NOT_FOUND); } float DistortionScoreProducer::CalculateDistortionScore(const Hypothesis& hypo, - const WordsRange &prev, const WordsRange &curr, const int FirstGap) + const Range &prev, const Range &curr, const int FirstGap) { if(!StaticData::Instance().UseEarlyDistortionCost()) { return - (float) hypo.GetInput().ComputeDistortionDistance(prev, curr); diff --git a/moses/FF/DistortionScoreProducer.h b/moses/FF/DistortionScoreProducer.h index 218fb9b40..a7cd6f36a 100644 --- a/moses/FF/DistortionScoreProducer.h +++ b/moses/FF/DistortionScoreProducer.h @@ -10,7 +10,7 @@ class FFState; class ScoreComponentCollection; class Hypothesis; class ChartHypothesis; -class WordsRange; +class Range; /** Calculates Distortion scores */ @@ -31,7 +31,7 @@ public: } static float CalculateDistortionScore(const Hypothesis& hypo, - const WordsRange &prev, const WordsRange &curr, const int FirstGapPosition); + const Range &prev, const Range &curr, const int FirstGapPosition); virtual const FFState* EmptyHypothesisState(const InputType &input) const; diff --git a/moses/FF/DynamicCacheBasedLanguageModel.h b/moses/FF/DynamicCacheBasedLanguageModel.h index 5d9d17517..39e102e10 100644 --- a/moses/FF/DynamicCacheBasedLanguageModel.h +++ b/moses/FF/DynamicCacheBasedLanguageModel.h @@ -31,7 +31,7 @@ typedef std::map decaying_cache_t; namespace Moses { -class WordsRange; +class Range; /** Calculates score for the Dynamic Cache-Based pseudo LM */ diff --git a/moses/FF/FeatureFunction.h b/moses/FF/FeatureFunction.h index 35febaaca..994e65498 100644 --- a/moses/FF/FeatureFunction.h +++ b/moses/FF/FeatureFunction.h @@ -22,7 +22,7 @@ class ChartHypothesis; class InputType; class ScoreComponentCollection; class Bitmap; -class WordsRange; +class Range; class FactorMask; class InputPath; class StackVec; diff --git a/moses/FF/GlobalLexicalModel.h b/moses/FF/GlobalLexicalModel.h index e9b787220..17f905440 100644 --- a/moses/FF/GlobalLexicalModel.h +++ b/moses/FF/GlobalLexicalModel.h @@ -10,7 +10,7 @@ #include "moses/Phrase.h" #include "moses/TypeDef.h" #include "moses/Util.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/FactorTypeSet.h" #include "moses/Sentence.h" diff --git a/moses/FF/GlobalLexicalModelUnlimited.h b/moses/FF/GlobalLexicalModelUnlimited.h index 473a3c0e0..ece01bfa1 100644 --- a/moses/FF/GlobalLexicalModelUnlimited.h +++ b/moses/FF/GlobalLexicalModelUnlimited.h @@ -12,7 +12,7 @@ #include "moses/Phrase.h" #include "moses/TypeDef.h" #include "moses/Util.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/FactorTypeSet.h" #include "moses/Sentence.h" diff --git a/moses/FF/LexicalReordering/LexicalReordering.h b/moses/FF/LexicalReordering/LexicalReordering.h index ebf5cb3ca..33e4a66ae 100644 --- a/moses/FF/LexicalReordering/LexicalReordering.h +++ b/moses/FF/LexicalReordering/LexicalReordering.h @@ -8,7 +8,7 @@ #include "moses/Phrase.h" #include "moses/TypeDef.h" #include "moses/Util.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/TranslationOption.h" #include "moses/FF/StatefulFeatureFunction.h" diff --git a/moses/FF/LexicalReordering/LexicalReorderingState.cpp b/moses/FF/LexicalReordering/LexicalReorderingState.cpp index 8b6071f67..363ecfbb6 100644 --- a/moses/FF/LexicalReordering/LexicalReorderingState.cpp +++ b/moses/FF/LexicalReordering/LexicalReorderingState.cpp @@ -4,7 +4,7 @@ #include "moses/FF/FFState.h" #include "moses/Hypothesis.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/TranslationOption.h" #include "moses/Util.h" @@ -16,8 +16,8 @@ namespace Moses { bool -IsMonotonicStep(WordsRange const& prev, // words range of last source phrase - WordsRange const& cur, // words range of current source phrase +IsMonotonicStep(Range const& prev, // words range of last source phrase + Range const& cur, // words range of current source phrase Bitmap const& cov) // coverage bitmap { size_t e = prev.GetEndPos() + 1; @@ -26,7 +26,7 @@ IsMonotonicStep(WordsRange const& prev, // words range of last source phrase } bool -IsSwap(WordsRange const& prev, WordsRange const& cur, Bitmap const& cov) +IsSwap(Range const& prev, Range const& cur, Bitmap const& cov) { size_t s = prev.GetStartPos(); size_t e = cur.GetEndPos(); @@ -71,7 +71,7 @@ SetAdditionalScoreComponents(size_t number) /// return orientation for the first phrase LRModel::ReorderingType LRModel:: -GetOrientation(WordsRange const& cur) const +GetOrientation(Range const& cur) const { UTIL_THROW_IF2(m_modelType == None, "Reordering Model Type is None"); return ((m_modelType == LeftRight) ? R : @@ -82,7 +82,7 @@ GetOrientation(WordsRange const& cur) const LRModel::ReorderingType LRModel:: -GetOrientation(WordsRange const& prev, WordsRange const& cur) const +GetOrientation(Range const& prev, Range const& cur) const { UTIL_THROW_IF2(m_modelType == None, "No reordering model type specified"); return ((m_modelType == LeftRight) @@ -110,7 +110,7 @@ GetOrientation(int const reoDistance) const LRModel::ReorderingType LRModel:: -GetOrientation(WordsRange const& prev, WordsRange const& cur, +GetOrientation(Range const& prev, Range const& cur, Bitmap const& cov) const { return ((m_modelType == LeftRight) @@ -347,7 +347,7 @@ Expand(const TranslationOption& topt, const InputType& input, if ((m_direction != LRModel::Forward && m_useFirstBackwardScore) || !m_first) { LRModel const& lrmodel = m_configuration; - WordsRange const cur = topt.GetSourceWordsRange(); + Range const cur = topt.GetSourceWordsRange(); LRModel::ReorderingType reoType = (m_first ? lrmodel.GetOrientation(cur) : lrmodel.GetOrientation(m_prevRange,cur)); CopyScores(scores, topt, input, reoType); @@ -423,7 +423,7 @@ Expand(const TranslationOption& topt, const InputType& input, { HReorderingBackwardState* nextState; nextState = new HReorderingBackwardState(this, topt, m_reoStack); - WordsRange swrange = topt.GetSourceWordsRange(); + Range swrange = topt.GetSourceWordsRange(); int reoDistance = nextState->m_reoStack.ShiftReduce(swrange); ReorderingType reoType = m_configuration.GetOrientation(reoDistance); CopyScores(scores, topt, input, reoType); @@ -492,7 +492,7 @@ HReorderingForwardState:: Expand(TranslationOption const& topt, InputType const& input, ScoreComponentCollection* scores) const { - const WordsRange cur = topt.GetSourceWordsRange(); + const Range cur = topt.GetSourceWordsRange(); // keep track of the current coverage ourselves so we don't need the hypothesis Bitmap cov = m_coverage; cov.SetValue(cur, true); diff --git a/moses/FF/LexicalReordering/LexicalReorderingState.h b/moses/FF/LexicalReordering/LexicalReorderingState.h index e135cafad..752604dcd 100644 --- a/moses/FF/LexicalReordering/LexicalReorderingState.h +++ b/moses/FF/LexicalReordering/LexicalReorderingState.h @@ -7,7 +7,7 @@ #include "moses/Hypothesis.h" #include "moses/ScoreComponentCollection.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/Bitmap.h" #include "moses/TranslationOption.h" #include "moses/FF/FFState.h" @@ -59,13 +59,13 @@ public: ReorderingType // for first phrase in phrase-based - GetOrientation(WordsRange const& cur) const; + GetOrientation(Range const& cur) const; ReorderingType // for non-first phrases in phrase-based - GetOrientation(WordsRange const& prev, WordsRange const& cur) const; + GetOrientation(Range const& prev, Range const& cur) const; ReorderingType // for HReorderingForwardState - GetOrientation(WordsRange const& prev, WordsRange const& cur, + GetOrientation(Range const& prev, Range const& cur, Bitmap const& cov) const; ReorderingType // for HReorderingBackwarddState @@ -233,7 +233,7 @@ class PhraseBasedReorderingState : public LRState { private: - WordsRange m_prevRange; + Range m_prevRange; bool m_first; public: static bool m_useFirstBackwardScore; @@ -251,10 +251,10 @@ public: Expand(const TranslationOption& topt,const InputType& input, ScoreComponentCollection* scores) const; - ReorderingType GetOrientationTypeMSD(WordsRange currRange) const; - ReorderingType GetOrientationTypeMSLR(WordsRange currRange) const; - ReorderingType GetOrientationTypeMonotonic(WordsRange currRange) const; - ReorderingType GetOrientationTypeLeftRight(WordsRange currRange) const; + ReorderingType GetOrientationTypeMSD(Range currRange) const; + ReorderingType GetOrientationTypeMSLR(Range currRange) const; + ReorderingType GetOrientationTypeMonotonic(Range currRange) const; + ReorderingType GetOrientationTypeLeftRight(Range currRange) const; }; //! State for a hierarchical reordering model (see Galley and Manning, A @@ -288,7 +288,7 @@ class HReorderingForwardState : public LRState { private: bool m_first; - WordsRange m_prevRange; + Range m_prevRange; Bitmap m_coverage; public: diff --git a/moses/FF/LexicalReordering/LexicalReorderingTable.cpp b/moses/FF/LexicalReordering/LexicalReorderingTable.cpp index e4da6eb6b..d3078b522 100644 --- a/moses/FF/LexicalReordering/LexicalReorderingTable.cpp +++ b/moses/FF/LexicalReordering/LexicalReorderingTable.cpp @@ -100,7 +100,7 @@ LexicalReorderingTableMemory::GetScore(const Phrase& f, } else { //right try from large to smaller context for(size_t i = 0; i <= c.GetSize(); ++i) { - Phrase sub_c(c.GetSubString(WordsRange(i,c.GetSize()-1))); + Phrase sub_c(c.GetSubString(Range(i,c.GetSize()-1))); key = MakeKey(f,e,sub_c); r = m_Table.find(key); if(m_Table.end() != r) { @@ -582,7 +582,7 @@ Cache(const Sentence& input) size_t max_phrase_length = input.GetSize(); for(size_t len = 0; len <= max_phrase_length; ++len) { for(size_t start = 0; start+len <= input.GetSize(); ++start) { - Phrase f = input.GetSubString(WordsRange(start, start+len)); + Phrase f = input.GetSubString(Range(start, start+len)); auxCacheForSrcPhrase(f); } } diff --git a/moses/FF/LexicalReordering/ReorderingStack.cpp b/moses/FF/LexicalReordering/ReorderingStack.cpp index 014caece9..f3ec51ba6 100644 --- a/moses/FF/LexicalReordering/ReorderingStack.cpp +++ b/moses/FF/LexicalReordering/ReorderingStack.cpp @@ -22,7 +22,7 @@ bool ReorderingStack::operator==(const ReorderingStack& o) const } // Method to push (shift element into the stack and reduce if reqd) -int ReorderingStack::ShiftReduce(WordsRange input_span) +int ReorderingStack::ShiftReduce(Range input_span) { int distance; // value to return: the initial distance between this and previous span @@ -33,7 +33,7 @@ int ReorderingStack::ShiftReduce(WordsRange input_span) } // stack is non-empty - WordsRange prev_span = m_stack.back(); //access last element added + Range prev_span = m_stack.back(); //access last element added //calculate the distance we are returning if(input_span.GetStartPos() > prev_span.GetStartPos()) { @@ -44,11 +44,11 @@ int ReorderingStack::ShiftReduce(WordsRange input_span) if(distance == 1) { //monotone m_stack.pop_back(); - WordsRange new_span(prev_span.GetStartPos(), input_span.GetEndPos()); + Range new_span(prev_span.GetStartPos(), input_span.GetEndPos()); Reduce(new_span); } else if(distance == -1) { //swap m_stack.pop_back(); - WordsRange new_span(input_span.GetStartPos(), prev_span.GetEndPos()); + Range new_span(input_span.GetStartPos(), prev_span.GetEndPos()); Reduce(new_span); } else { // discontinuous m_stack.push_back(input_span); @@ -58,21 +58,21 @@ int ReorderingStack::ShiftReduce(WordsRange input_span) } // Method to reduce, if possible the spans -void ReorderingStack::Reduce(WordsRange current) +void ReorderingStack::Reduce(Range current) { bool cont_loop = true; while (cont_loop && m_stack.size() > 0) { - WordsRange previous = m_stack.back(); + Range previous = m_stack.back(); if(current.GetStartPos() - previous.GetEndPos() == 1) { //mono&merge m_stack.pop_back(); - WordsRange t(previous.GetStartPos(), current.GetEndPos()); + Range t(previous.GetStartPos(), current.GetEndPos()); current = t; } else if(previous.GetStartPos() - current.GetEndPos() == 1) { //swap&merge m_stack.pop_back(); - WordsRange t(current.GetStartPos(), previous.GetEndPos()); + Range t(current.GetStartPos(), previous.GetEndPos()); current = t; } else { // discontinuous, no more merging cont_loop=false; diff --git a/moses/FF/LexicalReordering/ReorderingStack.h b/moses/FF/LexicalReordering/ReorderingStack.h index 47fe8b055..4213a6792 100644 --- a/moses/FF/LexicalReordering/ReorderingStack.h +++ b/moses/FF/LexicalReordering/ReorderingStack.h @@ -12,7 +12,7 @@ //#include "Phrase.h" //#include "TypeDef.h" //#include "Util.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" namespace Moses { @@ -23,17 +23,17 @@ class ReorderingStack { private: - std::vector m_stack; + std::vector m_stack; public: size_t hash() const; bool operator==(const ReorderingStack& other) const; - int ShiftReduce(WordsRange input_span); + int ShiftReduce(Range input_span); private: - void Reduce(WordsRange input_span); + void Reduce(Range input_span); }; diff --git a/moses/FF/LexicalReordering/SparseReordering.cpp b/moses/FF/LexicalReordering/SparseReordering.cpp index f8416a284..1d102300e 100644 --- a/moses/FF/LexicalReordering/SparseReordering.cpp +++ b/moses/FF/LexicalReordering/SparseReordering.cpp @@ -237,9 +237,9 @@ void SparseReordering::CopyScores( //NB: Using a static cast for speed, but could be nasty if //using non-sentence input const Sentence& sentence = static_cast(input); - const WordsRange& currentRange = currentOpt.GetSourceWordsRange(); + const Range& currentRange = currentOpt.GetSourceWordsRange(); if (previousOpt) { - const WordsRange& previousRange = previousOpt->GetSourceWordsRange(); + const Range& previousRange = previousOpt->GetSourceWordsRange(); if (previousRange < currentRange) { gapStart = previousRange.GetEndPos() + 1; gapEnd = currentRange.GetStartPos(); diff --git a/moses/FF/MaxSpanFreeNonTermSource.cpp b/moses/FF/MaxSpanFreeNonTermSource.cpp index 7799c0b2a..2e0d6fa4d 100644 --- a/moses/FF/MaxSpanFreeNonTermSource.cpp +++ b/moses/FF/MaxSpanFreeNonTermSource.cpp @@ -5,7 +5,7 @@ #include "moses/InputPath.h" #include "moses/TargetPhrase.h" #include "moses/StackVec.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/ChartCellLabel.h" #include "moses/FactorCollection.h" diff --git a/moses/FF/NieceTerminal.cpp b/moses/FF/NieceTerminal.cpp index a467ce2b1..c1e454124 100644 --- a/moses/FF/NieceTerminal.cpp +++ b/moses/FF/NieceTerminal.cpp @@ -54,7 +54,7 @@ void NieceTerminal::EvaluateWithSourceContext(const InputType &input for (size_t i = 0; i < stackVec->size(); ++i) { const ChartCellLabel &cell = *stackVec->at(i); - const WordsRange &ntRange = cell.GetCoverage(); + const Range &ntRange = cell.GetCoverage(); bool containTerm = ContainTerm(input, ntRange, terms); if (containTerm) { @@ -79,7 +79,7 @@ void NieceTerminal::EvaluateWhenApplied(const ChartHypothesis &hypo, {} bool NieceTerminal::ContainTerm(const InputType &input, - const WordsRange &ntRange, + const Range &ntRange, const boost::unordered_set &terms) const { boost::unordered_set::const_iterator iter; diff --git a/moses/FF/NieceTerminal.h b/moses/FF/NieceTerminal.h index 008e34212..1b1c0df80 100644 --- a/moses/FF/NieceTerminal.h +++ b/moses/FF/NieceTerminal.h @@ -6,7 +6,7 @@ namespace Moses { -class WordsRange; +class Range; class Word; // 1 of the non-term covers the same word as 1 of the terminals @@ -45,7 +45,7 @@ public: protected: bool m_hardConstraint; bool ContainTerm(const InputType &input, - const WordsRange &ntRange, + const Range &ntRange, const boost::unordered_set &terms) const; }; diff --git a/moses/FF/OSM-Feature/OpSequenceModel.cpp b/moses/FF/OSM-Feature/OpSequenceModel.cpp index d069e3e1f..db62c45bf 100644 --- a/moses/FF/OSM-Feature/OpSequenceModel.cpp +++ b/moses/FF/OSM-Feature/OpSequenceModel.cpp @@ -120,7 +120,7 @@ FFState* OpSequenceModel::EvaluateWhenApplied( //const Sentence &sentence = static_cast(curr_hypo.GetManager().GetSource()); - const WordsRange & sourceRange = cur_hypo.GetCurrSourceWordsRange(); + const Range & sourceRange = cur_hypo.GetCurrSourceWordsRange(); int startIndex = sourceRange.GetStartPos(); int endIndex = sourceRange.GetEndPos(); const AlignmentInfo &align = cur_hypo.GetCurrTargetPhrase().GetAlignTerm(); diff --git a/moses/FF/PhraseOrientationFeature.cpp b/moses/FF/PhraseOrientationFeature.cpp index f20663459..e88e80769 100644 --- a/moses/FF/PhraseOrientationFeature.cpp +++ b/moses/FF/PhraseOrientationFeature.cpp @@ -762,7 +762,7 @@ void PhraseOrientationFeature::SparseWordL2RScore(const ChartHypothesis* hypo, // source word - WordsRange sourceSpan = hypo->GetCurrSourceRange(); + Range sourceSpan = hypo->GetCurrSourceRange(); const InputType& input = hypo->GetManager().GetSource(); const Sentence& sourceSentence = static_cast(input); const Word& sourceWord = sourceSentence.GetWord(sourceSpan.GetStartPos()); @@ -821,7 +821,7 @@ void PhraseOrientationFeature::SparseWordR2LScore(const ChartHypothesis* hypo, // source word - WordsRange sourceSpan = hypo->GetCurrSourceRange(); + Range sourceSpan = hypo->GetCurrSourceRange(); const InputType& input = hypo->GetManager().GetSource(); const Sentence& sourceSentence = static_cast(input); const Word& sourceWord = sourceSentence.GetWord(sourceSpan.GetEndPos()); diff --git a/moses/FF/SoftSourceSyntacticConstraintsFeature.cpp b/moses/FF/SoftSourceSyntacticConstraintsFeature.cpp index f788f8e53..322e95ab2 100644 --- a/moses/FF/SoftSourceSyntacticConstraintsFeature.cpp +++ b/moses/FF/SoftSourceSyntacticConstraintsFeature.cpp @@ -297,7 +297,7 @@ void SoftSourceSyntacticConstraintsFeature::EvaluateWithSourceContext(const Inpu FEATUREVERBOSE(3, inputPath << std::endl); for (size_t i = 0; i < stackVec->size(); ++i) { const ChartCellLabel &cell = *stackVec->at(i); - const WordsRange &ntRange = cell.GetCoverage(); + const Range &ntRange = cell.GetCoverage(); FEATUREVERBOSE(3, "stackVec[ " << i << " ] : " << ntRange.GetStartPos() << " - " << ntRange.GetEndPos() << std::endl); } @@ -339,9 +339,9 @@ void SoftSourceSyntacticConstraintsFeature::EvaluateWithSourceContext(const Inpu boost::unordered_set treeInputLabelsLHS; // get index map for underlying hypotheses - const WordsRange& wordsRange = inputPath.GetWordsRange(); - size_t startPos = wordsRange.GetStartPos(); - size_t endPos = wordsRange.GetEndPos(); + const Range& range = inputPath.GetWordsRange(); + size_t startPos = range.GetStartPos(); + size_t endPos = range.GetEndPos(); const Phrase *sourcePhrase = targetPhrase.GetRuleSource(); if (nNTs > 1) { // rule has right-hand side non-terminals, i.e. it's a hierarchical rule @@ -356,7 +356,7 @@ void SoftSourceSyntacticConstraintsFeature::EvaluateWithSourceContext(const Inpu if ( word.IsNonTerminal() ) { // retrieve information that is required for input tree label matching (RHS) const ChartCellLabel &cell = *stackVec->at(nonTerminalNumber); - const WordsRange& prevWordsRange = cell.GetCoverage(); + const Range& prevWordsRange = cell.GetCoverage(); symbolStartPos = prevWordsRange.GetStartPos(); symbolEndPos = prevWordsRange.GetEndPos(); } diff --git a/moses/FF/SourceGHKMTreeInputMatchFeature.cpp b/moses/FF/SourceGHKMTreeInputMatchFeature.cpp index d33cbf94a..9dae34ca2 100644 --- a/moses/FF/SourceGHKMTreeInputMatchFeature.cpp +++ b/moses/FF/SourceGHKMTreeInputMatchFeature.cpp @@ -39,9 +39,9 @@ void SourceGHKMTreeInputMatchFeature::EvaluateWithSourceContext(const InputType , ScoreComponentCollection &scoreBreakdown , ScoreComponentCollection *estimatedFutureScore) const { - const WordsRange& wordsRange = inputPath.GetWordsRange(); - size_t startPos = wordsRange.GetStartPos(); - size_t endPos = wordsRange.GetEndPos(); + const Range& range = inputPath.GetWordsRange(); + size_t startPos = range.GetStartPos(); + size_t endPos = range.GetEndPos(); const TreeInput& treeInput = static_cast(input); const NonTerminalSet& treeInputLabels = treeInput.GetLabelSet(startPos,endPos); const Word& lhsLabel = targetPhrase.GetTargetLHS(); diff --git a/moses/FF/SpanLength.cpp b/moses/FF/SpanLength.cpp index 91ac3ff89..afd15771b 100644 --- a/moses/FF/SpanLength.cpp +++ b/moses/FF/SpanLength.cpp @@ -3,7 +3,7 @@ #include "moses/StaticData.h" #include "moses/Word.h" #include "moses/ChartCellLabel.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/StackVec.h" #include "moses/TargetPhrase.h" #include "moses/PP/PhraseProperty.h" @@ -50,7 +50,7 @@ void SpanLength::EvaluateWithSourceContext(const InputType &input float score = 0; for (size_t i = 0; i < stackVec->size(); ++i) { const ChartCellLabel &cell = *stackVec->at(i); - const WordsRange &ntRange = cell.GetCoverage(); + const Range &ntRange = cell.GetCoverage(); size_t sourceWidth = ntRange.GetNumWordsCovered(); float prob = slProp->GetProb(i, sourceWidth, m_const); score += TransformScore(prob); diff --git a/moses/FF/SparseHieroReorderingFeature.cpp b/moses/FF/SparseHieroReorderingFeature.cpp index 14befa56f..df689b807 100644 --- a/moses/FF/SparseHieroReorderingFeature.cpp +++ b/moses/FF/SparseHieroReorderingFeature.cpp @@ -112,7 +112,7 @@ void SparseHieroReorderingFeature::EvaluateWhenApplied( size_t sourceStart = cur_hypo.GetCurrSourceRange().GetStartPos(); size_t sourceSize = cur_hypo.GetCurrSourceRange().GetNumWordsCovered(); - vector sourceNTSpans; + vector sourceNTSpans; for (size_t prevHypoId = 0; prevHypoId < cur_hypo.GetPrevHypos().size(); ++prevHypoId) { sourceNTSpans.push_back(cur_hypo.GetPrevHypo(prevHypoId)->GetCurrSourceRange()); } @@ -122,21 +122,21 @@ void SparseHieroReorderingFeature::EvaluateWhenApplied( //for (size_t i = 0; i < sourceNTSpans.size(); ++i) cerr << sourceNTSpans[i] << " "; //cerr << endl; - typedef pair Block;//flag indicates NT + typedef pair Block;//flag indicates NT vector sourceBlocks; sourceBlocks.push_back(Block(cur_hypo.GetCurrSourceRange(),false)); - for (vector::const_iterator i = sourceNTSpans.begin(); + for (vector::const_iterator i = sourceNTSpans.begin(); i != sourceNTSpans.end(); ++i) { - const WordsRange& prevHypoRange = *i; + const Range& prevHypoRange = *i; Block lastBlock = sourceBlocks.back(); sourceBlocks.pop_back(); //split this range into before NT, NT and after NT if (prevHypoRange.GetStartPos() > lastBlock.first.GetStartPos()) { - sourceBlocks.push_back(Block(WordsRange(lastBlock.first.GetStartPos(),prevHypoRange.GetStartPos()-1),false)); + sourceBlocks.push_back(Block(Range(lastBlock.first.GetStartPos(),prevHypoRange.GetStartPos()-1),false)); } sourceBlocks.push_back(Block(prevHypoRange,true)); if (prevHypoRange.GetEndPos() < lastBlock.first.GetEndPos()) { - sourceBlocks.push_back(Block(WordsRange(prevHypoRange.GetEndPos()+1,lastBlock.first.GetEndPos()), false)); + sourceBlocks.push_back(Block(Range(prevHypoRange.GetEndPos()+1,lastBlock.first.GetEndPos()), false)); } } /* diff --git a/moses/FF/SparseHieroReorderingFeature.h b/moses/FF/SparseHieroReorderingFeature.h index 132af58b1..1ea852c41 100644 --- a/moses/FF/SparseHieroReorderingFeature.h +++ b/moses/FF/SparseHieroReorderingFeature.h @@ -60,7 +60,7 @@ private: typedef boost::unordered_set Vocab; void AddNonTerminalPairFeatures( - const Sentence& sentence, const WordsRange& nt1, const WordsRange& nt2, + const Sentence& sentence, const Range& nt1, const Range& nt2, bool isMonotone, ScoreComponentCollection* accumulator) const; void LoadVocabulary(const std::string& filename, Vocab& vocab); diff --git a/moses/FF/TargetNgramFeature.h b/moses/FF/TargetNgramFeature.h index 571f6d921..d09618d14 100644 --- a/moses/FF/TargetNgramFeature.h +++ b/moses/FF/TargetNgramFeature.h @@ -132,7 +132,7 @@ public: :m_contextPrefix(order - 1), m_contextSuffix(order - 1) { m_numTargetTerminals = hypo.GetCurrTargetPhrase().GetNumTerminals(); - const WordsRange range = hypo.GetCurrSourceRange(); + const Range range = hypo.GetCurrSourceRange(); m_startPos = range.GetStartPos(); m_endPos = range.GetEndPos(); m_inputSize = hypo.GetManager().GetSource().GetSize(); diff --git a/moses/FF/UnknownWordPenaltyProducer.h b/moses/FF/UnknownWordPenaltyProducer.h index bef6bd58c..40233cb56 100644 --- a/moses/FF/UnknownWordPenaltyProducer.h +++ b/moses/FF/UnknownWordPenaltyProducer.h @@ -7,7 +7,7 @@ namespace Moses { -class WordsRange; +class Range; /** unknown word penalty */ diff --git a/moses/ForestInput.cpp b/moses/ForestInput.cpp index c6d906fee..0be3a5eae 100644 --- a/moses/ForestInput.cpp +++ b/moses/ForestInput.cpp @@ -73,7 +73,7 @@ int ForestInput::Read(std::istream &in, { Word symbol; symbol.CreateFromString(Input, factorOrder, "", false); - Syntax::PVertex pvertex(WordsRange(0, 0), symbol); + Syntax::PVertex pvertex(Range(0, 0), symbol); startSymbol = new Forest::Vertex(pvertex); m_forest->vertices.push_back(startSymbol); } @@ -83,7 +83,7 @@ int ForestInput::Read(std::istream &in, { Word symbol; symbol.CreateFromString(Input, factorOrder, "", false); - Syntax::PVertex pvertex(WordsRange(maxEnd+1, maxEnd+1), symbol); + Syntax::PVertex pvertex(Range(maxEnd+1, maxEnd+1), symbol); endSymbol = new Forest::Vertex(pvertex); m_forest->vertices.push_back(endSymbol); } @@ -92,7 +92,7 @@ int ForestInput::Read(std::istream &in, { Word symbol; symbol.CreateFromString(Input, factorOrder, "Q", true); - Syntax::PVertex pvertex(WordsRange(0, maxEnd+1), symbol); + Syntax::PVertex pvertex(Range(0, maxEnd+1), symbol); m_rootVertex = new Forest::Vertex(pvertex); m_forest->vertices.push_back(m_rootVertex); } @@ -189,7 +189,7 @@ void ForestInput::ParseHyperedgeLine( v = ParseVertex(*p, factorOrder); if (!v->pvertex.symbol.IsNonTerminal()) { // Egret does not give start/end for terminals. - v->pvertex.span = WordsRange(e->head->pvertex.span.GetStartPos(), + v->pvertex.span = Range(e->head->pvertex.span.GetStartPos(), e->head->pvertex.span.GetStartPos()); } e->tail.push_back(AddOrDeleteVertex(v)); @@ -211,7 +211,7 @@ Syntax::F2S::Forest::Vertex *ForestInput::ParseVertex( if (pos == std::string::npos) { symbol.CreateFromString(Input, factorOrder, s, false); // Create vertex: caller will fill in span. - WordsRange span(0, 0); + Range span(0, 0); return new Forest::Vertex(Syntax::PVertex(span, symbol)); } symbol.CreateFromString(Input, factorOrder, s.substr(0, pos), true); @@ -223,7 +223,7 @@ Syntax::F2S::Forest::Vertex *ForestInput::ParseVertex( s.substr(pos+1, s.size()-pos-2).CopyToString(&tmp); std::size_t end = std::atoi(tmp.c_str()); // Create vertex: offset span by 1 to allow for in first position. - WordsRange span(start+1, end+1); + Range span(start+1, end+1); return new Forest::Vertex(Syntax::PVertex(span, symbol)); } diff --git a/moses/Hypothesis.cpp b/moses/Hypothesis.cpp index c59a3a748..5c4292d6d 100644 --- a/moses/Hypothesis.cpp +++ b/moses/Hypothesis.cpp @@ -246,7 +246,7 @@ PrintHypothesis() const TRACE_ERR( "... "); } if (end>=0) { - WordsRange range(start, end); + Range range(start, end); TRACE_ERR( m_prevHypo->GetCurrTargetPhrase().GetSubString(range) << " "); } TRACE_ERR( ")"< 0 && phrase.GetSize() > 0) { - const WordsRange &sourceRange = edge.GetCurrSourceWordsRange(); + const Range &sourceRange = edge.GetCurrSourceWordsRange(); const int sourceStart = sourceRange.GetStartPos(); const int sourceEnd = sourceRange.GetEndPos(); out << "|" << sourceStart << "-" << sourceEnd; // enriched "-tt" @@ -604,8 +604,8 @@ Hypothesis:: OutputLocalWordAlignment(vector& dest) const { using namespace std; - WordsRange const& src = this->GetCurrSourceWordsRange(); - WordsRange const& trg = this->GetCurrTargetWordsRange(); + Range const& src = this->GetCurrSourceWordsRange(); + Range const& trg = this->GetCurrTargetWordsRange(); vector const* > a = this->GetCurrTargetPhrase().GetAlignTerm().GetSortedAlignments(); diff --git a/moses/Hypothesis.h b/moses/Hypothesis.h index 4c3cb2039..125aef530 100644 --- a/moses/Hypothesis.h +++ b/moses/Hypothesis.h @@ -49,7 +49,7 @@ namespace Moses class SquareMatrix; class StaticData; class TranslationOption; -class WordsRange; +class Range; class Hypothesis; class FFState; class StatelessFeatureFunction; @@ -74,8 +74,8 @@ protected: const Hypothesis* m_prevHypo; /*! backpointer to previous hypothesis (from which this one was created) */ const Bitmap &m_sourceCompleted; /*! keeps track of which words have been translated so far */ InputType const& m_sourceInput; - WordsRange m_currSourceWordsRange; /*! source word positions of the last phrase that was used to create this hypothesis */ - WordsRange m_currTargetWordsRange; /*! target word positions of the last phrase that was used to create this hypothesis */ + Range m_currSourceWordsRange; /*! source word positions of the last phrase that was used to create this hypothesis */ + Range m_currTargetWordsRange; /*! target word positions of the last phrase that was used to create this hypothesis */ bool m_wordDeleted; float m_totalScore; /*! score so far */ float m_futureScore; /*! estimated future cost to translate rest of sentence */ @@ -108,11 +108,11 @@ public: const TargetPhrase &GetCurrTargetPhrase() const; /** return input positions covered by the translation option (phrasal translation) used to create this hypothesis */ - inline const WordsRange &GetCurrSourceWordsRange() const { + inline const Range &GetCurrSourceWordsRange() const { return m_currSourceWordsRange; } - inline const WordsRange &GetCurrTargetWordsRange() const { + inline const Range &GetCurrTargetWordsRange() const { return m_currTargetWordsRange; } diff --git a/moses/HypothesisStackCubePruning.cpp b/moses/HypothesisStackCubePruning.cpp index 12bf5a732..7e6f47507 100644 --- a/moses/HypothesisStackCubePruning.cpp +++ b/moses/HypothesisStackCubePruning.cpp @@ -250,7 +250,7 @@ void HypothesisStackCubePruning::CleanupArcList() void HypothesisStackCubePruning::SetBitmapAccessor(const Bitmap &newBitmap , HypothesisStackCubePruning &stack - , const WordsRange &/*range*/ + , const Range &/*range*/ , BitmapContainer &bitmapContainer , const SquareMatrix &futureScore , const TranslationOptionList &transOptList) diff --git a/moses/HypothesisStackCubePruning.h b/moses/HypothesisStackCubePruning.h index 6965e77b5..e274a4293 100644 --- a/moses/HypothesisStackCubePruning.h +++ b/moses/HypothesisStackCubePruning.h @@ -121,7 +121,7 @@ public: void SetBitmapAccessor(const Bitmap &newBitmap , HypothesisStackCubePruning &stack - , const WordsRange &range + , const Range &range , BitmapContainer &bitmapContainer , const SquareMatrix &futureScore , const TranslationOptionList &transOptList); diff --git a/moses/IOWrapper.cpp b/moses/IOWrapper.cpp index 1c54ec619..62c753269 100644 --- a/moses/IOWrapper.cpp +++ b/moses/IOWrapper.cpp @@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "moses/TypeDef.h" #include "moses/Util.h" #include "moses/Hypothesis.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/TrellisPathList.h" #include "moses/StaticData.h" #include "moses/FeatureVector.h" diff --git a/moses/Incremental.cpp b/moses/Incremental.cpp index e0a994ca0..407cf0f9d 100644 --- a/moses/Incremental.cpp +++ b/moses/Incremental.cpp @@ -81,9 +81,9 @@ public: Fill(search::Context &context, const std::vector &vocab_mapping, search::Score oov_weight) : context_(context), vocab_mapping_(vocab_mapping), oov_weight_(oov_weight) {} - void Add(const TargetPhraseCollection &targets, const StackVec &nts, const WordsRange &ignored); + void Add(const TargetPhraseCollection &targets, const StackVec &nts, const Range &ignored); - void AddPhraseOOV(TargetPhrase &phrase, std::list &waste_memory, const WordsRange &range); + void AddPhraseOOV(TargetPhrase &phrase, std::list &waste_memory, const Range &range); float GetBestScore(const ChartCellLabel *chartCell) const; @@ -119,7 +119,7 @@ private: const search::Score oov_weight_; }; -template void Fill::Add(const TargetPhraseCollection &targets, const StackVec &nts, const WordsRange &range) +template void Fill::Add(const TargetPhraseCollection &targets, const StackVec &nts, const Range &range) { std::vector vertices; vertices.reserve(nts.size()); @@ -160,7 +160,7 @@ template void Fill::Add(const TargetPhraseCollection &targe } } -template void Fill::AddPhraseOOV(TargetPhrase &phrase, std::list &, const WordsRange &range) +template void Fill::AddPhraseOOV(TargetPhrase &phrase, std::list &, const Range &range) { std::vector words; UTIL_THROW_IF2(phrase.GetSize() > 1, @@ -245,14 +245,14 @@ PopulateBest(const Model &model, const std::vector &words, Best & if (startPos == 0 && startPos + width == size) { break; } - WordsRange range(startPos, startPos + width - 1); + Range range(startPos, startPos + width - 1); Fill filler(context, words, oov_weight); parser_.Create(range, filler); filler.Search(out, cells_.MutableBase(range).MutableTargetLabelSet(), vertex_pool); } } - WordsRange range(0, size - 1); + Range range(0, size - 1); Fill filler(context, words, oov_weight); parser_.Create(range, filler); return filler.RootSearch(out); @@ -420,7 +420,7 @@ void Manager::ReconstructApplicationContext(const search::Applied *applied, ApplicationContext &context) const { context.clear(); - const WordsRange &span = applied->GetRange(); + const Range &span = applied->GetRange(); const search::Applied *child = applied->Children(); size_t i = span.GetStartPos(); size_t j = 0; @@ -429,12 +429,12 @@ void Manager::ReconstructApplicationContext(const search::Applied *applied, if (j == applied->GetArity() || i < child->GetRange().GetStartPos()) { // Symbol is a terminal. const Word &symbol = sentence.GetWord(i); - context.push_back(std::make_pair(symbol, WordsRange(i, i))); + context.push_back(std::make_pair(symbol, Range(i, i))); ++i; } else { // Symbol is a non-terminal. const Word &symbol = static_cast(child->GetNote().vp)->GetTargetLHS(); - const WordsRange &range = child->GetRange(); + const Range &range = child->GetRange(); context.push_back(std::make_pair(symbol, range)); i = range.GetEndPos()+1; ++child; diff --git a/moses/InputPath.cpp b/moses/InputPath.cpp index b57d70704..4368e6b8e 100644 --- a/moses/InputPath.cpp +++ b/moses/InputPath.cpp @@ -14,7 +14,7 @@ InputPath:: InputPath(ttaskwptr const theTask, Phrase const& phrase, NonTerminalSet const& sourceNonTerms, - WordsRange const& range, InputPath const *prevNode, + Range const& range, InputPath const *prevNode, const ScorePair *inputScore) : ttask(theTask) , m_prevPath(prevNode) diff --git a/moses/InputPath.h b/moses/InputPath.h index 84dd22a26..3a1f5e435 100644 --- a/moses/InputPath.h +++ b/moses/InputPath.h @@ -5,7 +5,7 @@ #include #include #include "Phrase.h" -#include "WordsRange.h" +#include "Range.h" #include "NonTerminal.h" #include "moses/FactorCollection.h" #include @@ -44,7 +44,7 @@ public: protected: const InputPath *m_prevPath; Phrase m_phrase; - WordsRange m_range; + Range m_range; const ScorePair *m_inputScore; size_t m_nextNode; // distance to next node. For lattices @@ -68,7 +68,7 @@ public: InputPath(ttaskwptr const ttask, Phrase const& phrase, NonTerminalSet const& sourceNonTerms, - WordsRange const& range, + Range const& range, InputPath const* prevNode, ScorePair const* inputScore); @@ -83,7 +83,7 @@ public: const std::vector &GetNonTerminalArray() const { return m_sourceNonTermArray; } - const WordsRange &GetWordsRange() const { + const Range &GetWordsRange() const { return m_range; } const Word &GetLastWord() const; diff --git a/moses/InputType.cpp b/moses/InputType.cpp index d01fdd46e..db269ea8b 100644 --- a/moses/InputType.cpp +++ b/moses/InputType.cpp @@ -47,7 +47,7 @@ std::ostream& operator<<(std::ostream& out,InputType const& x) } // default implementation is one column equals one word -int InputType::ComputeDistortionDistance(const WordsRange& prev, const WordsRange& current) const +int InputType::ComputeDistortionDistance(const Range& prev, const Range& current) const { int dist = 0; if (prev.GetNumWordsCovered() == 0) { diff --git a/moses/InputType.h b/moses/InputType.h index f75c65a0f..af0a73b0c 100644 --- a/moses/InputType.h +++ b/moses/InputType.h @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "TargetPhraseCollection.h" #include "ReorderingConstraint.h" #include "NonTerminal.h" -#include "WordsRange.h" +#include "Range.h" namespace Moses { @@ -133,18 +133,18 @@ public: m_passthrough = passthrough; } //! returns the number of words moved - virtual int ComputeDistortionDistance(const WordsRange& prev, const WordsRange& current) const; + virtual int ComputeDistortionDistance(const Range& prev, const Range& current) const; //! In a word lattice, tells you if there's a path from node start to node end virtual bool CanIGetFromAToB(size_t start, size_t end) const; //! is there a path covering [range] (lattice only, otherwise true) - inline bool IsCoveragePossible(const WordsRange& range) const { + inline bool IsCoveragePossible(const Range& range) const { return CanIGetFromAToB(range.GetStartPos(), range.GetEndPos() + 1); } //! In a word lattice, you can't always get from node A to node B - inline bool IsExtensionPossible(const WordsRange& prev, const WordsRange& current) const { + inline bool IsExtensionPossible(const Range& prev, const Range& current) const { // return ComputeDistortionDistance(prev, current) < 100000; size_t t = prev.GetEndPos()+1; // 2 size_t l = current.GetEndPos()+1; //l=1 @@ -194,7 +194,7 @@ public: CreateTranslationOptionCollection(ttasksptr const& ttask) const=0; //! return substring. Only valid for Sentence class. TODO - get rid of this fn - virtual Phrase GetSubString(const WordsRange&) const =0; + virtual Phrase GetSubString(const Range&) const =0; //! return substring at a particular position. Only valid for Sentence class. TODO - get rid of this fn virtual const Word& GetWord(size_t pos) const=0; diff --git a/moses/LM/BilingualLM.cpp b/moses/LM/BilingualLM.cpp index ad6dbf3d3..4cd0a91f4 100644 --- a/moses/LM/BilingualLM.cpp +++ b/moses/LM/BilingualLM.cpp @@ -108,7 +108,7 @@ void BilingualLM::getSourceWords( const TargetPhrase &targetPhrase, int targetWordIdx, const Sentence &source_sent, - const WordsRange &sourceWordRange, + const Range &sourceWordRange, std::vector &words) const { //Get source context @@ -220,7 +220,7 @@ FFState* BilingualLM::EvaluateWhenApplied( float value = 0; const TargetPhrase& currTargetPhrase = cur_hypo.GetCurrTargetPhrase(); - const WordsRange& sourceWordRange = cur_hypo.GetCurrSourceWordsRange(); //Source words range to calculate offsets + const Range& sourceWordRange = cur_hypo.GetCurrSourceWordsRange(); //Source words range to calculate offsets // For each word in the current target phrase get its LM score. for (int i = 0; i < currTargetPhrase.GetSize(); i++) { diff --git a/moses/LM/BilingualLM.h b/moses/LM/BilingualLM.h index 15de9d044..6d53db7e3 100644 --- a/moses/LM/BilingualLM.h +++ b/moses/LM/BilingualLM.h @@ -64,7 +64,7 @@ private: const TargetPhrase &targetPhrase, int targetWordIdx, const Sentence &source_sent, - const WordsRange &sourceWordRange, + const Range &sourceWordRange, std::vector &words) const; void appendSourceWordsToVector(const Sentence &source_sent, std::vector &words, int source_word_mid_idx) const; diff --git a/moses/Manager.cpp b/moses/Manager.cpp index 8112193ef..71b384fd1 100644 --- a/moses/Manager.cpp +++ b/moses/Manager.cpp @@ -1676,8 +1676,8 @@ void Manager::OutputNBest(std::ostream& out out << " |||"; for (int currEdge = (int)edges.size() - 2 ; currEdge >= 0 ; currEdge--) { const Hypothesis &edge = *edges[currEdge]; - const WordsRange &sourceRange = edge.GetCurrSourceWordsRange(); - WordsRange targetRange = path.GetTargetWordsRange(edge); + const Range &sourceRange = edge.GetCurrSourceWordsRange(); + Range targetRange = path.GetTargetWordsRange(edge); out << " " << sourceRange.GetStartPos(); if (sourceRange.GetStartPos() < sourceRange.GetEndPos()) { out << "-" << sourceRange.GetEndPos(); @@ -1693,8 +1693,8 @@ void Manager::OutputNBest(std::ostream& out out << " ||| "; for (int currEdge = (int)edges.size() - 2 ; currEdge >= 0 ; currEdge--) { const Hypothesis &edge = *edges[currEdge]; - const WordsRange &sourceRange = edge.GetCurrSourceWordsRange(); - WordsRange targetRange = path.GetTargetWordsRange(edge); + const Range &sourceRange = edge.GetCurrSourceWordsRange(); + Range targetRange = path.GetTargetWordsRange(edge); const int sourceOffset = sourceRange.GetStartPos(); const int targetOffset = targetRange.GetStartPos(); const AlignmentInfo &ai = edge.GetCurrTargetPhrase().GetAlignTerm(); @@ -1775,7 +1775,7 @@ void Manager::OutputSurface(std::ostream &out, const Hypothesis &edge, const std // trace ("report segmentation") option "-t" / "-tt" if (reportSegmentation > 0 && phrase.GetSize() > 0) { - const WordsRange &sourceRange = edge.GetCurrSourceWordsRange(); + const Range &sourceRange = edge.GetCurrSourceWordsRange(); const int sourceStart = sourceRange.GetStartPos(); const int sourceEnd = sourceRange.GetEndPos(); out << "|" << sourceStart << "-" << sourceEnd; // enriched "-tt" diff --git a/moses/MockHypothesis.cpp b/moses/MockHypothesis.cpp index 1ec3690a0..11c5d0f84 100644 --- a/moses/MockHypothesis.cpp +++ b/moses/MockHypothesis.cpp @@ -55,14 +55,14 @@ MockHypothesisGuard vector::const_iterator ti = targetSegments.begin(); for (; ti != targetSegments.end() && ai != alignments.end(); ++ti,++ai) { Hypothesis* prevHypo = m_hypothesis; - WordsRange wordsRange(ai->first,ai->second); - const Bitmap &newBitmap = bitmaps.GetBitmap(prevHypo->GetWordsBitmap(), wordsRange); + Range range(ai->first,ai->second); + const Bitmap &newBitmap = bitmaps.GetBitmap(prevHypo->GetWordsBitmap(), range); m_targetPhrases.push_back(TargetPhrase(NULL)); // m_targetPhrases.back().CreateFromString(Input, factors, *ti, "|", NULL); m_targetPhrases.back().CreateFromString(Input, factors, *ti, NULL); m_toptions.push_back(new TranslationOption - (wordsRange,m_targetPhrases.back())); + (range,m_targetPhrases.back())); m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), newBitmap); } diff --git a/moses/Phrase.cpp b/moses/Phrase.cpp index 7ab3464df..a76d3e480 100644 --- a/moses/Phrase.cpp +++ b/moses/Phrase.cpp @@ -89,11 +89,11 @@ void Phrase::MergeFactors(const Phrase ©, const std::vector& fac } -Phrase Phrase::GetSubString(const WordsRange &wordsRange) const +Phrase Phrase::GetSubString(const Range &range) const { - Phrase retPhrase(wordsRange.GetNumWordsCovered()); + Phrase retPhrase(range.GetNumWordsCovered()); - for (size_t currPos = wordsRange.GetStartPos() ; currPos <= wordsRange.GetEndPos() ; currPos++) { + for (size_t currPos = range.GetStartPos() ; currPos <= range.GetEndPos() ; currPos++) { Word &word = retPhrase.AddWord(); word = GetWord(currPos); } @@ -101,11 +101,11 @@ Phrase Phrase::GetSubString(const WordsRange &wordsRange) const return retPhrase; } -Phrase Phrase::GetSubString(const WordsRange &wordsRange, FactorType factorType) const +Phrase Phrase::GetSubString(const Range &range, FactorType factorType) const { - Phrase retPhrase(wordsRange.GetNumWordsCovered()); + Phrase retPhrase(range.GetNumWordsCovered()); - for (size_t currPos = wordsRange.GetStartPos() ; currPos <= wordsRange.GetEndPos() ; currPos++) { + for (size_t currPos = range.GetStartPos() ; currPos <= range.GetEndPos() ; currPos++) { const Factor* f = GetFactor(currPos, factorType); Word &word = retPhrase.AddWord(); word.SetFactor(factorType, f); diff --git a/moses/Phrase.h b/moses/Phrase.h index e92d68ac4..e75c7afc0 100644 --- a/moses/Phrase.h +++ b/moses/Phrase.h @@ -39,7 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA namespace Moses { class FactorMask; -class WordsRange; +class Range; /** Representation of a phrase, ie. a contiguous number of words. * Wrapper for vector of words @@ -174,8 +174,8 @@ public: void InitStartEndWord(); //! create new phrase class that is a substring of this phrase - Phrase GetSubString(const WordsRange &wordsRange) const; - Phrase GetSubString(const WordsRange &wordsRange, FactorType factorType) const; + Phrase GetSubString(const Range &range) const; + Phrase GetSubString(const Range &range, FactorType factorType) const; //! return a string rep of the phrase. Each factor is separated by the factor delimiter as specified in StaticData class std::string GetStringRep(const std::vector factorsToPrint) const; diff --git a/moses/WordsRange.cpp b/moses/Range.cpp similarity index 89% rename from moses/WordsRange.cpp rename to moses/Range.cpp index f37a738c0..434f0fcb5 100644 --- a/moses/WordsRange.cpp +++ b/moses/Range.cpp @@ -17,14 +17,14 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ***********************************************************************/ -#include "WordsRange.h" +#include "Range.h" namespace Moses { -TO_STRING_BODY(WordsRange); +TO_STRING_BODY(Range); -std::ostream& operator << (std::ostream& out, const WordsRange& range) +std::ostream& operator << (std::ostream& out, const Range& range) { out << "[" << range.m_startPos << ".." << range.m_endPos << "]"; return out; diff --git a/moses/WordsRange.h b/moses/Range.h similarity index 82% rename from moses/WordsRange.h rename to moses/Range.h index 06f789989..52a201005 100644 --- a/moses/WordsRange.h +++ b/moses/Range.h @@ -38,15 +38,15 @@ namespace Moses /*** * Efficient version of Bitmap for contiguous ranges */ -class WordsRange +class Range { - friend std::ostream& operator << (std::ostream& out, const WordsRange& range); + friend std::ostream& operator << (std::ostream& out, const Range& range); // m_endPos is inclusive size_t m_startPos, m_endPos; public: - inline WordsRange(size_t startPos, size_t endPos) : m_startPos(startPos), m_endPos(endPos) {} - inline WordsRange(const WordsRange ©) + inline Range(size_t startPos, size_t endPos) : m_startPos(startPos), m_endPos(endPos) {} + inline Range(const Range ©) : m_startPos(copy.GetStartPos()) , m_endPos(copy.GetEndPos()) { } @@ -64,24 +64,24 @@ public: } //! transitive comparison - inline bool operator<(const WordsRange& x) const { + inline bool operator<(const Range& x) const { return (m_startPos m_endPos) return false; return true; } - inline size_t GetNumWordsBetween(const WordsRange& x) const { + inline size_t GetNumWordsBetween(const Range& x) const { UTIL_THROW_IF2(Overlap(x), "Overlapping ranges"); if (x.m_endPos < m_startPos) { @@ -95,7 +95,7 @@ public: TO_STRING(); }; -inline size_t hash_value(const WordsRange& range) +inline size_t hash_value(const Range& range) { size_t seed = range.GetStartPos(); boost::hash_combine(seed, range.GetEndPos()); diff --git a/moses/RuleCube.cpp b/moses/RuleCube.cpp index 7ded39d54..f41591004 100644 --- a/moses/RuleCube.cpp +++ b/moses/RuleCube.cpp @@ -26,7 +26,7 @@ #include "RuleCubeQueue.h" #include "StaticData.h" #include "Util.h" -#include "WordsRange.h" +#include "Range.h" #include diff --git a/moses/RuleCubeItem.cpp b/moses/RuleCubeItem.cpp index 970bac94d..976783d65 100644 --- a/moses/RuleCubeItem.cpp +++ b/moses/RuleCubeItem.cpp @@ -23,7 +23,7 @@ #include "ChartManager.h" #include "RuleCubeItem.h" #include "RuleCubeQueue.h" -#include "WordsRange.h" +#include "Range.h" #include "Util.h" #include "util/exception.hh" diff --git a/moses/SearchCubePruning.cpp b/moses/SearchCubePruning.cpp index a0fcfb490..e99a22004 100644 --- a/moses/SearchCubePruning.cpp +++ b/moses/SearchCubePruning.cpp @@ -200,7 +200,7 @@ void SearchCubePruning::CreateForwardTodos(HypothesisStackCubePruning &stack) continue; // not yet covered - WordsRange applyRange(startPos, startPos); + Range applyRange(startPos, startPos); if (CheckDistortion(bitmap, applyRange)) { // apply range CreateForwardTodos(bitmap, applyRange, bitmapContainer); @@ -213,7 +213,7 @@ void SearchCubePruning::CreateForwardTodos(HypothesisStackCubePruning &stack) if (bitmap.GetValue(endPos)) break; - WordsRange applyRange(startPos, endPos); + Range applyRange(startPos, endPos); if (CheckDistortion(bitmap, applyRange)) { // apply range CreateForwardTodos(bitmap, applyRange, bitmapContainer); @@ -225,7 +225,7 @@ void SearchCubePruning::CreateForwardTodos(HypothesisStackCubePruning &stack) void SearchCubePruning:: -CreateForwardTodos(Bitmap const& bitmap, WordsRange const& range, +CreateForwardTodos(Bitmap const& bitmap, Range const& range, BitmapContainer& bitmapContainer) { Bitmap newBitmap = bitmap; @@ -246,7 +246,7 @@ CreateForwardTodos(Bitmap const& bitmap, WordsRange const& range, bool SearchCubePruning:: -CheckDistortion(const Bitmap &hypoBitmap, const WordsRange &range) const +CheckDistortion(const Bitmap &hypoBitmap, const Range &range) const { // since we check for reordering limits, its good to have that limit handy int maxDistortion = m_manager.options().reordering.max_distortion; @@ -274,7 +274,7 @@ CheckDistortion(const Bitmap &hypoBitmap, const WordsRange &range) const // its maximum value will be (which will always be the value of the // hypothesis starting at the left-most edge). If this vlaue is than // the distortion limit, we don't allow this extension to be made. - WordsRange bestNextExtension(hypoFirstGapPos, hypoFirstGapPos); + Range bestNextExtension(hypoFirstGapPos, hypoFirstGapPos); return (m_source.ComputeDistortionDistance(range, bestNextExtension) <= maxDistortion); } diff --git a/moses/SearchCubePruning.h b/moses/SearchCubePruning.h index 7adc185ec..f2854a7f2 100644 --- a/moses/SearchCubePruning.h +++ b/moses/SearchCubePruning.h @@ -27,8 +27,8 @@ protected: //! go thru all bitmaps in 1 stack & create backpointers to bitmaps in the stack void CreateForwardTodos(HypothesisStackCubePruning &stack); //! create a back pointer to this bitmap, with edge that has this words range translation - void CreateForwardTodos(const Bitmap &bitmap, const WordsRange &range, BitmapContainer &bitmapContainer); - bool CheckDistortion(const Bitmap &bitmap, const WordsRange &range) const; + void CreateForwardTodos(const Bitmap &bitmap, const Range &range, BitmapContainer &bitmapContainer); + bool CheckDistortion(const Bitmap &bitmap, const Range &range) const; void PrintBitmapContainerGraph(); diff --git a/moses/SearchNormal.cpp b/moses/SearchNormal.cpp index e36710dc6..f66491493 100644 --- a/moses/SearchNormal.cpp +++ b/moses/SearchNormal.cpp @@ -131,7 +131,7 @@ ProcessOneHypothesis(const Hypothesis &hypothesis) tol && endPos < sourceSize; tol = m_transOptColl.GetTranslationOptionList(startPos, ++endPos)) { if (tol->size() == 0 - || hypoBitmap.Overlap(WordsRange(startPos, endPos)) + || hypoBitmap.Overlap(Range(startPos, endPos)) || !ReoConstraint.Check(hypoBitmap, startPos, endPos)) { continue; } @@ -145,7 +145,7 @@ ProcessOneHypothesis(const Hypothesis &hypothesis) // There are reordering limits. Make sure they are not violated. - WordsRange prevRange = hypothesis.GetCurrSourceWordsRange(); + Range prevRange = hypothesis.GetCurrSourceWordsRange(); for (size_t startPos = hypoFirstGapPos ; startPos < sourceSize ; ++startPos) { // don't bother expanding phrases if the first position is already taken @@ -176,7 +176,7 @@ ProcessOneHypothesis(const Hypothesis &hypothesis) continue; } - WordsRange currentStartRange(startPos, startPos); + Range currentStartRange(startPos, startPos); if(m_source.ComputeDistortionDistance(prevRange, currentStartRange) > m_options.reordering.max_distortion) continue; @@ -186,7 +186,7 @@ ProcessOneHypothesis(const Hypothesis &hypothesis) for (tol = m_transOptColl.GetTranslationOptionList(startPos, endPos); tol && endPos < sourceSize; tol = m_transOptColl.GetTranslationOptionList(startPos, ++endPos)) { - WordsRange extRange(startPos, endPos); + Range extRange(startPos, endPos); if (tol->size() == 0 || hypoBitmap.Overlap(extRange) || !ReoConstraint.Check(hypoBitmap, startPos, endPos) @@ -224,7 +224,7 @@ ProcessOneHypothesis(const Hypothesis &hypothesis) // be (which will always be the value of the hypothesis starting // at the left-most edge). If this value is less than the // distortion limit, we don't allow this extension to be made. - WordsRange bestNextExtension(hypoFirstGapPos, hypoFirstGapPos); + Range bestNextExtension(hypoFirstGapPos, hypoFirstGapPos); if (m_source.ComputeDistortionDistance(extRange, bestNextExtension) > m_options.reordering.max_distortion) continue; @@ -270,7 +270,7 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos // Create new bitmap const TranslationOption &transOpt = **tol->begin(); - const WordsRange &nextRange = transOpt.GetSourceWordsRange(); + const Range &nextRange = transOpt.GetSourceWordsRange(); const Bitmap &nextBitmap = m_bitmaps.GetBitmap(sourceCompleted, nextRange); TranslationOptionList::const_iterator iter; diff --git a/moses/Sentence.cpp b/moses/Sentence.cpp index 77dd2fa95..c83699ae2 100644 --- a/moses/Sentence.cpp +++ b/moses/Sentence.cpp @@ -204,7 +204,7 @@ init(string line, std::vector const& factorOrder) if (SD.GetXmlInputType() != XmlPassThrough) { m_xmlCoverageMap.assign(GetSize(), false); BOOST_FOREACH(XmlOption* o, m_xmlOptions) { - WordsRange const& r = o->range; + Range const& r = o->range; for(size_t j = r.GetStartPos(); j <= r.GetEndPos(); ++j) m_xmlCoverageMap[j]=true; } @@ -215,7 +215,7 @@ init(string line, std::vector const& factorOrder) // set reordering walls, if "-monotone-at-punction" is set if (SD.UseReorderingConstraint() && GetSize()) { - WordsRange r(0, GetSize()-1); + Range r(0, GetSize()-1); m_reorderingConstraint.SetMonotoneAtPunctuation(GetSubString(r)); } @@ -289,7 +289,7 @@ void Sentence::GetXmlTranslationOptions(std::vector &list) for (std::vector::const_iterator iterXMLOpts = m_xmlOptions.begin(); iterXMLOpts != m_xmlOptions.end(); ++iterXMLOpts) { const XmlOption &xmlOption = **iterXMLOpts; - const WordsRange &range = xmlOption.range; + const Range &range = xmlOption.range; const TargetPhrase &targetPhrase = xmlOption.targetPhrase; TranslationOption *transOpt = new TranslationOption(range, targetPhrase); list.push_back(transOpt); @@ -303,7 +303,7 @@ void Sentence::GetXmlTranslationOptions(std::vector &list, for (std::vector::const_iterator iterXMLOpts = m_xmlOptions.begin(); iterXMLOpts != m_xmlOptions.end(); ++iterXMLOpts) { const XmlOption &xmlOption = **iterXMLOpts; - const WordsRange &range = xmlOption.range; + const Range &range = xmlOption.range; if (startPos == range.GetStartPos() && endPos == range.GetEndPos()) { @@ -338,7 +338,7 @@ std::vector Sentence::GetXmlChartTranslationOptions() const XmlOption &xmlOption = **iterXmlOpts; TargetPhrase *targetPhrase = new TargetPhrase(xmlOption.targetPhrase); - WordsRange *range = new WordsRange(xmlOption.range); + Range *range = new Range(xmlOption.range); StackVec emptyStackVec; // hmmm... maybe dangerous, but it is never consulted TargetPhraseCollection *tpc = new TargetPhraseCollection; diff --git a/moses/Sentence.h b/moses/Sentence.h index 661280711..755f13c99 100644 --- a/moses/Sentence.h +++ b/moses/Sentence.h @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA namespace Moses { -class WordsRange; +class Range; class PhraseDictionary; class TranslationOption; class TranslationOptionCollection; @@ -73,7 +73,7 @@ public: } //! Calls Phrase::GetSubString(). Implements abstract InputType::GetSubString() - Phrase GetSubString(const WordsRange& r) const { + Phrase GetSubString(const Range& r) const { return Phrase::GetSubString(r); } diff --git a/moses/Syntax/F2S/DerivationWriter.cpp b/moses/Syntax/F2S/DerivationWriter.cpp index efa3c3d47..390508a37 100644 --- a/moses/Syntax/F2S/DerivationWriter.cpp +++ b/moses/Syntax/F2S/DerivationWriter.cpp @@ -79,7 +79,7 @@ void DerivationWriter::WriteLine(const SHyperedge ­peredge, // Spans covered by source RHS symbols. for (std::size_t i = 0; i < shyperedge.tail.size(); ++i) { const SVertex *child = shyperedge.tail[i]; - const WordsRange &span = child->pvertex->span; + const Range &span = child->pvertex->span; out << " " << span.GetStartPos() << ".." << span.GetEndPos(); } diff --git a/moses/Syntax/F2S/HyperTreeLoader.cpp b/moses/Syntax/F2S/HyperTreeLoader.cpp index aefddbc2d..c23594c54 100644 --- a/moses/Syntax/F2S/HyperTreeLoader.cpp +++ b/moses/Syntax/F2S/HyperTreeLoader.cpp @@ -15,7 +15,7 @@ #include "moses/Util.h" #include "moses/InputFileStream.h" #include "moses/StaticData.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/ChartTranslationOptionList.h" #include "moses/FactorCollection.h" #include "moses/Syntax/RuleTableFF.h" diff --git a/moses/Syntax/PVertex.h b/moses/Syntax/PVertex.h index 8832128b4..23cfbdb5f 100644 --- a/moses/Syntax/PVertex.h +++ b/moses/Syntax/PVertex.h @@ -1,7 +1,7 @@ #pragma once #include "moses/Word.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" namespace Moses { @@ -10,9 +10,9 @@ namespace Syntax struct PVertex { public: - PVertex(const WordsRange &wr, const Word &w) : span(wr), symbol(w) {} + PVertex(const Range &wr, const Word &w) : span(wr), symbol(w) {} - WordsRange span; + Range span; Word symbol; }; diff --git a/moses/Syntax/S2T/DerivationWriter.cpp b/moses/Syntax/S2T/DerivationWriter.cpp index 33fb8d70b..159763a46 100644 --- a/moses/Syntax/S2T/DerivationWriter.cpp +++ b/moses/Syntax/S2T/DerivationWriter.cpp @@ -78,7 +78,7 @@ void DerivationWriter::WriteLine(const SHyperedge ­peredge, // Spans covered by source RHS symbols. for (std::size_t i = 0; i < shyperedge.tail.size(); ++i) { const SVertex *child = shyperedge.tail[i]; - const WordsRange &span = child->pvertex->span; + const Range &span = child->pvertex->span; out << " " << span.GetStartPos() << ".." << span.GetEndPos(); } diff --git a/moses/Syntax/S2T/Manager-inl.h b/moses/Syntax/S2T/Manager-inl.h index 422f14915..0dff7b846 100644 --- a/moses/Syntax/S2T/Manager-inl.h +++ b/moses/Syntax/S2T/Manager-inl.h @@ -45,7 +45,7 @@ void Manager::InitializeCharts() const Word &terminal = m_source.GetWord(i); // PVertex - PVertex tmp(WordsRange(i,i), terminal); + PVertex tmp(Range(i,i), terminal); PVertex &pvertex = m_pchart.AddVertex(tmp); // SVertex @@ -184,7 +184,7 @@ void Manager::Decode() //PChart::Cell &pcell = m_pchart.GetCell(start, end); SChart::Cell &scell = m_schart.GetCell(start, end); - WordsRange range(start, end); + Range range(start, end); // Call the parsers to generate PHyperedges for this span and convert // each one to a SHyperedgeBundle (via the callback). The callback diff --git a/moses/Syntax/S2T/ParserCallback.h b/moses/Syntax/S2T/ParserCallback.h index f9db51601..2314b27f3 100644 --- a/moses/Syntax/S2T/ParserCallback.h +++ b/moses/Syntax/S2T/ParserCallback.h @@ -31,7 +31,7 @@ public: m_container.SwapIn(m_tmpBundle, score); } - void InitForRange(const WordsRange &range) { + void InitForRange(const Range &range) { m_container.LazyClear(); } @@ -62,7 +62,7 @@ public: m_containers[end].SwapIn(m_tmpBundle, score); } - void InitForRange(const WordsRange &range) { + void InitForRange(const Range &range) { const std::size_t start = range.GetStartPos(); m_end = range.GetEndPos(); if (start != m_prevStart) { diff --git a/moses/Syntax/S2T/Parsers/Parser.h b/moses/Syntax/S2T/Parsers/Parser.h index 785fb66f9..c0f460a8f 100644 --- a/moses/Syntax/S2T/Parsers/Parser.h +++ b/moses/Syntax/S2T/Parsers/Parser.h @@ -20,7 +20,7 @@ public: virtual ~Parser() {} - virtual void EnumerateHyperedges(const WordsRange &, Callback &) = 0; + virtual void EnumerateHyperedges(const Range &, Callback &) = 0; protected: PChart &m_chart; }; diff --git a/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser-inl.h b/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser-inl.h index c8f57c4d1..c0201bded 100644 --- a/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser-inl.h +++ b/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser-inl.h @@ -24,7 +24,7 @@ RecursiveCYKPlusParser::RecursiveCYKPlusParser( template void RecursiveCYKPlusParser::EnumerateHyperedges( - const WordsRange &range, + const Range &range, Callback &callback) { const std::size_t start = range.GetStartPos(); diff --git a/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser.h b/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser.h index 2b8edbfd1..ce5272f15 100644 --- a/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser.h +++ b/moses/Syntax/S2T/Parsers/RecursiveCYKPlusParser/RecursiveCYKPlusParser.h @@ -4,7 +4,7 @@ #include "moses/Syntax/PVertex.h" #include "moses/Syntax/S2T/Parsers/Parser.h" #include "moses/Syntax/S2T/RuleTrieCYKPlus.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" namespace Moses { @@ -35,7 +35,7 @@ public: ~RecursiveCYKPlusParser() {} - void EnumerateHyperedges(const WordsRange &, Callback &); + void EnumerateHyperedges(const Range &, Callback &); private: diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/Parser-inl.h b/moses/Syntax/S2T/Parsers/Scope3Parser/Parser-inl.h index da81a5606..1225ec910 100644 --- a/moses/Syntax/S2T/Parsers/Scope3Parser/Parser-inl.h +++ b/moses/Syntax/S2T/Parsers/Scope3Parser/Parser-inl.h @@ -39,7 +39,7 @@ Scope3Parser::~Scope3Parser() template void Scope3Parser:: -EnumerateHyperedges(const WordsRange &range, Callback &callback) +EnumerateHyperedges(const Range &range, Callback &callback) { const std::size_t start = range.GetStartPos(); const std::size_t end = range.GetEndPos(); diff --git a/moses/Syntax/S2T/Parsers/Scope3Parser/Parser.h b/moses/Syntax/S2T/Parsers/Scope3Parser/Parser.h index df2989d62..fa7adc200 100644 --- a/moses/Syntax/S2T/Parsers/Scope3Parser/Parser.h +++ b/moses/Syntax/S2T/Parsers/Scope3Parser/Parser.h @@ -5,7 +5,7 @@ #include "moses/Syntax/S2T/Parsers/Parser.h" #include "moses/Syntax/S2T/RuleTrieScope3.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "PatternApplicationTrie.h" #include "SymbolRangeCalculator.h" @@ -41,7 +41,7 @@ public: ~Scope3Parser(); - void EnumerateHyperedges(const WordsRange &, Callback &); + void EnumerateHyperedges(const Range &, Callback &); private: void Init(); diff --git a/moses/Syntax/S2T/RuleTrieLoader.cpp b/moses/Syntax/S2T/RuleTrieLoader.cpp index 3ac266bdb..4e3799253 100644 --- a/moses/Syntax/S2T/RuleTrieLoader.cpp +++ b/moses/Syntax/S2T/RuleTrieLoader.cpp @@ -15,7 +15,7 @@ #include "moses/Util.h" #include "moses/InputFileStream.h" #include "moses/StaticData.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/ChartTranslationOptionList.h" #include "moses/FactorCollection.h" #include "moses/Syntax/RuleTableFF.h" diff --git a/moses/Syntax/T2S/InputTreeBuilder.cpp b/moses/Syntax/T2S/InputTreeBuilder.cpp index b72391f12..927c6b4e3 100644 --- a/moses/Syntax/T2S/InputTreeBuilder.cpp +++ b/moses/Syntax/T2S/InputTreeBuilder.cpp @@ -50,10 +50,10 @@ void InputTreeBuilder::CreateNodes(const TreeInput &in, p != xmlNodes.end(); ++p) { std::size_t start = p->m_range.GetStartPos(); std::size_t end = p->m_range.GetEndPos(); - nonTerms.push_back(XMLParseOutput(p->m_label, WordsRange(start+1, end+1))); + nonTerms.push_back(XMLParseOutput(p->m_label, Range(start+1, end+1))); } // Add a top-level node that also covers and . - nonTerms.push_back(XMLParseOutput(topLevelLabel, WordsRange(0, numWords-1))); + nonTerms.push_back(XMLParseOutput(topLevelLabel, Range(0, numWords-1))); // Allocate space for the InputTree nodes. In the case of out.nodes, this // step is essential because once created the PVertex objects must not be @@ -75,7 +75,7 @@ void InputTreeBuilder::CreateNodes(const TreeInput &in, // Add a node for each terminal to the left of or below the first // nonTerm child of the subtree. for (int i = prevEnd+1; i <= end; ++i) { - PVertex v(WordsRange(i, i), in.GetWord(i)); + PVertex v(Range(i, i), in.GetWord(i)); out.nodes.push_back(InputTree::Node(v)); out.nodesAtPos[i].push_back(&out.nodes.back()); } @@ -83,7 +83,7 @@ void InputTreeBuilder::CreateNodes(const TreeInput &in, // Add a node for the non-terminal. Word w(true); w.CreateFromString(Moses::Output, m_outputFactorOrder, p->m_label, true); - PVertex v(WordsRange(start, end), w); + PVertex v(Range(start, end), w); out.nodes.push_back(InputTree::Node(v)); out.nodesAtPos[start].push_back(&out.nodes.back()); diff --git a/moses/Syntax/T2S/RuleTrieLoader.cpp b/moses/Syntax/T2S/RuleTrieLoader.cpp index f0646b1f7..71d4b24d0 100644 --- a/moses/Syntax/T2S/RuleTrieLoader.cpp +++ b/moses/Syntax/T2S/RuleTrieLoader.cpp @@ -15,7 +15,7 @@ #include "moses/Util.h" #include "moses/InputFileStream.h" #include "moses/StaticData.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/ChartTranslationOptionList.h" #include "moses/FactorCollection.h" #include "moses/Syntax/RuleTableFF.h" diff --git a/moses/TranslationAnalysis.cpp b/moses/TranslationAnalysis.cpp index ebca957ce..631419023 100644 --- a/moses/TranslationAnalysis.cpp +++ b/moses/TranslationAnalysis.cpp @@ -46,8 +46,8 @@ void PrintTranslationAnalysis(std::ostream &os, const Hypothesis* hypo) util::StringStream tms; std::string target = (*tpi)->GetTargetPhraseStringRep(); std::string source = (*tpi)->GetSourcePhraseStringRep(); - WordsRange twr = (*tpi)->GetCurrTargetWordsRange(); - WordsRange swr = (*tpi)->GetCurrSourceWordsRange(); + Range twr = (*tpi)->GetCurrTargetWordsRange(); + Range swr = (*tpi)->GetCurrSourceWordsRange(); const AlignmentInfo &alignmentInfo = (*tpi)->GetCurrTargetPhrase().GetAlignTerm(); // language model backoff stats, if (doLMStats) { diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerCYKPlus.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerCYKPlus.cpp index e8d2f734a..ba29f2ae7 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerCYKPlus.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerCYKPlus.cpp @@ -33,7 +33,7 @@ namespace Moses void ChartRuleLookupManagerCYKPlus::AddCompletedRule( const DottedRule &dottedRule, const TargetPhraseCollection &tpc, - const WordsRange &range, + const Range &range, ChartParserCallback &outColl) { // Determine the rule's rank. diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerCYKPlus.h b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerCYKPlus.h index 02bea7b43..3179083db 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerCYKPlus.h +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerCYKPlus.h @@ -29,7 +29,7 @@ namespace Moses class DottedRule; class TargetPhraseCollection; -class WordsRange; +class Range; /** @todo what is this? */ @@ -44,7 +44,7 @@ protected: void AddCompletedRule( const DottedRule &dottedRule, const TargetPhraseCollection &tpc, - const WordsRange &range, + const Range &range, ChartParserCallback &outColl); StackVec m_stackVec; diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp index 61ec03892..55db20303 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp @@ -56,7 +56,7 @@ void ChartRuleLookupManagerMemory::GetChartRuleCollection( size_t lastPos, ChartParserCallback &outColl) { - const WordsRange &range = inputPath.GetWordsRange(); + const Range &range = inputPath.GetWordsRange(); size_t startPos = range.GetStartPos(); size_t absEndPos = range.GetEndPos(); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h index c8e2db2d7..e564afba2 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h @@ -32,7 +32,7 @@ namespace Moses { class ChartParserCallback; -class WordsRange; +class Range; //! Implementation of ChartRuleLookupManager for in-memory rule tables. class ChartRuleLookupManagerMemory : public ChartRuleLookupManagerCYKPlus diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp index 26ecb80e2..4b1bdb03a 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp @@ -56,7 +56,7 @@ void ChartRuleLookupManagerMemoryPerSentence::GetChartRuleCollection( size_t lastPos, ChartParserCallback &outColl) { - const WordsRange &range = inputPath.GetWordsRange(); + const Range &range = inputPath.GetWordsRange(); size_t startPos = range.GetStartPos(); size_t absEndPos = range.GetEndPos(); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.h b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.h index 9db0d02f0..9b28d9e3a 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.h +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.h @@ -34,7 +34,7 @@ namespace Moses { class ChartParserCallback; -class WordsRange; +class Range; //! Implementation of ChartRuleLookupManager for in-memory rule tables. class ChartRuleLookupManagerMemoryPerSentence : public ChartRuleLookupManagerCYKPlus diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp index 102fa82cf..e640ea6d3 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp @@ -82,7 +82,7 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection( { const StaticData &staticData = StaticData::Instance(); const Word &defaultSourceNonTerm = staticData.GetInputDefaultNonTerminal(); - const WordsRange &range = inputPath.GetWordsRange(); + const Range &range = inputPath.GetWordsRange(); size_t relEndPos = range.GetEndPos() - range.GetStartPos(); size_t absEndPos = range.GetEndPos(); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.cpp index 7db3e14cd..ca219f249 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.cpp @@ -61,7 +61,7 @@ void ChartRuleLookupManagerSkeleton::GetChartRuleCollection( TargetPhraseCollection::shared_ptr tpColl(new TargetPhraseCollection); m_tpColl.push_back(tpColl); - const WordsRange &range = inputPath.GetWordsRange(); + const Range &range = inputPath.GetWordsRange(); if (range.GetNumWordsCovered() == 1) { const ChartCellLabel &sourceWordLabel = GetSourceAt(range.GetStartPos()); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.h b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.h index 219d7b2b6..d01f3b9bd 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.h +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.h @@ -28,7 +28,7 @@ namespace Moses class TargetPhraseCollection; class ChartParserCallback; class DottedRuleColl; -class WordsRange; +class Range; class SkeletonPT; class ChartRuleLookupManagerSkeleton : public ChartRuleLookupManager diff --git a/moses/TranslationModel/CYKPlusParser/DotChart.h b/moses/TranslationModel/CYKPlusParser/DotChart.h index 946f36ff2..07f7e8642 100644 --- a/moses/TranslationModel/CYKPlusParser/DotChart.h +++ b/moses/TranslationModel/CYKPlusParser/DotChart.h @@ -38,7 +38,7 @@ public: : m_cellLabel(&ccl) , m_prev(&prev) {} - const WordsRange &GetWordsRange() const { + const Range &GetWordsRange() const { return m_cellLabel->GetCoverage(); } const Word &GetSourceWord() const { diff --git a/moses/TranslationModel/CompactPT/LexicalReorderingTableCompact.cpp b/moses/TranslationModel/CompactPT/LexicalReorderingTableCompact.cpp index 729df525b..156d7da3c 100644 --- a/moses/TranslationModel/CompactPT/LexicalReorderingTableCompact.cpp +++ b/moses/TranslationModel/CompactPT/LexicalReorderingTableCompact.cpp @@ -70,7 +70,7 @@ GetScore(const Phrase& f, const Phrase& e, const Phrase& c) key = MakeKey(f, e, c); else for(size_t i = 0; i <= c.GetSize(); ++i) { - Phrase sub_c(c.GetSubString(WordsRange(i,c.GetSize()-1))); + Phrase sub_c(c.GetSubString(Range(i,c.GetSize()-1))); key = MakeKey(f,e,sub_c); } diff --git a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp index 54e6815a1..0e6c33bdd 100644 --- a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp +++ b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp @@ -358,7 +358,7 @@ TargetPhraseVectorPtr PhraseDecoder::DecodeCollection( // if range smaller than source phrase retrieve subphrase if(unsigned(srcEnd - srcStart + 1) != srcSize) { - Phrase subPhrase = sourcePhrase.GetSubString(WordsRange(srcStart, srcEnd)); + Phrase subPhrase = sourcePhrase.GetSubString(Range(srcStart, srcEnd)); subTpv = CreateTargetPhraseCollection(subPhrase, false); } else { // false positive consistency check diff --git a/moses/TranslationModel/CompactPT/PhraseDecoder.h b/moses/TranslationModel/CompactPT/PhraseDecoder.h index 83f174cf6..e430f5526 100644 --- a/moses/TranslationModel/CompactPT/PhraseDecoder.h +++ b/moses/TranslationModel/CompactPT/PhraseDecoder.h @@ -37,7 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "moses/Util.h" #include "moses/InputFileStream.h" #include "moses/StaticData.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "PhraseDictionaryCompact.h" #include "StringVector.h" diff --git a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp index 880067ba4..4b354d346 100644 --- a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp +++ b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp @@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "moses/Util.h" #include "moses/InputFileStream.h" #include "moses/StaticData.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/ThreadPool.h" #include "util/exception.hh" diff --git a/moses/TranslationModel/PhraseDictionary.cpp b/moses/TranslationModel/PhraseDictionary.cpp index f27ae004e..4bfe57b03 100644 --- a/moses/TranslationModel/PhraseDictionary.cpp +++ b/moses/TranslationModel/PhraseDictionary.cpp @@ -105,7 +105,7 @@ GetTargetPhraseCollectionNonCacheLEGACY(const Phrase& src) const TargetPhraseCollectionWithSourcePhrase::shared_ptr PhraseDictionary:: -GetTargetPhraseCollectionLEGACY(InputType const& src,WordsRange const& range) const +GetTargetPhraseCollectionLEGACY(InputType const& src,Range const& range) const { UTIL_THROW(util::Exception, "Legacy method not implemented"); } diff --git a/moses/TranslationModel/PhraseDictionary.h b/moses/TranslationModel/PhraseDictionary.h index 5798abb37..351c6050a 100644 --- a/moses/TranslationModel/PhraseDictionary.h +++ b/moses/TranslationModel/PhraseDictionary.h @@ -50,7 +50,7 @@ namespace Moses class StaticData; class InputType; -class WordsRange; +class Range; class ChartCellCollectionBase; class ChartRuleLookupManager; class ChartParser; @@ -159,7 +159,7 @@ public: //! find list of translations that can translates a portion of src. Used by confusion network decoding virtual TargetPhraseCollectionWithSourcePhrase::shared_ptr - GetTargetPhraseCollectionLEGACY(InputType const& src,WordsRange const& range) const; + GetTargetPhraseCollectionLEGACY(InputType const& src,Range const& range) const; protected: static std::vector s_staticColl; diff --git a/moses/TranslationModel/PhraseDictionaryMemory.cpp b/moses/TranslationModel/PhraseDictionaryMemory.cpp index 3053e46db..21ba862bc 100644 --- a/moses/TranslationModel/PhraseDictionaryMemory.cpp +++ b/moses/TranslationModel/PhraseDictionaryMemory.cpp @@ -29,7 +29,7 @@ #include "moses/Util.h" #include "moses/InputFileStream.h" #include "moses/StaticData.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/TranslationModel/RuleTable/LoaderFactory.h" #include "moses/TranslationModel/RuleTable/Loader.h" #include "moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h" diff --git a/moses/TranslationModel/PhraseDictionaryScope3.cpp b/moses/TranslationModel/PhraseDictionaryScope3.cpp index 4bf636c3e..e0b15fe12 100644 --- a/moses/TranslationModel/PhraseDictionaryScope3.cpp +++ b/moses/TranslationModel/PhraseDictionaryScope3.cpp @@ -29,7 +29,7 @@ #include "moses/Util.h" #include "moses/InputFileStream.h" #include "moses/StaticData.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/TranslationModel/RuleTable/LoaderFactory.h" #include "moses/TranslationModel/RuleTable/Loader.h" #include "moses/TranslationModel/Scope3Parser/Parser.h" diff --git a/moses/TranslationModel/PhraseDictionaryTreeAdaptor.cpp b/moses/TranslationModel/PhraseDictionaryTreeAdaptor.cpp index fbeb3abe6..d2007e523 100644 --- a/moses/TranslationModel/PhraseDictionaryTreeAdaptor.cpp +++ b/moses/TranslationModel/PhraseDictionaryTreeAdaptor.cpp @@ -108,7 +108,7 @@ const PDTAimp& PhraseDictionaryTreeAdaptor::GetImplementation() const // legacy TargetPhraseCollectionWithSourcePhrase::shared_ptr PhraseDictionaryTreeAdaptor:: -GetTargetPhraseCollectionLEGACY(InputType const& src,WordsRange const &range) const +GetTargetPhraseCollectionLEGACY(InputType const& src,Range const &range) const { TargetPhraseCollectionWithSourcePhrase::shared_ptr ret; if(GetImplementation().m_rangeCache.empty()) { diff --git a/moses/TranslationModel/PhraseDictionaryTreeAdaptor.h b/moses/TranslationModel/PhraseDictionaryTreeAdaptor.h index 020ce117e..90c8f12ff 100644 --- a/moses/TranslationModel/PhraseDictionaryTreeAdaptor.h +++ b/moses/TranslationModel/PhraseDictionaryTreeAdaptor.h @@ -19,7 +19,7 @@ namespace Moses class Phrase; class PDTAimp; -class WordsRange; +class Range; class InputType; /*** Implementation of a phrase table in a trie that is binarized and @@ -76,7 +76,7 @@ public: // legacy TargetPhraseCollectionWithSourcePhrase::shared_ptr GetTargetPhraseCollectionLEGACY(InputType const& src, - WordsRange const & srcRange) const; + Range const & srcRange) const; }; diff --git a/moses/TranslationModel/RuleTable/LoaderStandard.cpp b/moses/TranslationModel/RuleTable/LoaderStandard.cpp index 2c2c3a8be..2c4d6f3e9 100644 --- a/moses/TranslationModel/RuleTable/LoaderStandard.cpp +++ b/moses/TranslationModel/RuleTable/LoaderStandard.cpp @@ -33,7 +33,7 @@ #include "moses/Util.h" #include "moses/InputFileStream.h" #include "moses/StaticData.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/ChartTranslationOptionList.h" #include "moses/FactorCollection.h" #include "util/file_piece.hh" diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp b/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp index 0d6321f2b..435478d35 100644 --- a/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp +++ b/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp @@ -39,7 +39,7 @@ #include "moses/Util.h" #include "moses/InputFileStream.h" #include "moses/StaticData.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include "moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.h" #include "moses/TranslationModel/fuzzy-match/FuzzyMatchWrapper.h" #include "moses/TranslationModel/fuzzy-match/SentenceAlignment.h" diff --git a/moses/TranslationModel/Scope3Parser/Parser.cpp b/moses/TranslationModel/Scope3Parser/Parser.cpp index fe1561c6e..ee194d172 100644 --- a/moses/TranslationModel/Scope3Parser/Parser.cpp +++ b/moses/TranslationModel/Scope3Parser/Parser.cpp @@ -43,7 +43,7 @@ void Scope3Parser::GetChartRuleCollection( size_t last, ChartParserCallback &outColl) { - const WordsRange &range = inputPath.GetWordsRange(); + const Range &range = inputPath.GetWordsRange(); const size_t start = range.GetStartPos(); const size_t end = range.GetEndPos(); diff --git a/moses/TranslationModel/Scope3Parser/Parser.h b/moses/TranslationModel/Scope3Parser/Parser.h index e7f4a5d51..c5a71c16f 100644 --- a/moses/TranslationModel/Scope3Parser/Parser.h +++ b/moses/TranslationModel/Scope3Parser/Parser.h @@ -40,7 +40,7 @@ namespace Moses class InputType; class ChartCellCollectionBase; class ChartHypothesisCollection; -class WordsRange; +class Range; /** @todo what is this? */ @@ -66,14 +66,14 @@ private: // Define a callback type for use by StackLatticeSearcher. struct MatchCallback { public: - MatchCallback(const WordsRange &range, ChartParserCallback &out) + MatchCallback(const Range &range, ChartParserCallback &out) : m_range(range) , m_out(out) // , m_tpc(NULL) { } void operator()(const StackVec &stackVec) { m_out.Add(*m_tpc, stackVec, m_range); } - const WordsRange &m_range; + const Range &m_range; ChartParserCallback &m_out; TargetPhraseCollection::shared_ptr m_tpc; }; diff --git a/moses/TranslationModel/Scope3Parser/VarSpanNode.h b/moses/TranslationModel/Scope3Parser/VarSpanNode.h index 0dda6a787..21f743251 100644 --- a/moses/TranslationModel/Scope3Parser/VarSpanNode.h +++ b/moses/TranslationModel/Scope3Parser/VarSpanNode.h @@ -20,7 +20,7 @@ #pragma once #include "IntermediateVarSpanNode.h" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include diff --git a/moses/TranslationModel/UG/spe-check-coverage.cc b/moses/TranslationModel/UG/spe-check-coverage.cc index 351832fa5..d32efe613 100644 --- a/moses/TranslationModel/UG/spe-check-coverage.cc +++ b/moses/TranslationModel/UG/spe-check-coverage.cc @@ -123,7 +123,7 @@ int main(int argc, char* argv[]) { for (size_t k = i; k < snt.GetSize(); ++k) { - Phrase p = snt.GetSubString(WordsRange(i,k)); + Phrase p = snt.GetSubString(Range(i,k)); if (!mmsapt->PrefixExists(p)) break; TargetPhraseCollection const* trg = PT->GetTargetPhraseCollectionLEGACY(p); if (!trg || !trg->GetSize()) continue; diff --git a/moses/TranslationOption.cpp b/moses/TranslationOption.cpp index 90675eb60..16e8af00f 100644 --- a/moses/TranslationOption.cpp +++ b/moses/TranslationOption.cpp @@ -39,11 +39,11 @@ TranslationOption::TranslationOption() { } //TODO this should be a factory function! -TranslationOption::TranslationOption(const WordsRange &wordsRange +TranslationOption::TranslationOption(const Range &range , const TargetPhrase &targetPhrase) : m_targetPhrase(targetPhrase) , m_inputPath(NULL) - , m_sourceWordsRange(wordsRange) + , m_sourceWordsRange(range) , m_futureScore(targetPhrase.GetFutureScore()) { } diff --git a/moses/TranslationOption.h b/moses/TranslationOption.h index ca3ab8899..f191f0215 100644 --- a/moses/TranslationOption.h +++ b/moses/TranslationOption.h @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include "Bitmap.h" -#include "WordsRange.h" +#include "Range.h" #include "Phrase.h" #include "TargetPhrase.h" #include "Hypothesis.h" @@ -67,7 +67,7 @@ protected: TargetPhrase m_targetPhrase; /*< output phrase when using this translation option */ const InputPath *m_inputPath; - const WordsRange m_sourceWordsRange; /*< word position in the input that are covered by this translation option */ + const Range m_sourceWordsRange; /*< word position in the input that are covered by this translation option */ float m_futureScore; /*< estimate of total cost when using this translation option, includes language model probabilities */ // typedef std::map _ScoreCacheMap; @@ -91,7 +91,7 @@ public: explicit TranslationOption(); // For initial hypo that does translate nothing /** constructor. Used by initial translation step */ - TranslationOption(const WordsRange &wordsRange + TranslationOption(const Range &range , const TargetPhrase &targetPhrase); /** returns true if all feature types in featuresToCheck are compatible between the two phrases */ @@ -103,7 +103,7 @@ public: } /** returns source word range */ - inline const WordsRange &GetSourceWordsRange() const { + inline const Range &GetSourceWordsRange() const { return m_sourceWordsRange; } diff --git a/moses/TranslationOptionCollection.cpp b/moses/TranslationOptionCollection.cpp index f0f6c8d84..765839fa6 100644 --- a/moses/TranslationOptionCollection.cpp +++ b/moses/TranslationOptionCollection.cpp @@ -237,7 +237,7 @@ ProcessOneUnknownWord(const InputPath &inputPath, size_t sourcePos, // source phrase const Phrase &sourcePhrase = inputPath.GetPhrase(); m_unksrcs.push_back(&sourcePhrase); - WordsRange range(sourcePos, sourcePos + length - 1); + Range range(sourcePos, sourcePos + length - 1); targetPhrase.EvaluateInIsolation(sourcePhrase); @@ -588,7 +588,7 @@ void TranslationOptionCollection:: Add(TranslationOption *translationOption) { - const WordsRange &coverage = translationOption->GetSourceWordsRange(); + const Range &coverage = translationOption->GetSourceWordsRange(); size_t const s = coverage.GetStartPos(); size_t const e = coverage.GetEndPos(); size_t const i = e - s; diff --git a/moses/TranslationOptionCollection.h b/moses/TranslationOptionCollection.h index e4facf38e..c6d0462a5 100644 --- a/moses/TranslationOptionCollection.h +++ b/moses/TranslationOptionCollection.h @@ -169,7 +169,7 @@ public: //! list of trans opt for a particular span TranslationOptionList const* - GetTranslationOptionList(const WordsRange &coverage) const { + GetTranslationOptionList(const Range &coverage) const { return GetTranslationOptionList(coverage.GetStartPos(), coverage.GetEndPos()); } diff --git a/moses/TranslationOptionCollectionConfusionNet.cpp b/moses/TranslationOptionCollectionConfusionNet.cpp index 391d1d6b6..761bc4137 100644 --- a/moses/TranslationOptionCollectionConfusionNet.cpp +++ b/moses/TranslationOptionCollectionConfusionNet.cpp @@ -50,7 +50,7 @@ TranslationOptionCollectionConfusionNet(ttasksptr const& ttask, vec.push_back(InputPathList()); InputPathList &list = vec.back(); - WordsRange range(startPos, startPos); + Range range(startPos, startPos); const NonTerminalSet &labels = input.GetLabelSet(startPos, startPos); const ConfusionNet::Column &col = input.GetColumn(startPos); @@ -74,7 +74,7 @@ TranslationOptionCollectionConfusionNet(ttasksptr const& ttask, for (size_t startPos = 0; startPos < inputSize - phraseSize + 1; ++startPos) { size_t endPos = startPos + phraseSize -1; - WordsRange range(startPos, endPos); + Range range(startPos, endPos); const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos); vector &vec = m_inputPathMatrix[startPos]; diff --git a/moses/TranslationOptionCollectionLattice.cpp b/moses/TranslationOptionCollectionLattice.cpp index 2cb3b6387..c3b5765e7 100644 --- a/moses/TranslationOptionCollectionLattice.cpp +++ b/moses/TranslationOptionCollectionLattice.cpp @@ -47,7 +47,7 @@ TranslationOptionCollectionLattice size_t nextNode = nextNodes[i]; size_t endPos = startPos + nextNode - 1; - WordsRange range(startPos, endPos); + Range range(startPos, endPos); if (range.GetNumWordsCovered() > maxPhraseLength) { continue; @@ -98,7 +98,7 @@ void TranslationOptionCollectionLattice::Extend(const InputPath &prevPath, const size_t nextNode = nextNodes[i]; size_t endPos = nextPos + nextNode - 1; - WordsRange range(startPos, endPos); + Range range(startPos, endPos); size_t maxPhraseLength = StaticData::Instance().GetMaxPhraseLength(); if (range.GetNumWordsCovered() > maxPhraseLength) { @@ -144,7 +144,7 @@ void TranslationOptionCollectionLattice::CreateTranslationOptions() TargetPhraseCollection::shared_ptr tpColl = path.GetTargetPhrases(phraseDictionary); - const WordsRange &range = path.GetWordsRange(); + const Range &range = path.GetWordsRange(); if (tpColl && tpColl->GetSize()) { TargetPhraseCollection::const_iterator iter; diff --git a/moses/TranslationOptionCollectionText.cpp b/moses/TranslationOptionCollectionText.cpp index 01b22a788..9ad5d19ad 100644 --- a/moses/TranslationOptionCollectionText.cpp +++ b/moses/TranslationOptionCollectionText.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "DecodeStep.h" #include "DecodeStepTranslation.h" #include "FactorCollection.h" -#include "WordsRange.h" +#include "Range.h" #include using namespace std; @@ -42,8 +42,8 @@ TranslationOptionCollectionText::TranslationOptionCollectionText(ttasksptr const size_t endPos = startPos + phaseSize -1; vector &vec = m_inputPathMatrix[startPos]; - WordsRange range(startPos, endPos); - Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos))); + Range range(startPos, endPos); + Phrase subphrase(input.GetSubString(Range(startPos, endPos))); const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos); InputPath *path; @@ -92,7 +92,7 @@ bool TranslationOptionCollectionText::ViolatesXmlOptionsConstraint(size_t startP vector xmlOptions; source.GetXmlTranslationOptions(xmlOptions); for(size_t i=0; iGetSourceWordsRange(); + const Range &range = xmlOptions[i]->GetSourceWordsRange(); // if transOpt is a subphrase of a xml specification, do not use it if (range.GetStartPos() <= startPosition && range.GetEndPos() >= endPosition && (range.GetStartPos() < startPosition || range.GetEndPos() > endPosition)) { diff --git a/moses/TreeInput.cpp b/moses/TreeInput.cpp index 81a76507e..89ce0ba65 100644 --- a/moses/TreeInput.cpp +++ b/moses/TreeInput.cpp @@ -166,7 +166,7 @@ bool TreeInput::ProcessAndStripXMLTags(string &line, std::vector // specified label if (translation.length() == 0 && label.length() > 0) { - WordsRange range(startPos,endPos-1); // really? + Range range(startPos,endPos-1); // really? XMLParseOutput item(label, range); sourceLabels.push_back(item); } @@ -199,7 +199,7 @@ bool TreeInput::ProcessAndStripXMLTags(string &line, std::vector targetPhrase.SetTargetLHS(targetLHS); // not tested - Phrase sourcePhrase = this->GetSubString(WordsRange(startPos,endPos-1)); + Phrase sourcePhrase = this->GetSubString(Range(startPos,endPos-1)); // get probability float probValue = 1; @@ -212,7 +212,7 @@ bool TreeInput::ProcessAndStripXMLTags(string &line, std::vector targetPhrase.EvaluateInIsolation(sourcePhrase); // set span and create XmlOption - WordsRange range(startPos+1,endPos); + Range range(startPos+1,endPos); XmlOption *option = new XmlOption(range,targetPhrase); assert(option); xmlOptions.push_back(option); @@ -268,7 +268,7 @@ int TreeInput::Read(std::istream& in,const std::vector& factorOrder) vector::const_iterator iterLabel; for (iterLabel = m_labelledSpans.begin(); iterLabel != m_labelledSpans.end(); ++iterLabel) { const XMLParseOutput &labelItem = *iterLabel; - const WordsRange &range = labelItem.m_range; + const Range &range = labelItem.m_range; const string &label = labelItem.m_label; AddChartLabel(range.GetStartPos() + 1, range.GetEndPos() + 1, label, factorOrder); } diff --git a/moses/TreeInput.h b/moses/TreeInput.h index fc7387b0d..2716831cc 100644 --- a/moses/TreeInput.h +++ b/moses/TreeInput.h @@ -14,9 +14,9 @@ class XMLParseOutput { public: std::string m_label; - WordsRange m_range; + Range m_range; - XMLParseOutput(const std::string &label, const WordsRange &range) + XMLParseOutput(const std::string &label, const Range &range) : m_label(label) , m_range(range) { } diff --git a/moses/TrellisPath.cpp b/moses/TrellisPath.cpp index 36397e006..7b7baa815 100644 --- a/moses/TrellisPath.cpp +++ b/moses/TrellisPath.cpp @@ -226,7 +226,7 @@ Phrase TrellisPath::GetSurfacePhrase() const return ret; } -WordsRange TrellisPath::GetTargetWordsRange(const Hypothesis &hypo) const +Range TrellisPath::GetTargetWordsRange(const Hypothesis &hypo) const { size_t startPos = 0; @@ -235,14 +235,14 @@ WordsRange TrellisPath::GetTargetWordsRange(const Hypothesis &hypo) const size_t endPos = startPos + currHypo->GetCurrTargetLength() - 1; if (currHypo == &hypo) { - return WordsRange(startPos, endPos); + return Range(startPos, endPos); } startPos = endPos + 1; } // have to give a hypo in the trellis path, but u didn't. UTIL_THROW(util::Exception, "Hypothesis not found"); - return WordsRange(NOT_FOUND, NOT_FOUND); + return Range(NOT_FOUND, NOT_FOUND); } TO_STRING_BODY(TrellisPath); diff --git a/moses/TrellisPath.h b/moses/TrellisPath.h index 89efb32e4..1e6914a5c 100644 --- a/moses/TrellisPath.h +++ b/moses/TrellisPath.h @@ -94,7 +94,7 @@ public: const boost::shared_ptr GetScoreBreakdown() const; //! get target words range of the hypo within n-best trellis. not necessarily the same as hypo.GetCurrTargetWordsRange() - WordsRange GetTargetWordsRange(const Hypothesis &hypo) const; + Range GetTargetWordsRange(const Hypothesis &hypo) const; Phrase GetTargetPhrase() const; Phrase GetSurfacePhrase() const; @@ -109,7 +109,7 @@ inline std::ostream& operator<<(std::ostream& out, const TrellisPath& path) const size_t sizePath = path.m_path.size(); for (int pos = (int) sizePath - 1 ; pos >= 0 ; pos--) { const Hypothesis *edge = path.m_path[pos]; - const WordsRange &sourceRange = edge->GetCurrSourceWordsRange(); + const Range &sourceRange = edge->GetCurrSourceWordsRange(); out << edge->GetId() << " " << sourceRange.GetStartPos() << "-" << sourceRange.GetEndPos() << ", "; } // scores diff --git a/moses/WordLattice.cpp b/moses/WordLattice.cpp index c68d182b0..51ef4be9e 100644 --- a/moses/WordLattice.cpp +++ b/moses/WordLattice.cpp @@ -171,7 +171,7 @@ void WordLattice::GetAsEdgeMatrix(std::vector >& edges) const } } -int WordLattice::ComputeDistortionDistance(const WordsRange& prev, const WordsRange& current) const +int WordLattice::ComputeDistortionDistance(const Range& prev, const Range& current) const { int result; diff --git a/moses/WordLattice.h b/moses/WordLattice.h index 4dc937858..70b1602f2 100644 --- a/moses/WordLattice.h +++ b/moses/WordLattice.h @@ -33,7 +33,7 @@ public: void Print(std::ostream&) const; /** Get shortest path between two nodes */ - virtual int ComputeDistortionDistance(const WordsRange& prev, const WordsRange& current) const; + virtual int ComputeDistortionDistance(const Range& prev, const Range& current) const; // is it possible to get from the edge of the previous word range to the current word range virtual bool CanIGetFromAToB(size_t start, size_t end) const; diff --git a/moses/XmlOption.cpp b/moses/XmlOption.cpp index 38b767d8a..941eb2d24 100644 --- a/moses/XmlOption.cpp +++ b/moses/XmlOption.cpp @@ -29,7 +29,7 @@ #include #include "Util.h" #include "StaticData.h" -#include "WordsRange.h" +#include "Range.h" #include "TargetPhrase.h" #include "ReorderingConstraint.h" #include "FactorCollection.h" @@ -451,7 +451,7 @@ bool ProcessAndStripXMLTags(string &line, vector &res, ReorderingCon // convert from prob to log-prob float scoreValue = FloorScore(TransformScore(probValue)); - WordsRange range(startPos + offset,endPos-1 + offset); // span covered by phrase + Range range(startPos + offset,endPos-1 + offset); // span covered by phrase TargetPhrase targetPhrase(firstPt); // targetPhrase.CreateFromString(Output, outputFactorOrder,altTexts[i],factorDelimiter, NULL); targetPhrase.CreateFromString(Output, outputFactorOrder,altTexts[i], NULL); diff --git a/moses/XmlOption.h b/moses/XmlOption.h index a08425b84..60ab24a70 100644 --- a/moses/XmlOption.h +++ b/moses/XmlOption.h @@ -3,7 +3,7 @@ #include #include -#include "WordsRange.h" +#include "Range.h" #include "TargetPhrase.h" namespace Moses @@ -16,10 +16,10 @@ class ReorderingConstraint; */ struct XmlOption { - WordsRange range; + Range range; TargetPhrase targetPhrase; - XmlOption(const WordsRange &r, const TargetPhrase &tp) + XmlOption(const Range &r, const TargetPhrase &tp) : range(r), targetPhrase(tp) { } diff --git a/moses/server/TranslationRequest.cpp b/moses/server/TranslationRequest.cpp index 8c1efb628..4635065c6 100644 --- a/moses/server/TranslationRequest.cpp +++ b/moses/server/TranslationRequest.cpp @@ -7,7 +7,7 @@ namespace MosesServer using namespace std; using Moses::Hypothesis; using Moses::StaticData; -using Moses::WordsRange; +using Moses::Range; using Moses::ChartHypothesis; using Moses::Phrase; using Moses::Manager; @@ -87,8 +87,8 @@ TranslationRequest:: add_phrase_aln_info(Hypothesis const& h, vector& aInfo) const { if (!m_withAlignInfo) return; - WordsRange const& trg = h.GetCurrTargetWordsRange(); - WordsRange const& src = h.GetCurrSourceWordsRange(); + Range const& trg = h.GetCurrTargetWordsRange(); + Range const& src = h.GetCurrSourceWordsRange(); std::map pAlnInfo; pAlnInfo["tgt-start"] = xmlrpc_c::value_int(trg.GetStartPos()); diff --git a/search/applied.hh b/search/applied.hh index 9464080cc..f404cccbc 100644 --- a/search/applied.hh +++ b/search/applied.hh @@ -24,7 +24,7 @@ template class GenericApplied : public Header { *child_out = Below(part->End()); } - GenericApplied(void *location, Score score, Arity arity, Note note, Moses::WordsRange range) : Header(location, arity) { + GenericApplied(void *location, Score score, Arity arity, Note note, Moses::Range range) : Header(location, arity) { SetScore(score); SetNote(note); SetRange(range); diff --git a/search/header.hh b/search/header.hh index 699d8ef15..980507516 100644 --- a/search/header.hh +++ b/search/header.hh @@ -1,10 +1,10 @@ #ifndef SEARCH_HEADER__ #define SEARCH_HEADER__ -// Header consisting of Score, Arity, Note and WordsRange +// Header consisting of Score, Arity, Note and Range #include "search/types.hh" -#include "moses/WordsRange.h" +#include "moses/Range.h" #include @@ -39,11 +39,11 @@ class Header { *reinterpret_cast(base_ + sizeof(Score) + sizeof(Arity)) = to; } - Moses::WordsRange GetRange() const { - return *reinterpret_cast(base_ + sizeof(Score) + sizeof(Arity) + sizeof(Note)); + Moses::Range GetRange() const { + return *reinterpret_cast(base_ + sizeof(Score) + sizeof(Arity) + sizeof(Note)); } - void SetRange(Moses::WordsRange to) { - *reinterpret_cast(base_ + sizeof(Score) + sizeof(Arity) + sizeof(Note)) = to; + void SetRange(Moses::Range to) { + *reinterpret_cast(base_ + sizeof(Score) + sizeof(Arity) + sizeof(Note)) = to; } uint8_t *Base() { return base_; } @@ -58,7 +58,7 @@ class Header { *reinterpret_cast(base_ + sizeof(Score)) = arity; } - static const std::size_t kHeaderSize = sizeof(Score) + sizeof(Arity) + sizeof(Note) + sizeof(Moses::WordsRange); + static const std::size_t kHeaderSize = sizeof(Score) + sizeof(Arity) + sizeof(Note) + sizeof(Moses::Range); uint8_t *After() { return base_ + kHeaderSize; } const uint8_t *After() const { return base_ + kHeaderSize; }