make class name consistent for chart & pb decoders

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@3560 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
hieuhoang1972 2010-09-23 16:54:32 +00:00
parent 0b6a29327c
commit 4d34e5155e
13 changed files with 877 additions and 1188 deletions

View File

@ -17,12 +17,8 @@
1ED4FBBC11BDBC9F004E826A /* ChartHypothesisCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ED4FB9D11BDBC9F004E826A /* ChartHypothesisCollection.h */; };
1ED4FBBD11BDBC9F004E826A /* ChartManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ED4FB9E11BDBC9F004E826A /* ChartManager.cpp */; };
1ED4FBBE11BDBC9F004E826A /* ChartManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ED4FB9F11BDBC9F004E826A /* ChartManager.h */; };
1ED4FBBF11BDBC9F004E826A /* ChartTranslationOption.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ED4FBA011BDBC9F004E826A /* ChartTranslationOption.cpp */; };
1ED4FBC011BDBC9F004E826A /* ChartTranslationOption.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ED4FBA111BDBC9F004E826A /* ChartTranslationOption.h */; };
1ED4FBC111BDBC9F004E826A /* ChartTranslationOptionCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ED4FBA211BDBC9F004E826A /* ChartTranslationOptionCollection.cpp */; };
1ED4FBC211BDBC9F004E826A /* ChartTranslationOptionCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ED4FBA311BDBC9F004E826A /* ChartTranslationOptionCollection.h */; };
1ED4FBC311BDBC9F004E826A /* ChartTranslationOptionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ED4FBA411BDBC9F004E826A /* ChartTranslationOptionList.cpp */; };
1ED4FBC411BDBC9F004E826A /* ChartTranslationOptionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ED4FBA511BDBC9F004E826A /* ChartTranslationOptionList.h */; };
1ED4FBC511BDBC9F004E826A /* ChartTrellisNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ED4FBA611BDBC9F004E826A /* ChartTrellisNode.cpp */; };
1ED4FBC611BDBC9F004E826A /* ChartTrellisNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ED4FBA711BDBC9F004E826A /* ChartTrellisNode.h */; };
1ED4FBC711BDBC9F004E826A /* ChartTrellisPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ED4FBA811BDBC9F004E826A /* ChartTrellisPath.cpp */; };
@ -49,12 +45,8 @@
1ED4FB9D11BDBC9F004E826A /* ChartHypothesisCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChartHypothesisCollection.h; path = src/ChartHypothesisCollection.h; sourceTree = "<group>"; };
1ED4FB9E11BDBC9F004E826A /* ChartManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChartManager.cpp; path = src/ChartManager.cpp; sourceTree = "<group>"; };
1ED4FB9F11BDBC9F004E826A /* ChartManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChartManager.h; path = src/ChartManager.h; sourceTree = "<group>"; };
1ED4FBA011BDBC9F004E826A /* ChartTranslationOption.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChartTranslationOption.cpp; path = src/ChartTranslationOption.cpp; sourceTree = "<group>"; };
1ED4FBA111BDBC9F004E826A /* ChartTranslationOption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChartTranslationOption.h; path = src/ChartTranslationOption.h; sourceTree = "<group>"; };
1ED4FBA211BDBC9F004E826A /* ChartTranslationOptionCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChartTranslationOptionCollection.cpp; path = src/ChartTranslationOptionCollection.cpp; sourceTree = "<group>"; };
1ED4FBA311BDBC9F004E826A /* ChartTranslationOptionCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChartTranslationOptionCollection.h; path = src/ChartTranslationOptionCollection.h; sourceTree = "<group>"; };
1ED4FBA411BDBC9F004E826A /* ChartTranslationOptionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChartTranslationOptionList.cpp; path = src/ChartTranslationOptionList.cpp; sourceTree = "<group>"; };
1ED4FBA511BDBC9F004E826A /* ChartTranslationOptionList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChartTranslationOptionList.h; path = src/ChartTranslationOptionList.h; sourceTree = "<group>"; };
1ED4FBA611BDBC9F004E826A /* ChartTrellisNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChartTrellisNode.cpp; path = src/ChartTrellisNode.cpp; sourceTree = "<group>"; };
1ED4FBA711BDBC9F004E826A /* ChartTrellisNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChartTrellisNode.h; path = src/ChartTrellisNode.h; sourceTree = "<group>"; };
1ED4FBA811BDBC9F004E826A /* ChartTrellisPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChartTrellisPath.cpp; path = src/ChartTrellisPath.cpp; sourceTree = "<group>"; };
@ -107,12 +99,8 @@
1ED4FB9D11BDBC9F004E826A /* ChartHypothesisCollection.h */,
1ED4FB9E11BDBC9F004E826A /* ChartManager.cpp */,
1ED4FB9F11BDBC9F004E826A /* ChartManager.h */,
1ED4FBA011BDBC9F004E826A /* ChartTranslationOption.cpp */,
1ED4FBA111BDBC9F004E826A /* ChartTranslationOption.h */,
1ED4FBA211BDBC9F004E826A /* ChartTranslationOptionCollection.cpp */,
1ED4FBA311BDBC9F004E826A /* ChartTranslationOptionCollection.h */,
1ED4FBA411BDBC9F004E826A /* ChartTranslationOptionList.cpp */,
1ED4FBA511BDBC9F004E826A /* ChartTranslationOptionList.h */,
1ED4FBA611BDBC9F004E826A /* ChartTrellisNode.cpp */,
1ED4FBA711BDBC9F004E826A /* ChartTrellisNode.h */,
1ED4FBA811BDBC9F004E826A /* ChartTrellisPath.cpp */,
@ -159,9 +147,7 @@
1ED4FBBA11BDBC9F004E826A /* ChartHypothesis.h in Headers */,
1ED4FBBC11BDBC9F004E826A /* ChartHypothesisCollection.h in Headers */,
1ED4FBBE11BDBC9F004E826A /* ChartManager.h in Headers */,
1ED4FBC011BDBC9F004E826A /* ChartTranslationOption.h in Headers */,
1ED4FBC211BDBC9F004E826A /* ChartTranslationOptionCollection.h in Headers */,
1ED4FBC411BDBC9F004E826A /* ChartTranslationOptionList.h in Headers */,
1ED4FBC611BDBC9F004E826A /* ChartTrellisNode.h in Headers */,
1ED4FBC811BDBC9F004E826A /* ChartTrellisPath.h in Headers */,
1ED4FBCA11BDBC9F004E826A /* ChartTrellisPathCollection.h in Headers */,
@ -218,9 +204,7 @@
1ED4FBB911BDBC9F004E826A /* ChartHypothesis.cpp in Sources */,
1ED4FBBB11BDBC9F004E826A /* ChartHypothesisCollection.cpp in Sources */,
1ED4FBBD11BDBC9F004E826A /* ChartManager.cpp in Sources */,
1ED4FBBF11BDBC9F004E826A /* ChartTranslationOption.cpp in Sources */,
1ED4FBC111BDBC9F004E826A /* ChartTranslationOptionCollection.cpp in Sources */,
1ED4FBC311BDBC9F004E826A /* ChartTranslationOptionList.cpp in Sources */,
1ED4FBC511BDBC9F004E826A /* ChartTrellisNode.cpp in Sources */,
1ED4FBC711BDBC9F004E826A /* ChartTrellisPath.cpp in Sources */,
1ED4FBC911BDBC9F004E826A /* ChartTrellisPathCollection.cpp in Sources */,

