diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-29 21:16:15 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-29 21:16:15 +0400 |
commit | 6249432407af8730c10bccc7894c0725fcaf5e47 (patch) | |
tree | 3ac1f094b9fdc199b04bc5ef209ce00e3596e37d /moses/ChartCellCollection.h | |
parent | 59bd7deb4b6b9c4f7b3b7dbb055783528fbc31ca (diff) |
beautify
Diffstat (limited to 'moses/ChartCellCollection.h')
-rw-r--r-- | moses/ChartCellCollection.h | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/moses/ChartCellCollection.h b/moses/ChartCellCollection.h index 7532503d7..d0423b0b2 100644 --- a/moses/ChartCellCollection.h +++ b/moses/ChartCellCollection.h @@ -31,57 +31,59 @@ namespace Moses class InputType; class ChartManager; -class ChartCellCollectionBase { - public: - template <class Factory> ChartCellCollectionBase(const InputType &input, const Factory &factory) : - m_cells(input.GetSize()) { - size_t size = input.GetSize(); - for (size_t startPos = 0; startPos < size; ++startPos) { - std::vector<ChartCellBase*> &inner = m_cells[startPos]; - inner.reserve(size - startPos); - for (size_t endPos = startPos; endPos < size; ++endPos) { - inner.push_back(factory(startPos, endPos)); - } - /* Hack: ChartCellLabel shouldn't need to know its span, but the parser - * 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. - */ - m_source.push_back(new ChartCellLabel(inner[0]->GetCoverage(), input.GetWord(startPos))); +class ChartCellCollectionBase +{ +public: + template <class Factory> ChartCellCollectionBase(const InputType &input, const Factory &factory) : + m_cells(input.GetSize()) { + size_t size = input.GetSize(); + for (size_t startPos = 0; startPos < size; ++startPos) { + std::vector<ChartCellBase*> &inner = m_cells[startPos]; + inner.reserve(size - startPos); + for (size_t endPos = startPos; endPos < size; ++endPos) { + inner.push_back(factory(startPos, endPos)); } + /* Hack: ChartCellLabel shouldn't need to know its span, but the parser + * 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. + */ + m_source.push_back(new ChartCellLabel(inner[0]->GetCoverage(), input.GetWord(startPos))); } + } - virtual ~ChartCellCollectionBase(); + virtual ~ChartCellCollectionBase(); - const ChartCellBase &GetBase(const WordsRange &coverage) const { - return *m_cells[coverage.GetStartPos()][coverage.GetEndPos() - coverage.GetStartPos()]; - } + const ChartCellBase &GetBase(const WordsRange &coverage) const { + return *m_cells[coverage.GetStartPos()][coverage.GetEndPos() - coverage.GetStartPos()]; + } - ChartCellBase &MutableBase(const WordsRange &coverage) { - return *m_cells[coverage.GetStartPos()][coverage.GetEndPos() - coverage.GetStartPos()]; - } + ChartCellBase &MutableBase(const WordsRange &coverage) { + return *m_cells[coverage.GetStartPos()][coverage.GetEndPos() - coverage.GetStartPos()]; + } - const ChartCellLabel &GetSourceWordLabel(size_t at) const { - return m_source[at]; - } + const ChartCellLabel &GetSourceWordLabel(size_t at) const { + return m_source[at]; + } - private: - std::vector<std::vector<ChartCellBase*> > m_cells; +private: + std::vector<std::vector<ChartCellBase*> > m_cells; - boost::ptr_vector<ChartCellLabel> m_source; + boost::ptr_vector<ChartCellLabel> m_source; }; /** Hold all the chart cells for 1 input sentence. A variable of this type is held by the ChartManager */ -class ChartCellCollection : public ChartCellCollectionBase { - public: - ChartCellCollection(const InputType &input, ChartManager &manager); +class ChartCellCollection : public ChartCellCollectionBase +{ +public: + ChartCellCollection(const InputType &input, ChartManager &manager); //! get a chart cell for a particular range ChartCell &Get(const WordsRange &coverage) { return static_cast<ChartCell&>(MutableBase(coverage)); } - + //! get a chart cell for a particular range const ChartCell &Get(const WordsRange &coverage) const { return static_cast<const ChartCell&>(GetBase(coverage)); |