00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021 #ifndef HOLECOLLECTION_H_INCLUDED_
00022 #define HOLECOLLECTION_H_INCLUDED_
00023
00024 #include <set>
00025 #include <vector>
00026
00027 #include "Hole.h"
00028
00029 namespace MosesTraining
00030 {
00031
00032 class HoleCollection
00033 {
00034 protected:
00035 HoleList m_holes;
00036 std::vector<Hole*> m_sortedSourceHoles;
00037 std::vector<int> m_sourceHoleStartPoints;
00038 std::vector<int> m_sourceHoleEndPoints;
00039 std::vector<int> m_scope;
00040 std::vector<int> m_sourcePhraseStart;
00041 std::vector<int> m_sourcePhraseEnd;
00042
00043 public:
00044 HoleCollection(int sourcePhraseStart, int sourcePhraseEnd)
00045 : m_scope(1, 0)
00046 , m_sourcePhraseStart(1, sourcePhraseStart)
00047 , m_sourcePhraseEnd(1, sourcePhraseEnd) {
00048 }
00049
00050 const HoleList &GetHoles() const {
00051 return m_holes;
00052 }
00053
00054 HoleList &GetHoles() {
00055 return m_holes;
00056 }
00057
00058 std::vector<Hole*> &GetSortedSourceHoles() {
00059 return m_sortedSourceHoles;
00060 }
00061
00062 void Add(int startT, int endT, int startS, int endS);
00063
00064 void RemoveLast();
00065
00066 bool OverlapSource(const Hole &sourceHole) const {
00067 HoleList::const_iterator iter;
00068 for (iter = m_holes.begin(); iter != m_holes.end(); ++iter) {
00069 const Hole &currHole = *iter;
00070 if (currHole.Overlap(sourceHole, 0))
00071 return true;
00072 }
00073 return false;
00074 }
00075
00076 bool ConsecSource(const Hole &sourceHole) const {
00077 HoleList::const_iterator iter;
00078 for (iter = m_holes.begin(); iter != m_holes.end(); ++iter) {
00079 const Hole &currHole = *iter;
00080 if (currHole.Neighbor(sourceHole, 0))
00081 return true;
00082 }
00083 return false;
00084 }
00085
00086
00087 int Scope(const Hole &proposedHole) const;
00088
00089 void SortSourceHoles();
00090
00091 };
00092
00093 }
00094
00095 #endif