View File

@ -22,7 +22,6 @@
#include <algorithm>
#include "ChartCell.h"
#include "ChartTranslationOptionCollection.h"
#include "ChartTranslationOption.h"
#include "ChartCellCollection.h"
#include "Cube.h"
#include "QueueEntry.h"

View File

@ -24,7 +24,6 @@
#include "ChartHypothesis.h"
#include "QueueEntry.h"
#include "ChartCell.h"
#include "ChartTranslationOption.h"
#include "ChartManager.h"
#include "../../moses/src/TargetPhrase.h"
#include "../../moses/src/Phrase.h"

View File

@ -28,7 +28,6 @@
#include "../../moses/src/Phrase.h"
#include "../../moses/src/ChartRule.h"
#include "../../moses/src/ObjectPool.h"
#include "ChartTranslationOption.h"
namespace MosesChart
{

View File

@ -1,59 +0,0 @@
// $Id$
// vim:tabstop=2
/***********************************************************************
Moses - factored phrase-based language decoder
Copyright (C) 2010 Hieu Hoang
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
***********************************************************************/
#include "ChartTranslationOption.h"
#include "../../moses/src/WordsRange.h"
#include "../../moses/src/InputType.h"
#include "../../moses/src/ChartRule.h"
#include "../../moses/src/WordConsumed.h"
using namespace std;
using namespace Moses;
namespace MosesChart
{
TranslationOption::TranslationOption(const WordsRange &wordsRange
, const ChartRule &rule)
:m_rule(rule)
{
//assert(wordsRange.GetStartPos() == rule.GetWordsConsumed().front()->GetWordsRange().GetStartPos());
assert(wordsRange.GetEndPos() == rule.GetLastWordConsumed().GetWordsRange().GetEndPos());
}
TranslationOption::~TranslationOption()
{
}
// friend
ostream& operator<<(ostream& out, const TranslationOption& transOpt)
{
out << transOpt.GetTotalScore()
<< " " << transOpt.GetTargetPhrase()
<< " " << transOpt.GetTargetPhrase().GetScoreBreakdown()
<< " " << transOpt.m_rule;
return out;
}
}

View File

@ -1,74 +0,0 @@
// $Id$
// vim:tabstop=2
/***********************************************************************
Moses - factored phrase-based language decoder
Copyright (C) 2010 Hieu Hoang
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
***********************************************************************/
#pragma once
#include <iostream>
#include <vector>
#include "../../moses/src/TargetPhrase.h"
#include "../../moses/src/WordsRange.h"
#include "../../moses/src/InputType.h"
#include "../../moses/src/ChartRule.h"
namespace MosesChart
{
class TranslationOption
{
friend std::ostream& operator<<(std::ostream& out, const TranslationOption &transOpt);
protected:
const Moses::ChartRule &m_rule; /*< output phrase when using this translation option */
public:
TranslationOption(const Moses::WordsRange &wordsRange
, const Moses::ChartRule &chartRule);
~TranslationOption();
const Moses::ChartRule &GetChartRule() const
{ return m_rule; }
const Moses::TargetPhrase &GetTargetPhrase() const
{ return m_rule.GetTargetPhrase(); }
const std::vector<size_t> &GetWordsConsumedTargetOrder() const
{ return m_rule.GetWordsConsumedTargetOrder(); }
const Moses::WordConsumed &GetLastWordConsumed() const
{ return m_rule.GetLastWordConsumed(); }
const Moses::WordsRange &GetSourceWordsRange() const
{ return m_rule.GetSourceWordsRange(); }
/** return estimate of total cost of this option */
inline size_t GetArity() const
{
return m_rule.GetTargetPhrase().GetArity();
}
/** return estimate of total cost of this option */
inline float GetTotalScore() const
{
return m_rule.GetTargetPhrase().GetFutureScore();
}
};
}

View File

@ -21,7 +21,6 @@
#include <cassert>
#include "ChartTranslationOptionCollection.h"
#include "ChartTranslationOption.h"
#include "ChartCellCollection.h"
#include "../../moses/src/InputType.h"
#include "../../moses/src/StaticData.h"

View File

@ -22,7 +22,6 @@
#pragma once
#include <vector>
#include "ChartTranslationOptionList.h"
#include "../../moses/src/InputType.h"
#include "../../moses/src/DecodeGraph.h"
#include "../../moses/src/ChartRuleCollection.h"
@ -58,7 +57,6 @@ protected:
size_t startPosition
, size_t endPosition
, bool adhereTableLimit);
void Add(TranslationOptionList &translationOptionList);
// for adding 1 trans opt in unknown word proc
void Add(Moses::ChartRule *transOpt, size_t pos);

