mosesdecoder/moses/src/Util.h File Reference

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <limits>
#include <map>
#include <cstdlib>
#include <cstring>
#include "util/check.hh"
#include "TypeDef.h"

Go to the source code of this file.

Namespaces

namespace  Moses

Defines

#define TRACE_ERR(str)   do {} while (false)
#define VERBOSE(level, str)   { if (StaticData::Instance().GetVerboseLevel() >= level) { TRACE_ERR(str); } }
#define IFVERBOSE(level)   if (StaticData::Instance().GetVerboseLevel() >= level)
#define TO_STRING()   std::string ToString() const;
#define TO_STRING_BODY(CLASS)
 definition of ToString() function to go in .cpp file. Can be used for any class that can be piped to a stream

Functions

const std::string Moses::Trim (const std::string &str, const std::string dropChars=" \t\n\r")
 delete white spaces at beginning and end of string
const std::string Moses::ToLower (const std::string &str)
template<typename T >
std::string Moses::SPrint (const T &input)
 get string representation of any object/variable, as long as it can pipe to a stream
template<typename T >
Moses::Scan (const std::string &input)
 convert string to variable of type T. Used to reading floats, int etc from files
template<>
std::string Moses::Scan< std::string > (const std::string &input)
 just return input
template<>
bool Moses::Scan< bool > (const std::string &input)
 Specialisation to understand yes/no y/n true/false 0/1.
template<typename T >
std::vector< T > Moses::Scan (const std::vector< std::string > &input)
 convert vectors of string to vectors of type T variables
template<typename T >
void Moses::Scan (std::vector< T > &output, const std::vector< std::string > &input)
 speeded up version of above
std::string Moses::Replace (const std::string &str, const std::string &todelStr, const std::string &toaddStr)
std::vector< std::string > Moses::Tokenize (const std::string &input, const std::string &delimiters=" \t")
 tokenise input string to vector of type T
void Moses::Tokenize (std::vector< std::string > &output, const std::string &str, const std::string &delimiters=" \t")
template<typename T >
void Moses::Tokenize (std::vector< T > &output, const std::string &input, const std::string &delimiters=" \t")
std::vector< std::string > Moses::TokenizeMultiCharSeparator (const std::string &str, const std::string &separator)
void Moses::TokenizeMultiCharSeparator (std::vector< std::string > &output, const std::string &str, const std::string &separator)
template<typename T >
std::string Moses::Join (const std::string &delimiter, const std::vector< T > &items)
float Moses::TransformScore (float prob)
 transform prob to natural log score
float Moses::UntransformScore (float score)
 transform natural log score to prob. Not currently used
float Moses::TransformLMScore (float irstScore)
 irst number are in log 10, transform to natural log
float Moses::UntransformLMScore (float logNScore)
float Moses::FloorScore (float logScore)
 make sure score doesn't fall below LOWEST_SCORE
float Moses::CalcTranslationScore (const std::vector< float > &probVector, const std::vector< float > &weightT)
template<class COLL >
void Moses::RemoveAllInColl (COLL &coll)
 delete and remove every element of a collection object such as map, set, list etc
string Moses::GetTempFolder ()
 x-platform reference to temp folder
std::string Moses::GetMD5Hash (const std::string &filePath)
 MD5 hash of a file.
template<typename T >
void Moses::ShrinkToFit (T &v)
 save memory by getting rid of spare, unused elements in a collection
bool Moses::FileExists (const std::string &filePath)
void Moses::ResetUserTime ()
void Moses::PrintUserTime (const std::string &message)
double Moses::GetUserTime ()
std::map< std::string,
std::string > 
Moses::ProcessAndStripSGML (std::string &line)
std::string Moses::GetFirstString (const std::string &str, int &first_pos, const std::string &delimiters=" \t")
template<class T >
Moses::log_sum (T log_a, T log_b)


Define Documentation

#define IFVERBOSE ( level   )     if (StaticData::Instance().GetVerboseLevel() >= level)

 
#define TO_STRING (  )     std::string ToString() const;

declaration of ToString() function to go in header for each class. This function, as well as the operator<< fn for each class, is for debugging purposes only. The output format is likely to change from time-to-time as classes are updated so shouldn't be relied upon for any decoding algorithm

Definition at line 302 of file Util.h.

#define TO_STRING_BODY ( CLASS   ) 

Value:

std::string CLASS::ToString() const     \
        {                                                                                                                       \
                std::stringstream out;                  \
                out << *this;                                                           \
                return out.str();                                               \
        }                                                                                                                       \
definition of ToString() function to go in .cpp file. Can be used for any class that can be piped to a stream

Definition at line 305 of file Util.h.

#define TRACE_ERR ( str   )     do {} while (false)

Outputting debugging/verbose information to stderr. Use TRACE_ENABLE flag to redirect tracing output into oblivion so that you can output your own ad-hoc debugging info. However, if you use stderr directly, please delete calls to it once you finished debugging so that it won't clutter up. Also use TRACE_ENABLE to turn off output of any debugging info when compiling for a gui front-end so that running gui won't generate output on command line

Definition at line 53 of file Util.h.

