| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #pragma once |
| |
|
| | #include <set> |
| | #include "ChartHypothesis.h" |
| | #include "RuleCube.h" |
| |
|
| |
|
| | namespace Moses |
| | { |
| |
|
| | class ChartSearchGraphWriter; |
| | struct AllOptions; |
| |
|
| | |
| | class ChartHypothesisScoreOrderer |
| | { |
| | public: |
| | bool operator()(const ChartHypothesis* hypoA, const ChartHypothesis* hypoB) const { |
| | return hypoA->GetFutureScore() > hypoB->GetFutureScore(); |
| | } |
| | }; |
| |
|
| | |
| | |
| | |
| | class ChartHypothesisCollection |
| | { |
| | friend std::ostream& operator<<(std::ostream&, const ChartHypothesisCollection&); |
| |
|
| | protected: |
| | |
| | typedef boost::unordered_set< ChartHypothesis*, UnorderedComparer<ChartHypothesis>, UnorderedComparer<ChartHypothesis> > HCType; |
| | HCType m_hypos; |
| | HypoList m_hyposOrdered; |
| |
|
| | float m_bestScore; |
| | float m_beamWidth; |
| | size_t m_maxHypoStackSize; |
| | bool m_nBestIsEnabled; |
| |
|
| | std::pair<HCType::iterator, bool> Add(ChartHypothesis *hypo, ChartManager &manager); |
| |
|
| | public: |
| | typedef HCType::iterator iterator; |
| | typedef HCType::const_iterator const_iterator; |
| | |
| | const_iterator begin() const { |
| | return m_hypos.begin(); |
| | } |
| | const_iterator end() const { |
| | return m_hypos.end(); |
| | } |
| |
|
| | ChartHypothesisCollection(AllOptions const& opts); |
| | ~ChartHypothesisCollection(); |
| | bool AddHypothesis(ChartHypothesis *hypo, ChartManager &manager); |
| |
|
| | void Detach(const HCType::iterator &iter); |
| | void Remove(const HCType::iterator &iter); |
| |
|
| | void PruneToSize(ChartManager &manager); |
| |
|
| | size_t GetSize() const { |
| | return m_hypos.size(); |
| | } |
| | size_t GetHypo() const { |
| | return m_hypos.size(); |
| | } |
| |
|
| | void SortHypotheses(); |
| | void CleanupArcList(); |
| |
|
| | |
| | const HypoList &GetSortedHypotheses() const { |
| | return m_hyposOrdered; |
| | } |
| |
|
| | |
| | float GetBestScore() const { |
| | return m_bestScore; |
| | } |
| |
|
| | void WriteSearchGraph(const ChartSearchGraphWriter& writer, const std::map<unsigned,bool> &reachable) const; |
| |
|
| | }; |
| |
|
| | } |
| |
|
| |
|