Moses::Bitmap Class Reference

#include <Bitmap.h>

List of all members.

Public Member Functions

 Bitmap (size_t size, const std::vector< bool > &initializer)
 Create Bitmap of length size, and initialise with vector.
 Bitmap (size_t size)
 Create Bitmap of length size and initialise.
 Bitmap (const Bitmap &copy)
 Deep copy.
 Bitmap (const Bitmap &copy, const Range &range)
size_t GetNumWordsCovered () const
 Count of words translated.
size_t GetFirstGapPos () const
 position of 1st word not yet translated, or NOT_FOUND if everything already translated
size_t GetLastGapPos () const
 position of last word not yet translated, or NOT_FOUND if everything already translated
size_t GetLastPos () const
 position of last translated word
bool GetValue (size_t pos) const
 whether a word has been translated at a particular position
void SetValue (size_t pos, bool value)
 set value at a particular position
bool IsComplete () const
 whether every word has been translated
bool Overlap (const Range &compare) const
 whether the wordrange overlaps with any translated word in this bitmap
size_t GetSize () const
 number of elements
size_t GetEdgeToTheLeftOf (size_t l) const
size_t GetEdgeToTheRightOf (size_t r) const
WordsBitmapID GetID () const
 converts bitmap into an integer ID: it consists of two parts: the first 16 bit are the pattern between the first gap and the last word-1, the second 16 bit are the number of filled positions. enforces a sentence length limit of 65535 and a max distortion of 16
WordsBitmapID GetIDPlus (size_t startPos, size_t endPos) const
 converts bitmap into an integer ID, with an additional span covered
size_t hash () const
bool operator== (const Bitmap &other) const
bool operator!= (const Bitmap &other) const
 TO_STRING ()

Friends

std::ostream & operator<< (std::ostream &out, const Bitmap &bitmap)


Detailed Description

Vector of boolean to represent whether a word has been translated or not.

Implemented using a vector of char, which is usually the same representation for the elements that a C array of bool would use. A vector of bool, or a Boost dynamic_bitset, could be much more efficient in theory. Unfortunately algorithms like std::find() are not optimized for vector<bool> on gcc or clang, and dynamic_bitset lacks all the optimized search operations we want. Only benchmarking will tell what works best. Perhaps dynamic_bitset could still be a dramatic improvement, if we flip the meaning of the bits around so we can use its find_first() and find_next() for the most common searches.

Definition at line 50 of file Bitmap.h.


Constructor & Destructor Documentation

Moses::Bitmap::Bitmap ( size_t  size,
const std::vector< bool > &  initializer 
) [explicit]

Create Bitmap of length size, and initialise with vector.

Definition at line 30 of file Bitmap.cpp.

References count, and NOT_FOUND.

Moses::Bitmap::Bitmap ( size_t  size  )  [explicit]

Create Bitmap of length size and initialise.

Definition at line 49 of file Bitmap.cpp.

Moses::Bitmap::Bitmap ( const Bitmap copy  )  [explicit]

Deep copy.

Definition at line 58 of file Bitmap.cpp.

Moses::Bitmap::Bitmap ( const Bitmap copy,
const Range range 
) [explicit]

Definition at line 65 of file Bitmap.cpp.


Member Function Documentation

size_t Moses::Bitmap::GetEdgeToTheLeftOf ( size_t  l  )  const [inline]

Definition at line 180 of file Bitmap.h.

Referenced by Moses::SearchNormal::ProcessOneHypothesis().

Here is the caller graph for this function:

size_t Moses::Bitmap::GetEdgeToTheRightOf ( size_t  r  )  const [inline]

Definition at line 188 of file Bitmap.h.

Referenced by Moses::SearchNormal::ProcessOneHypothesis().

Here is the caller graph for this function:

size_t Moses::Bitmap::GetFirstGapPos (  )  const [inline]

WordsBitmapID Moses::Bitmap::GetID (  )  const [inline]