View File

@ -1,89 +0,0 @@
// $Id$
// vim:tabstop=2
/***********************************************************************
Moses - factored phrase-based language decoder
Copyright (C) 2010 Hieu Hoang
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
***********************************************************************/
#include <algorithm>
#include <iostream>
#include "ChartTranslationOptionList.h"
#include "../../moses/src/Util.h"
#include "../../moses/src/StaticData.h"
using namespace Moses;
using namespace std;
namespace MosesChart
{
TranslationOptionList::~TranslationOptionList()
{
RemoveAllInColl(m_coll);
}
void TranslationOptionList::Add(TranslationOption *transOpt)
{
m_coll.push_back(transOpt);
}
void TranslationOptionList::Sort()
{
// keep only those over best + threshold
float scoreThreshold = -std::numeric_limits<float>::infinity();
CollType::const_iterator iter;
for (iter = m_coll.begin(); iter != m_coll.end(); ++iter)
{
const TranslationOption *transOpt = *iter;
float score = transOpt->GetTotalScore();
scoreThreshold = (score > scoreThreshold) ? score : scoreThreshold;
}
scoreThreshold += StaticData::Instance().GetTranslationOptionThreshold();
size_t ind = 0;
while (ind < m_coll.size())
{
const TranslationOption *transOpt = m_coll[ind];
if (transOpt->GetTotalScore() < scoreThreshold)
{
delete transOpt;
m_coll.erase(m_coll.begin() + ind);
}
else
{
ind++;
}
}
std::sort(m_coll.begin(), m_coll.end(), ChartTranslationOptionOrderer());
}
std::ostream& operator<<(std::ostream &out, const TranslationOptionList &list)
{
TranslationOptionList::const_iterator iter;
for (iter = list.begin(); iter != list.end(); ++iter)
{
out << **iter << endl;
}
return out;
}
}