Referenced by Moses::ChartHypothesisCollection::AddHypothesis(), Moses::HypothesisStackNormal::AddPrune(), Moses::HypothesisStackCubePruning::AddPrune(), Moses::PDTAimp::CacheSource(), Moses::Manager::CalcDecoderStatistics(), Moses::TranslationOptionCollection::CalcFutureScore(), Moses::PrefixTreeF< T, D >::changeData(), MosesTuning::Timer::check(), Moses::Timer::check(), Moses::LanguageModelIRST::CleanUpAfterSentenceProcessing(), Moses::WordLattice::ComputeDistortionDistance(), Moses::PrefixTreeF< T, D >::create(), Moses::PhraseDictionaryTree::Create(), Moses::PDTAimp::Create(), Moses::LexicalReorderingTableTree::Create(), Moses::Phrase::CreateFromString(), Moses::fRead(), Moses::fReadString(), Moses::fReadVector(), Moses::fSeek(), Moses::fWrite(), Moses::fWriteString(), Moses::fWriteVector(), Moses::ChartManager::GetSearchGraph(), Moses::ConfusionNet::GetStringRep(), Moses::ConfusionNet::GetSubString(), Moses::ConfusionNet::GetWord(), Moses::PhraseDictionaryFuzzyMatch::InitializeForInput(), Moses::WordLattice::InitializeFromPCNDataType(), Moses::TranslationOptionCollection::InsertPreCalculatedScores(), Moses::ChartManager::InsertPreCalculatedScores(), Moses::RuleTableLoaderStandard::Load(), Moses::StaticData::LoadData(), Moses::StaticData::LoadGenerationTables(), Moses::Parameter::LoadParam(), main(), Moses::SearchCubePruning::OutputHypoStack(), Moses::SearchNormal::OutputHypoStackSize(), Moses::SearchCubePruning::OutputHypoStackSize(), Moses::ParseXmlTagAttribute(), Moses::PhraseDictionaryTree::PhraseDictionaryTree(), Moses::Hypothesis::PrintHypothesis(), Moses::PhraseDictionaryTree::PrintTargetCandidates(), Moses::ProcessAndStripSGML(), Moses::ProcessAndStripXMLTags(), Moses::BitmapContainer::ProcessBestHypothesis(), Moses::DecodeStepTranslation::ProcessInitialTranslation(), Moses::HypothesisStackNormal::PruneToSize(), Moses::HypothesisStackCubePruning::PruneToSize(), Moses::ChartHypothesisCollection::PruneToSize(), Moses::Sentence::Read(), Moses::PrefixTreeMap::Read(), Moses::PhraseDictionaryTree::Read(), Moses::PDTimp::Read(), Moses::ConfusionNet::ReadFormat0(), MosesCmd::ReadInput(), MosesTuning::Timer::restart(), MosesCmd::TranslationTask::Run(), MosesTuning::Timer::start(), Moses::Timer::start(), Moses::TokenizeXml(), Moses::LanguageModelIRST::~LanguageModelIRST(), and Moses::PDTAimp::~PDTAimp().

#define VERBOSE ( level,
str   )     { if (StaticData::Instance().GetVerboseLevel() >= level) { TRACE_ERR(str); } }

verbose macros

Definition at line 58 of file Util.h.

Referenced by Moses::HypothesisStackNormal::Add(), Moses::HypothesisStackCubePruning::Add(), Moses::ChartHypothesisCollection::Add(), Moses::ChartHypothesisCollection::AddHypothesis(), Moses::HypothesisStackNormal::AddPrune(), Moses::HypothesisStackCubePruning::AddPrune(), MosesCmd::IOWrapper::Backtrack(), Moses::BackwardsEdge::BackwardsEdge(), MosesCmd::calcNgramExpectations(), Moses::ReorderingConstraint::Check(), Moses::WordLattice::ComputeDistortionDistance(), Moses::TranslationOptionCollection::CreateTranslationOptions(), Moses::DecodeFeature::DecodeFeature(), Moses::DecodeStep::DecodeStep(), MosesCmd::doConsensusDecoding(), Moses::SyntacticLanguageModel::Evaluate(), Moses::ReorderingConstraint::FinalizeWalls(), MosesCmd::GetIOWrapper(), MosesCmd::getLatticeMBRNBest(), Moses::StaticData::GetTranslationSystem(), Moses::LanguageModelIRST::Load(), Moses::LexicalReorderingTable::LoadAvailable(), Moses::StaticData::LoadData(), Moses::StaticData::LoadGenerationTables(), Moses::StaticData::LoadLexicalReorderingModel(), Moses::StaticData::LoadPhraseTables(), MosesCmd::IOWrapper::OutputBestHypo(), Moses::ProcessAndStripXMLTags(), Moses::DecodeStepTranslation::ProcessInitialTranslation(), Moses::SearchNormalBatch::ProcessSentence(), Moses::SearchNormal::ProcessSentence(), Moses::SearchCubePruning::ProcessSentence(), Moses::Manager::ProcessSentence(), Moses::ChartManager::ProcessSentence(), Moses::TranslationOptionCollection::Prune(), MosesCmd::pruneLatticeFB(), Moses::HypothesisStackNormal::PruneToSize(), Moses::HypothesisStackCubePruning::PruneToSize(), Moses::ChartHypothesisCollection::PruneToSize(), Moses::ConfusionNet::ReadF(), Moses::ConfusionNet::ReadFormat0(), Moses::ConfusionNet::ReadFormat1(), Moses::StaticData::ReduceTransOptCache(), Moses::ScoreComponentCollection::RegisterScoreProducer(), MosesCmd::TranslationTask::Run(), Moses::SearchNormal::SearchNormal(), Moses::ReorderingConstraint::SetWall(), Moses::ReorderingConstraint::SetZone(), Moses::SyntacticLanguageModel::SyntacticLanguageModel(), Moses::SyntacticLanguageModelState< MY, MX, YS, B >::SyntacticLanguageModelState(), Moses::ChartManager::~ChartManager(), Moses::SyntacticLanguageModel::~SyntacticLanguageModel(), Moses::SyntacticLanguageModelFiles< MH, MO >::~SyntacticLanguageModelFiles(), and Moses::SyntacticLanguageModelState< MY, MX, YS, B >::~SyntacticLanguageModelState().


Generated on Mon Nov 12 00:30:23 2012 for Moses by  doxygen 1.5.9