This commit is contained in:
Hieu Hoang 2013-08-15 21:14:04 +01:00
parent 49e36cebc2
commit 9f92642e59
13 changed files with 65 additions and 66 deletions

View File

@ -379,9 +379,9 @@ void IOWrapper::OutputBestHypo(const Hypothesis *hypo, long /*translationId*/, c
Backtrack(hypo);
VERBOSE(3,"0" << std::endl);
if (!m_surpressSingleBestOutput) {
if (StaticData::Instance().GetOutputHypoScore()) {
cout << hypo->GetTotalScore() << " ";
}
if (StaticData::Instance().GetOutputHypoScore()) {
cout << hypo->GetTotalScore() << " ";
}
if (StaticData::Instance().IsPathRecoveryEnabled()) {
OutputInput(cout, hypo);

View File

@ -15,8 +15,8 @@ void ChartTranslationOption::Evaluate(const InputType &input, const InputPath &i
const std::vector<FeatureFunction*> &ffs = FeatureFunction::GetFeatureFunctions();
for (size_t i = 0; i < ffs.size(); ++i) {
const FeatureFunction &ff = *ffs[i];
ff.Evaluate(input, inputPath, m_scoreBreakdown);
const FeatureFunction &ff = *ffs[i];
ff.Evaluate(input, inputPath, m_scoreBreakdown);
}
}
}

View File

@ -151,8 +151,8 @@ void ChartTranslationOptionList::Evaluate(const InputType &input, const InputPat
{
CollType::iterator iter;
for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) {
ChartTranslationOptions &transOpts = **iter;
transOpts.Evaluate(input, inputPath);
ChartTranslationOptions &transOpts = **iter;
transOpts.Evaluate(input, inputPath);
}
}

View File

@ -68,8 +68,8 @@ void ChartTranslationOptions::Evaluate(const InputType &input, const InputPath &
{
CollType::iterator iter;
for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) {
ChartTranslationOption &transOpt = **iter;
transOpt.Evaluate(input, inputPath);
ChartTranslationOption &transOpt = **iter;
transOpt.Evaluate(input, inputPath);
}
}

View File

@ -12,29 +12,29 @@ namespace Moses
InputFeature::InputFeature(const std::string &line)
:StatelessFeatureFunction("InputFeature", line)
{
ReadParameters();
ReadParameters();
}
void InputFeature::SetParameter(const std::string& key, const std::string& value)
{
if (key == "num-input-features") {
m_numInputScores = Scan<size_t>(value);
} else if (key == "real-word-count") {
m_numRealWordCount = Scan<size_t>(value);
} else {
StatelessFeatureFunction::SetParameter(key, value);
}
if (key == "num-input-features") {
m_numInputScores = Scan<size_t>(value);
} else if (key == "real-word-count") {
m_numRealWordCount = Scan<size_t>(value);
} else {
StatelessFeatureFunction::SetParameter(key, value);
}
}
void InputFeature::Evaluate(const InputType &input
, const InputPath &inputPath
, ScoreComponentCollection &scoreBreakdown) const
, const InputPath &inputPath
, ScoreComponentCollection &scoreBreakdown) const
{
const ScoreComponentCollection *scores = inputPath.GetInputScore();
if (scores) {
const ScoreComponentCollection *scores = inputPath.GetInputScore();
if (scores) {
}
}
}
} // namespace

View File

