Moses::WordsBitmap Class Reference

#include <WordsBitmap.h>

List of all members.

Public Member Functions

 WordsBitmap (size_t size, const std::vector< bool > &initializer)
 Create WordsBitmap of length size, and initialise with vector.
 WordsBitmap (size_t size)
 Create WordsBitmap of length size and initialise.
 WordsBitmap (const WordsBitmap &copy)
 Deep copy.
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 IsAdjacent (size_t startPos, size_t endPos) const
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
void SetValue (size_t startPos, size_t endPos, bool value)
 set value between 2 positions, inclusive
void SetValue (WordsRange const &range, bool val)
bool IsComplete () const
 whether every word has been translated
bool Overlap (const WordsRange &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 WordsBitmap &other) const
bool operator!= (const WordsBitmap &other) const
 TO_STRING ()

Friends

std::ostream & operator<< (std::ostream &out, const WordsBitmap &wordsBitmap)


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 WordsBitmap.h.


Constructor & Destructor Documentation

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

Create WordsBitmap of length size, and initialise with vector.

Definition at line 85 of file WordsBitmap.h.

References NOT_FOUND.

Moses::WordsBitmap::WordsBitmap ( size_t  size  )  [inline]

Create WordsBitmap of length size and initialise.

Definition at line 101 of file WordsBitmap.h.

Moses::WordsBitmap::WordsBitmap ( const WordsBitmap copy  )  [inline]

Deep copy.

Definition at line 106 of file WordsBitmap.h.


Member Function Documentation

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

Definition at line 186 of file WordsBitmap.h.

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

Here is the caller graph for this function:

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

Definition at line 194 of file WordsBitmap.h.

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

Here is the caller graph for this function:

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

WordsBitmapID Moses::WordsBitmap::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 204 of file WordsBitmap.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::WordsBitmap::GetIDPlus ( size_t  startPos,
size_t  endPos 
) const [inline]

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

Definition at line 222 of file WordsBitmap.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::WordsBitmap::GetLastGapPos (  )  const [inline]

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

Definition at line 122 of file WordsBitmap.h.

References NOT_FOUND.

Referenced by BOOST_AUTO_TEST_CASE(), and IsAdjacent().

Here is the caller graph for this function:

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

position of last translated word

Definition at line 134 of file WordsBitmap.h.

References NOT_FOUND.

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

Here is the caller graph for this function:

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

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

number of elements

Definition at line 182 of file WordsBitmap.h.

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

Here is the caller graph for this function:

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

size_t Moses::WordsBitmap::hash (  )  const

Definition at line 39 of file WordsBitmap.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::WordsBitmap::IsAdjacent ( size_t  startPos,
size_t  endPos 
) const

Definition at line 30 of file WordsBitmap.cpp.

References GetFirstGapPos(), GetLastGapPos(), and GetNumWordsCovered().

Here is the call graph for this function:

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

whether every word has been translated

Definition at line 170 of file WordsBitmap.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::WordsBitmap::operator!= ( const WordsBitmap other  )  const [inline]

Definition at line 247 of file WordsBitmap.h.

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

Definition at line 45 of file WordsBitmap.cpp.

bool Moses::WordsBitmap::Overlap ( const WordsRange compare  )  const [inline]

whether the wordrange overlaps with any translated word in this bitmap

Definition at line 174 of file WordsBitmap.h.

References Moses::WordsRange::GetEndPos(), and Moses::WordsRange::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::WordsBitmap::SetValue ( WordsRange const &  range,
bool  val 
) [inline]

Definition at line 165 of file WordsBitmap.h.

References Moses::WordsRange::GetEndPos(), Moses::WordsRange::GetStartPos(), and SetValue().

Here is the call graph for this function:

void Moses::WordsBitmap::SetValue ( size_t  startPos,
size_t  endPos,
bool  value 
) [inline]

set value between 2 positions, inclusive

Definition at line 157 of file WordsBitmap.h.

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

Moses::WordsBitmap::TO_STRING (  ) 


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const WordsBitmap wordsBitmap 
) [friend]

Definition at line 51 of file WordsBitmap.cpp.


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

Generated on Sun Oct 25 00:34:32 2015 for Moses by  doxygen 1.5.9