variable number of score components for phrase trans

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@79 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
hieuhoang1972 2006-07-12 10:16:21 +00:00
parent 257bced4de
commit e338a6dbc0
5 changed files with 21 additions and 13 deletions

View File

@ -143,7 +143,7 @@ void IOCommandLine::SetNBest(const LatticePathList &nBestList, long translationI
for (iterTrans = transScoreComponent.begin() ; iterTrans != transScoreComponent.end() ; ++iterTrans)
{
const ScoreComponent &transScore = iterTrans->second;
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
for (size_t i = 0 ; i < transScore.GetNoScoreComponent() ; i++)
{
m_nBestFile << transScore[i] << " ";
}

View File

@ -101,7 +101,10 @@ Hypothesis::Hypothesis(const Hypothesis &prevHypo, const TranslationOption &tran
const ScoreComponent &possComponent = transOpt.GetScoreComponents();
ScoreComponent &transComponent = m_transScoreComponent.GetScoreComponent(possComponent.GetDictionary());
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
const size_t noScoreComponent = possComponent.GetNoScoreComponent();
assert(noScoreComponent == transComponent.GetNoScoreComponent());
for (size_t i = 0 ; i < noScoreComponent ; i++)
{
transComponent[i] += possComponent[i];
}

View File

@ -46,3 +46,18 @@ void ScoreComponent::Reset()
}
}
}
std::ostream& operator<<(std::ostream &out, const ScoreComponent &scoreComponent)
{
const size_t noScoreComponent = scoreComponent.GetNoScoreComponent();
if (noScoreComponent > 0)
{
out << scoreComponent[0];
for (size_t i = 1 ; i < noScoreComponent ; i++)
{
out << "," << scoreComponent[i];
}
}
return out;
}

View File

@ -71,13 +71,4 @@ public:
}
};
inline std::ostream& operator<<(std::ostream &out, const ScoreComponent &transScoreComponent)
{
out << transScoreComponent[0];
for (size_t i = 1 ; i < NUM_PHRASE_SCORES ; i++)
{
out << "," << transScoreComponent[i];
}
return out;
}
std::ostream& operator<<(std::ostream &out, const ScoreComponent &scoreComponent);

View File

@ -31,7 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#define NOT_FOUND std::numeric_limits<size_t>::max()
const size_t NUM_PHRASE_SCORES = 5;
const size_t DEFAULT_MAX_HYPOSTACK_SIZE = 200;
const size_t ARRAY_SIZE_INCR = 20; //amount by which a hypostack gets resized when necessary
const float LOWEST_SCORE = -100.0f;