converts bitmap into an integer ID: it consists of two parts: the first 16 bit are the pattern between the first gap and the last word-1, the second 16 bit are the number of filled positions. enforces a sentence length limit of 65535 and a max distortion of 16

Definition at line 198 of file Bitmap.h.

References end, GetFirstGapPos(), GetLastPos(), GetValue(), and NOT_FOUND.

Referenced by Moses::HypothesisStackNormal::Add(), Moses::HypothesisStackNormal::GetWorstScoreForBitmap(), and Moses::HypothesisStackNormal::PruneToSize().

Here is the call graph for this function:

Here is the caller graph for this function:

WordsBitmapID Moses::Bitmap::GetIDPlus ( size_t  startPos,
size_t  endPos 
) const [inline]

converts bitmap into an integer ID, with an additional span covered

Definition at line 216 of file Bitmap.h.

References end, GetFirstGapPos(), GetLastPos(), GetValue(), and NOT_FOUND.

Referenced by Moses::SearchNormal::ExpandHypothesis().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t Moses::Bitmap::GetLastGapPos (  )  const [inline]

position of last word not yet translated, or NOT_FOUND if everything already translated

Definition at line 121 of file Bitmap.h.

References NOT_FOUND.

Referenced by BOOST_AUTO_TEST_CASE().

Here is the caller graph for this function:

size_t Moses::Bitmap::GetLastPos (  )  const [inline]

position of last translated word

Definition at line 133 of file Bitmap.h.

References NOT_FOUND.

Referenced by BOOST_AUTO_TEST_CASE(), Moses::SquareMatrix::CalcEstimatedScore(), Moses::ReorderingConstraint::Check(), GetID(), and GetIDPlus().

Here is the caller graph for this function:

size_t Moses::Bitmap::GetNumWordsCovered (  )  const [inline]

size_t Moses::Bitmap::GetSize (  )  const [inline]

number of elements

Definition at line 176 of file Bitmap.h.

Referenced by BOOST_AUTO_TEST_CASE(), Moses::SquareMatrix::CalcEstimatedScore(), Moses::BleuScoreFeature::EvaluateWhenApplied(), and IsComplete().

Here is the caller graph for this function:

bool Moses::Bitmap::GetValue ( size_t  pos  )  const [inline]

size_t Moses::Bitmap::hash (  )  const

Definition at line 74 of file Bitmap.cpp.

References Moses::hash_value().

Referenced by Moses::Hypothesis::hash().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Moses::Bitmap::IsComplete (  )  const [inline]

whether every word has been translated

Definition at line 164 of file Bitmap.h.

References GetNumWordsCovered(), and GetSize().

Referenced by Moses::calcNgramExpectations(), Moses::TargetNgramFeature::EvaluateWhenApplied(), Moses::TargetBigramFeature::EvaluateWhenApplied(), and Moses::Hypothesis::IsSourceCompleted().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Moses::Bitmap::operator!= ( const Bitmap other  )  const [inline]

Definition at line 241 of file Bitmap.h.

bool Moses::Bitmap::operator== ( const Bitmap other  )  const

Definition at line 80 of file Bitmap.cpp.

bool Moses::Bitmap::Overlap ( const Range compare  )  const [inline]

whether the wordrange overlaps with any translated word in this bitmap

Definition at line 168 of file Bitmap.h.

References Moses::Range::GetEndPos(), and Moses::Range::GetStartPos().

Referenced by Moses::TranslationOption::Overlap(), and Moses::SearchNormal::ProcessOneHypothesis().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Bitmap::SetValue ( size_t  pos,
bool  value 
) [inline]

set value at a particular position

Definition at line 148 of file Bitmap.h.

Referenced by BOOST_AUTO_TEST_CASE(), and Moses::OpSequenceModel::EvaluateWhenApplied().

Here is the caller graph for this function:

Moses::Bitmap::TO_STRING (  ) 


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const Bitmap bitmap 
) [friend]

Definition at line 86 of file Bitmap.cpp.


The documentation for this class was generated from the following files:

Generated on Thu Jul 6 00:32:52 2017 for Moses by  doxygen 1.5.9