mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 21:42:19 +03:00
variable number of translation component scores
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@23 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
287cf55d8a
commit
a17432379b
@ -36,7 +36,9 @@ public:
|
||||
{
|
||||
return *m_factorsUsed[direction];
|
||||
}
|
||||
|
||||
virtual ~Dictionary()
|
||||
{
|
||||
}
|
||||
virtual DecodeType GetDecodeType() const = 0;
|
||||
};
|
||||
|
||||
|
@ -34,8 +34,11 @@ class Hypothesis;
|
||||
class Arc;
|
||||
class GenerationDictionary;
|
||||
|
||||
|
||||
class LatticeEdge
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& out, const LatticeEdge& edge);
|
||||
|
||||
protected:
|
||||
// scores
|
||||
float m_score[NUM_SCORES];
|
||||
@ -50,7 +53,7 @@ protected:
|
||||
#endif
|
||||
|
||||
public:
|
||||
LatticeEdge(const LatticeEdge &edge); // not implemented
|
||||
LatticeEdge(const LatticeEdge ©); // not implemented
|
||||
LatticeEdge(const float score[NUM_SCORES]
|
||||
, const ScoreComponentCollection &transScoreComponent
|
||||
, const ScoreColl &lmScoreComponent
|
||||
@ -59,13 +62,13 @@ public:
|
||||
, const Hypothesis *prevHypo)
|
||||
:m_prevHypo(prevHypo)
|
||||
,m_phrase(phrase)
|
||||
#ifdef N_BEST
|
||||
,m_transScoreComponent(transScoreComponent)
|
||||
,m_generationScoreComponent(generationScoreComponent)
|
||||
,m_lmScoreComponent (lmScoreComponent)
|
||||
#endif
|
||||
{
|
||||
SetScore(score);
|
||||
#ifdef N_BEST
|
||||
m_transScoreComponent = transScoreComponent;
|
||||
m_lmScoreComponent = lmScoreComponent;
|
||||
m_generationScoreComponent = generationScoreComponent;
|
||||
#endif
|
||||
}
|
||||
LatticeEdge(FactorDirection direction, const Hypothesis *prevHypo)
|
||||
:m_prevHypo(prevHypo)
|
||||
@ -73,6 +76,7 @@ public:
|
||||
{}
|
||||
virtual ~LatticeEdge()
|
||||
{
|
||||
TRACE_ERR(*this << std::endl);
|
||||
}
|
||||
|
||||
inline const Phrase &GetPhrase() const
|
||||
|
@ -30,22 +30,37 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
class ScoreComponentCollection : public std::map<const PhraseDictionary *, ScoreComponent*>
|
||||
{
|
||||
public:
|
||||
ScoreComponentCollection()
|
||||
{
|
||||
}
|
||||
ScoreComponentCollection(const ScoreComponentCollection ©)
|
||||
{
|
||||
ScoreComponentCollection::const_iterator iter;
|
||||
for (iter = copy.begin() ; iter != copy.end() ; ++iter)
|
||||
{
|
||||
const ScoreComponent *origScoreComponent = iter->second;
|
||||
Add(*origScoreComponent);
|
||||
}
|
||||
}
|
||||
|
||||
~ScoreComponentCollection()
|
||||
{ // ??? memory leak but double free
|
||||
TRACE_ERR(this << std::endl);
|
||||
ScoreComponentCollection::iterator iter;
|
||||
for (iter = begin() ; iter != end() ; ++iter)
|
||||
{
|
||||
TRACE_ERR(iter->second << std::endl);
|
||||
TRACE_ERR(*iter->second << std::endl);
|
||||
delete iter->second;
|
||||
}
|
||||
}
|
||||
|
||||
ScoreComponent &GetScoreComponent(const PhraseDictionary *phraseDictionary)
|
||||
{
|
||||
ScoreComponentCollection::iterator iter = find(phraseDictionary);
|
||||
assert(iter != end());
|
||||
return *iter->second;
|
||||
}
|
||||
|
||||
~ScoreComponentCollection()
|
||||
{ // ??? memory leak but double free
|
||||
/* ScoreComponentCollection::iterator iter;
|
||||
for (iter = begin() ; iter != end() ; ++iter)
|
||||
{
|
||||
delete iter->second;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
const ScoreComponent &GetScoreComponent(const PhraseDictionary *phraseDictionary) const
|
||||
{
|
||||
@ -69,7 +84,17 @@ public:
|
||||
}
|
||||
ScoreComponent &Add(const PhraseDictionary *phraseDictionary)
|
||||
{
|
||||
return Add(ScoreComponent(phraseDictionary));
|
||||
ScoreComponentCollection::iterator iter = find(phraseDictionary);
|
||||
if (iter != end())
|
||||
{ // already have scores for this phrase table. delete it 1st
|
||||
delete iter->second;
|
||||
erase(iter);
|
||||
}
|
||||
// add new into same place
|
||||
ScoreComponent *newScoreComponent = new ScoreComponent(phraseDictionary);
|
||||
operator[](phraseDictionary) = newScoreComponent;
|
||||
|
||||
return *newScoreComponent;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user