@ -97,9 +97,8 @@ public:
return vertex.BestChild();
}
void Evaluate(const InputType &input, const InputPath &inputPath)
{
// TODO for input lattice
void Evaluate(const InputType &input, const InputPath &inputPath) {
// TODO for input lattice
}
private:
lm::WordIndex Convert(const Word &word) const;

View File

@ -250,7 +250,7 @@ bool Sentence::XmlOverlap(size_t startPos, size_t endPos) const
return false;
}
void Sentence::GetXmlTranslationOptions(std::vector <TranslationOption*> &list) const
void Sentence::GetXmlTranslationOptions(std::vector <TranslationOption*> &list) const
{
for (std::vector<XmlOption*>::const_iterator iterXMLOpts = m_xmlOptions.begin();
iterXMLOpts != m_xmlOptions.end(); ++iterXMLOpts) {

View File

@ -37,9 +37,9 @@ struct CompareTargetPhrase {
TargetPhraseCollection::TargetPhraseCollection(const TargetPhraseCollection &copy)
{
for (const_iterator iter = copy.begin(); iter != copy.end(); ++iter) {
const TargetPhrase &origTP = **iter;
TargetPhrase *newTP = new TargetPhrase(origTP);
Add(newTP);
const TargetPhrase &origTP = **iter;
TargetPhrase *newTP = new TargetPhrase(origTP);
Add(newTP);
}
}

View File

@ -43,34 +43,33 @@ const TargetPhraseCollection *PhraseDictionary::GetTargetPhraseCollection(const
{
const TargetPhraseCollection *ret;
if (m_useCache) {
size_t hash = hash_value(src);
size_t hash = hash_value(src);
std::map<size_t, const TargetPhraseCollection*>::const_iterator iter;
std::map<size_t, const TargetPhraseCollection*>::const_iterator iter;
{ // scope of read lock
#ifdef WITH_THREADS
boost::shared_lock<boost::shared_mutex> read_lock(m_accessLock);
#endif
iter = m_cache.find(hash);
}
{
// scope of read lock
#ifdef WITH_THREADS
boost::shared_lock<boost::shared_mutex> read_lock(m_accessLock);
#endif
iter = m_cache.find(hash);
}
if (iter == m_cache.end()) {
ret = GetTargetPhraseCollectionNonCache(src);
if (ret) {
ret = new TargetPhraseCollection(*ret);
}
if (iter == m_cache.end()) {
ret = GetTargetPhraseCollectionNonCache(src);
if (ret) {
ret = new TargetPhraseCollection(*ret);
}
#ifdef WITH_THREADS
boost::unique_lock<boost::shared_mutex> lock(m_accessLock);
#endif
m_cache[hash] = ret;
}
else {
ret = iter->second;
}
}
else {
ret = GetTargetPhraseCollectionNonCache(src);
#ifdef WITH_THREADS
boost::unique_lock<boost::shared_mutex> lock(m_accessLock);
#endif
m_cache[hash] = ret;
} else {
ret = iter->second;
}
} else {
ret = GetTargetPhraseCollectionNonCache(src);
}
return ret;

View File

@ -34,11 +34,11 @@ PhraseDictionaryTreeAdaptor(const std::string &line)
PhraseDictionaryTreeAdaptor::~PhraseDictionaryTreeAdaptor()
{
std::map<size_t, const TargetPhraseCollection*>::const_iterator iter;
for (iter = m_cache.begin(); iter != m_cache.end(); ++iter) {
const TargetPhraseCollection *coll = iter->second;
delete coll;
}
std::map<size_t, const TargetPhraseCollection*>::const_iterator iter;
for (iter = m_cache.begin(); iter != m_cache.end(); ++iter) {
const TargetPhraseCollection *coll = iter->second;
delete coll;
}
}
void PhraseDictionaryTreeAdaptor::Load()

View File

@ -120,8 +120,9 @@ public:
}
//!List of unknowns (OOVs)
const std::vector<const Phrase*>& GetUnknownSources() const
{ return m_unksrcs; }
const std::vector<const Phrase*>& GetUnknownSources() const {
return m_unksrcs;
}
//! get length/size of source input
size_t GetSize() const {

View File

@ -129,11 +129,11 @@ void TranslationOptionCollectionConfusionNet::ProcessUnknownWord(size_t sourcePo
InputPathList::const_iterator iterInputPath;
size_t j=0;
for(iterCol = coll.begin(), iterInputPath = inputPathList.begin();
iterCol != coll.end();
++iterCol , ++iterInputPath) {
const InputPath &inputPath = **iterInputPath;
size_t length = source.GetColumnIncrement(sourcePos, j++);
const Scores &inputScores = iterCol->second;
iterCol != coll.end();
++iterCol , ++iterInputPath) {
const InputPath &inputPath = **iterInputPath;
size_t length = source.GetColumnIncrement(sourcePos, j++);
const Scores &inputScores = iterCol->second;
ProcessOneUnknownWord(inputPath ,sourcePos, length, &inputScores);
}

View File

@ -122,7 +122,7 @@ bool TranslationOptionCollectionText::ViolatesXmlOptionsConstraint(size_t startP
}
if (match) {
return false; // no violation if matching xml option found
}
}
}
return true;
}