View File

@ -1,80 +0,0 @@
// $Id$
// vim:tabstop=2
/***********************************************************************
Moses - factored phrase-based language decoder
Copyright (C) 2010 Hieu Hoang
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
***********************************************************************/
#pragma once
#include <vector>
#include "../../moses/src/WordsRange.h"
#include "ChartTranslationOption.h"
namespace MosesChart
{
class ChartTranslationOptionOrderer
{
public:
bool operator()(const TranslationOption* transOptA, const TranslationOption* transOptB) const
{
/*
if (transOptA->GetArity() != transOptB->GetArity())
{
return transOptA->GetArity() < transOptB->GetArity();
}
*/
return transOptA->GetTotalScore() > transOptB->GetTotalScore();
}
};
class TranslationOptionList
{
friend std::ostream& operator<<(std::ostream&, const TranslationOptionList&);
protected:
typedef std::vector<TranslationOption*> CollType;
CollType m_coll;
Moses::WordsRange m_range;
public:
typedef CollType::iterator iterator;
typedef CollType::const_iterator const_iterator;
const_iterator begin() const { return m_coll.begin(); }
const_iterator end() const { return m_coll.end(); }
iterator begin() { return m_coll.begin(); }
iterator end() { return m_coll.end(); }
TranslationOptionList(const Moses::WordsRange &range)
: m_range(range)
{}
~TranslationOptionList();
size_t GetSize() const
{ return m_coll.size(); }
const Moses::WordsRange &GetSourceRange() const
{ return m_range; }
void Add(TranslationOption *transOpt);
void Sort();
void Reserve(CollType::size_type n) { m_coll.reserve(n); }
};
}

View File

@ -6,9 +6,7 @@ libmoses_chart_a_SOURCES = \
ChartHypothesis.cpp \
ChartHypothesisCollection.cpp \
ChartManager.cpp \
ChartTranslationOption.cpp \
ChartTranslationOptionCollection.cpp \
ChartTranslationOptionList.cpp \
ChartTrellisNode.cpp \
ChartTrellisPath.cpp \
ChartTrellisPathCollection.cpp \

View File

@ -21,8 +21,6 @@
#include "QueueEntry.h"
#include "ChartCell.h"
#include "ChartTranslationOption.h"
#include "ChartTranslationOptionList.h"
#include "ChartTranslationOptionCollection.h"
#include "ChartCellCollection.h"
#include "Cube.h"

File diff suppressed because it is too large Load Diff