Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorevahasler <evahasler@1f5c12ca-751b-0410-a591-d2e778427230>2007-11-27 19:25:19 +0300
committerevahasler <evahasler@1f5c12ca-751b-0410-a591-d2e778427230>2007-11-27 19:25:19 +0300
commit78728d70eadb722f81cadeeafc567ddfa2657781 (patch)
tree3cc63d8859592583e728467ccd33d06e853c7025
parent858f5c1b25393f2fba92eb8e160fcb97e2429d81 (diff)
delete CompressedRepr() from Bitmapeva_2d_pruning@1521
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/branches/eva_cube_pruning/moses@1521 1f5c12ca-751b-0410-a591-d2e778427230
-rwxr-xr-xsrc/Hypothesis.cpp6
-rwxr-xr-xsrc/Manager.cpp13
-rwxr-xr-xsrc/WordsBitmap.cpp23
-rwxr-xr-xsrc/WordsBitmap.h10
4 files changed, 16 insertions, 36 deletions
diff --git a/src/Hypothesis.cpp b/src/Hypothesis.cpp
index 866768086..36a608b83 100755
--- a/src/Hypothesis.cpp
+++ b/src/Hypothesis.cpp
@@ -187,8 +187,10 @@ int Hypothesis::NGramCompare(const Hypothesis &compare) const
// 0 = this ==compare
if (m_languageModelStates < compare.m_languageModelStates) return -1;
if (m_languageModelStates > compare.m_languageModelStates) return 1;
- if (m_sourceCompleted.GetCompressedRepresentation() < compare.m_sourceCompleted.GetCompressedRepresentation()) return -1;
- if (m_sourceCompleted.GetCompressedRepresentation() > compare.m_sourceCompleted.GetCompressedRepresentation()) return 1;
+
+ int compareBitmap = m_sourceCompleted.Compare(compare.m_sourceCompleted);
+ if (compareBitmap != 0)
+ return compareBitmap;
if (m_currSourceWordsRange.GetEndPos() < compare.m_currSourceWordsRange.GetEndPos()) return -1;
if (m_currSourceWordsRange.GetEndPos() > compare.m_currSourceWordsRange.GetEndPos()) return 1;
if (! StaticData::Instance().GetSourceStartPosMattersForRecombination()) return 0;
diff --git a/src/Manager.cpp b/src/Manager.cpp
index 18f121650..00c95c60f 100755
--- a/src/Manager.cpp
+++ b/src/Manager.cpp
@@ -117,7 +117,8 @@ void Manager::ProcessSentence()
sourceHypoColl.CleanupArcList();
// keep already seen coverages in mind
- set<vector<size_t> > seenCoverages;
+ //set<vector<size_t> > seenCoverages;
+ set< WordsBitmap > seenCoverages;
// go through each hypothesis on the stack, find the set of hypothesis with same coverage and expand this set using cube pruning
HypothesisStack::const_iterator iterHypo;
@@ -126,12 +127,12 @@ void Manager::ProcessSentence()
// take first hypothesis from stack to get coverage
Hypothesis *hypothesis = *iterHypo;
const WordsBitmap &wb = hypothesis->GetWordsBitmap();
- vector<size_t> cov = wb.GetCompressedRepresentation();
+ //vector<size_t> cov = wb.GetCompressedRepresentation();
// check if coverage of current hypothesis was already seen --> if no, proceed
- if( (seenCoverages.count( cov )) == 0 )
+ if( (seenCoverages.count( wb )) == 0 )
{
- seenCoverages.insert( cov );
+ seenCoverages.insert( wb );
const set<Hypothesis*, HypothesisScoreOrderer> coverageSet = sourceHypoColl.GetCoverageSet( wb );
size_t j = 0;
@@ -163,7 +164,7 @@ void Manager::ProcessSentence()
}
i++;
// some logging
- IFVERBOSE(2) { OutputHypoStackSize(); }
+ OutputHypoStackSize();
}
// some more logging
@@ -326,7 +327,7 @@ void Manager::CubePruning(const vector< Hypothesis*> &coverageVec, TranslationOp
Hypothesis *item;
// TODO: the size of the buffer could be a little bigger than top_k to allow for more possible hypotheses being found
size_t extra = 0;
- while( !(cand.empty()) && (buf.size() < top_k+extra) )
+ while( !(cand.empty()) && (buf.size() < top_k + extra) )
{
IFVERBOSE(3) {
cout << "candidates: " << endl;
diff --git a/src/WordsBitmap.cpp b/src/WordsBitmap.cpp
index b70495552..fadf597ae 100755
--- a/src/WordsBitmap.cpp
+++ b/src/WordsBitmap.cpp
@@ -57,26 +57,3 @@ int WordsBitmap::GetFutureCosts(int lastPos) const
}
-std::vector<size_t> WordsBitmap::GetCompressedRepresentation() const
-{
- std::vector<size_t> res(1 + (m_size >> (sizeof(int) + 3)), 0);
- size_t c=0; size_t x=0; size_t ci=0;
- for(size_t i=0;i<m_size;++i) {
- // one shift too much --> swap these two lines
- // x |= (size_t)m_bitmap[i];
- // x <<= 1;
- x <<= 1;
- x |= (size_t)m_bitmap[i];
- c++;
- if (c == sizeof(int)*8) {
- res[ci++] = x; x = 0;
- // new
- c = 0;
- }
- }
- // rest: save current x in res
- res[ci++] = x;
- return res;
-}
-
-
diff --git a/src/WordsBitmap.h b/src/WordsBitmap.h
index 423682108..59b3e80fe 100755
--- a/src/WordsBitmap.h
+++ b/src/WordsBitmap.h
@@ -149,11 +149,6 @@ public:
{
return m_size;
}
- /** represent this bitmap as 1 or more vector of integers.
- * Used for exact matching of source words translated in hypothesis recombination
- */
- std::vector<size_t> GetCompressedRepresentation() const;
-
//! transitive comparison of WordsBitmap
inline int Compare (const WordsBitmap &compare) const
@@ -172,6 +167,11 @@ public:
return std::memcmp(m_bitmap, compare.m_bitmap, thisSize);
}
+ inline bool operator<(const WordsBitmap &compare) const
+ {
+ return Compare(compare) < 0;
+ }
+
inline size_t GetEdgeToTheLeftOf(size_t l) const
{
if (l == 0) return l;