mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 05:14:36 +03:00
more comments
This commit is contained in:
parent
e7faa978b0
commit
1088bdcb86
@ -7,6 +7,8 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1E879EA715A346F90051F346 /* SearchNormalBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E879EA515A346F90051F346 /* SearchNormalBatch.cpp */; };
|
||||
1E879EA815A346F90051F346 /* SearchNormalBatch.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E879EA615A346F90051F346 /* SearchNormalBatch.h */; };
|
||||
1EAC363514CDC79300DF97C3 /* Loader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1EAC362C14CDC79300DF97C3 /* Loader.h */; };
|
||||
1EAC363614CDC79300DF97C3 /* LoaderCompact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1EAC362D14CDC79300DF97C3 /* LoaderCompact.cpp */; };
|
||||
1EAC363714CDC79300DF97C3 /* LoaderCompact.h in Headers */ = {isa = PBXBuildFile; fileRef = 1EAC362E14CDC79300DF97C3 /* LoaderCompact.h */; };
|
||||
@ -299,6 +301,8 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1E879EA515A346F90051F346 /* SearchNormalBatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SearchNormalBatch.cpp; path = ../../moses/src/SearchNormalBatch.cpp; sourceTree = "<group>"; };
|
||||
1E879EA615A346F90051F346 /* SearchNormalBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SearchNormalBatch.h; path = ../../moses/src/SearchNormalBatch.h; sourceTree = "<group>"; };
|
||||
1EAC362C14CDC79300DF97C3 /* Loader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Loader.h; path = ../../moses/src/RuleTable/Loader.h; sourceTree = "<group>"; };
|
||||
1EAC362D14CDC79300DF97C3 /* LoaderCompact.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LoaderCompact.cpp; path = ../../moses/src/RuleTable/LoaderCompact.cpp; sourceTree = "<group>"; };
|
||||
1EAC362E14CDC79300DF97C3 /* LoaderCompact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LoaderCompact.h; path = ../../moses/src/RuleTable/LoaderCompact.h; sourceTree = "<group>"; };
|
||||
@ -617,6 +621,8 @@
|
||||
08FB7795FE84155DC02AAC07 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1E879EA515A346F90051F346 /* SearchNormalBatch.cpp */,
|
||||
1E879EA615A346F90051F346 /* SearchNormalBatch.h */,
|
||||
1EDA803514D19ECD003D2191 /* Scope3Parser */,
|
||||
1EDA803414D19EB8003D2191 /* CYKPlusParser */,
|
||||
1EC7365B14B977AA00238410 /* LM */,
|
||||
@ -1136,6 +1142,7 @@
|
||||
1EDA809114D19FBF003D2191 /* UTrie.h in Headers */,
|
||||
1EDA809314D19FBF003D2191 /* UTrieNode.h in Headers */,
|
||||
1EF8F2C4159A61970047B613 /* HypoList.h in Headers */,
|
||||
1E879EA815A346F90051F346 /* SearchNormalBatch.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -1320,6 +1327,7 @@
|
||||
1EDA808E14D19FBF003D2191 /* Trie.cpp in Sources */,
|
||||
1EDA809014D19FBF003D2191 /* UTrie.cpp in Sources */,
|
||||
1EDA809214D19FBF003D2191 /* UTrieNode.cpp in Sources */,
|
||||
1E879EA715A346F90051F346 /* SearchNormalBatch.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -61,7 +61,11 @@ ChartCell::~ChartCell()
|
||||
delete m_sourceWordLabel;
|
||||
}
|
||||
|
||||
/** Add the given hypothesis to the cell */
|
||||
/** Add the given hypothesis to the cell.
|
||||
* Returns true if added, false if not. Maybe it already exists in the collection or score falls below threshold etc.
|
||||
* This function just calls the correspondind AddHypothesis() in ChartHypothesisCollection
|
||||
* \param hypo Hypothesis to be added
|
||||
*/
|
||||
bool ChartCell::AddHypothesis(ChartHypothesis *hypo)
|
||||
{
|
||||
const Word &targetLHS = hypo->GetTargetLHS();
|
||||
@ -119,7 +123,7 @@ void ChartCell::SortHypotheses()
|
||||
}
|
||||
}
|
||||
|
||||
/** Return the highest scoring hypothesis in the cell from the all the hypo collection */
|
||||
/** Return the highest scoring hypothesis out of all the hypo collection in this cell */
|
||||
const ChartHypothesis *ChartCell::GetBestHypothesis() const
|
||||
{
|
||||
const ChartHypothesis *ret = NULL;
|
||||
|
@ -44,7 +44,7 @@ class ChartCellCollection;
|
||||
class ChartManager;
|
||||
|
||||
/** 1 cell in chart decoder.
|
||||
* Doesn't directly hold hypotheses. Each cell contain a map of ChartHypothesisCollection that have different LHS non-terms
|
||||
* Doesn't directly hold hypotheses. Each cell contain a map of ChartHypothesisCollection that have different constituent labels
|
||||
*/
|
||||
class ChartCell
|
||||
{
|
||||
@ -78,7 +78,7 @@ public:
|
||||
void ProcessSentence(const ChartTranslationOptionList &transOptList
|
||||
,const ChartCellCollection &allChartCells);
|
||||
|
||||
/** Get all hypotheses in the cell that have the specified constituent label */
|
||||
//! Get all hypotheses in the cell that have the specified constituent label
|
||||
const HypoList *GetSortedHypotheses(const Word &constituentLabel) const
|
||||
{
|
||||
MapType::const_iterator p = m_hypoColl.find(constituentLabel);
|
||||
@ -92,11 +92,13 @@ public:
|
||||
|
||||
const ChartHypothesis *GetBestHypothesis() const;
|
||||
|
||||
//! @todo what is a m_sourceWordLabel?
|
||||
const ChartCellLabel &GetSourceWordLabel() const {
|
||||
CHECK(m_coverage.GetNumWordsCovered() == 1);
|
||||
return *m_sourceWordLabel;
|
||||
}
|
||||
|
||||
//! @todo what is a m_sourceWordLabel?
|
||||
const ChartCellLabelSet &GetTargetLabelSet() const {
|
||||
return m_targetLabelSet;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace Moses
|
||||
|
||||
class Word;
|
||||
|
||||
/** Contains a range, word (terminals?) and a vector of hypotheses.
|
||||
/** Contains a range, word (non-terms?) and a vector of hypotheses.
|
||||
* @todo This is probably incompatible with lattice decoding when the word that spans
|
||||
* a position (or positions) can vary.
|
||||
* @todo is this to hold sorted hypotheses that are in the queue for creating the next hypos?
|
||||
|
@ -67,8 +67,11 @@ protected:
|
||||
|
||||
unsigned m_id; /* pkoehn wants to log the order in which hypotheses were generated */
|
||||
|
||||
ChartHypothesis(); // not implemented
|
||||
ChartHypothesis(const ChartHypothesis ©); // not implemented
|
||||
//! not implemented
|
||||
ChartHypothesis();
|
||||
|
||||
//! not implemented
|
||||
ChartHypothesis(const ChartHypothesis ©);
|
||||
|
||||
public:
|
||||
#ifdef USE_HYPO_POOL
|
||||
@ -129,9 +132,11 @@ public:
|
||||
void CleanupArcList();
|
||||
void SetWinningHypo(const ChartHypothesis *hypo);
|
||||
|
||||
//! get the unweighted score for each feature function
|
||||
const ScoreComponentCollection &GetScoreBreakdown() const
|
||||
{ return m_scoreBreakdown; }
|
||||
|
||||
//! Get the weighted total score
|
||||
float GetTotalScore() const
|
||||
{ return m_totalScore; }
|
||||
|
||||
@ -144,7 +149,7 @@ public:
|
||||
return m_prevHypos[pos];
|
||||
}
|
||||
|
||||
//! get the LHS non-term for this particular rule
|
||||
//! get the constituency label that covers this hypo
|
||||
const Word &GetTargetLHS() const {
|
||||
return GetCurrTargetPhrase().GetTargetLHS();
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ void ChartHypothesisCollection::Remove(const HCType::iterator &iter)
|
||||
|
||||
/** prune number of hypo to a particular number of hypos, specified by m_maxHypoStackSize, according to score
|
||||
* Don't prune of hypos have identical scores on the boundary, so occasionally number of hypo can remain above m_maxHypoStackSize.
|
||||
* \param manager pointer back to manager. Used for collecting stats
|
||||
* \param manager reference back to manager. Used for collecting stats
|
||||
*/
|
||||
void ChartHypothesisCollection::PruneToSize(ChartManager &manager)
|
||||
{
|
||||
|
@ -38,6 +38,10 @@ namespace Moses
|
||||
{
|
||||
extern bool g_debug;
|
||||
|
||||
/* constructor. Initialize everything prior to decoding a particular sentence.
|
||||
* \param source the sentence to be decoded
|
||||
* \param system which particular set of models to use.
|
||||
*/
|
||||
ChartManager::ChartManager(InputType const& source, const TranslationSystem* system)
|
||||
:m_source(source)
|
||||
,m_hypoStackColl(source, *this)
|
||||
@ -71,6 +75,7 @@ ChartManager::~ChartManager()
|
||||
|
||||
}
|
||||
|
||||
//! decode the sentence. This contains the main laps. Basically, the CKY++ algorithm
|
||||
void ChartManager::ProcessSentence()
|
||||
{
|
||||
VERBOSE(1,"Translating: " << m_source << endl);
|
||||
@ -125,6 +130,10 @@ void ChartManager::ProcessSentence()
|
||||
}
|
||||
}
|
||||
|
||||
/** add specific translation options and hypotheses according to the XML override translation scheme.
|
||||
* Doesn't seem to do anything about walls and zones.
|
||||
* @todo check walls & zones. Check that the implementation doesn't leak, xml options sometimes does if you're not careful
|
||||
*/
|
||||
void ChartManager::AddXmlChartOptions() {
|
||||
const std::vector <ChartTranslationOption*> xmlChartOptionsList = m_source.GetXmlChartTranslationOptions();
|
||||
IFVERBOSE(2) { cerr << "AddXmlChartOptions " << xmlChartOptionsList.size() << endl; }
|
||||
@ -146,6 +155,7 @@ void ChartManager::AddXmlChartOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
//! get best complete translation from the top chart cell.
|
||||
const ChartHypothesis *ChartManager::GetBestHypothesis() const
|
||||
{
|
||||
size_t size = m_source.GetSize();
|
||||
@ -159,6 +169,12 @@ const ChartHypothesis *ChartManager::GetBestHypothesis() const
|
||||
}
|
||||
}
|
||||
|
||||
/** Calculate the n-best paths through the output hypergraph.
|
||||
* Return the list of paths with the variable ret
|
||||
* \param count how may paths to return
|
||||
* \param ret return argument
|
||||
* \param onlyDistinct whether to check for distinct output sentence or not (default - don't check, just return top n-paths)
|
||||
*/
|
||||
void ChartManager::CalcNBest(size_t count, ChartTrellisPathList &ret,bool onlyDistinct) const
|
||||
{
|
||||
size_t size = m_source.GetSize();
|
||||
@ -241,10 +257,6 @@ void ChartManager::CalcNBest(size_t count, ChartTrellisPathList &ret,bool onlyDi
|
||||
}
|
||||
}
|
||||
|
||||
void ChartManager::CalcDecoderStatistics() const
|
||||
{
|
||||
}
|
||||
|
||||
void ChartManager::GetSearchGraph(long translationId, std::ostream &outputSearchGraphStream) const
|
||||
{
|
||||
size_t size = m_source.GetSize();
|
||||
|
@ -69,29 +69,38 @@ public:
|
||||
void ProcessSentence();
|
||||
void AddXmlChartOptions();
|
||||
const ChartHypothesis *GetBestHypothesis() const;
|
||||
void CalcNBest(size_t count, ChartTrellisPathList &ret,bool onlyDistinct=0) const;
|
||||
void CalcNBest(size_t count, ChartTrellisPathList &ret, bool onlyDistinct=0) const;
|
||||
|
||||
void GetSearchGraph(long translationId, std::ostream &outputSearchGraphStream) const;
|
||||
void FindReachableHypotheses( const ChartHypothesis *hypo, std::map<unsigned,bool> &reachable ) const; /* auxilliary function for GetSearchGraph */
|
||||
|
||||
//! the input sentence being decoded
|
||||
const InputType& GetSource() const {
|
||||
return m_source;
|
||||
}
|
||||
|
||||
//! which particular set of models is in use
|
||||
const TranslationSystem* GetTranslationSystem() const {
|
||||
return m_system;
|
||||
}
|
||||
|
||||
//! debug data collected when decoding sentence
|
||||
SentenceStats& GetSentenceStats() const {
|
||||
return *m_sentenceStats;
|
||||
}
|
||||
|
||||
/***
|
||||
* to be called after processing a sentence (which may consist of more than just calling ProcessSentence() )
|
||||
* currently an empty function
|
||||
*/
|
||||
void CalcDecoderStatistics() const;
|
||||
void ChartManager::CalcDecoderStatistics() const
|
||||
{ }
|
||||
|
||||
void ResetSentenceStats(const InputType& source) {
|
||||
m_sentenceStats = std::auto_ptr<SentenceStats>(new SentenceStats(source));
|
||||
}
|
||||
|
||||
//! contigious hypo id for each input sentence. For debugging purposes
|
||||
unsigned GetNextHypoId() { return m_hypothesisId++; }
|
||||
};
|
||||
|
||||
|
@ -46,20 +46,28 @@ public:
|
||||
|
||||
virtual ~ChartRuleLookupManager() {}
|
||||
|
||||
//! the sentence being decoded
|
||||
const InputType &GetSentence() const {
|
||||
return m_sentence;
|
||||
}
|
||||
|
||||
//! all the chart cells
|
||||
const ChartCellCollection &GetCellCollection() const {
|
||||
return m_cellCollection;
|
||||
}
|
||||
|
||||
/** abstract function. Return a vector of translation options for given a range in the input sentence
|
||||
* \param range source range for which you want the translation options
|
||||
* \param outColl return argument
|
||||
*/
|
||||
virtual void GetChartRuleCollection(
|
||||
const WordsRange &range,
|
||||
ChartTranslationOptionList &outColl) = 0;
|
||||
|
||||
private:
|
||||
// Non-copyable: copy constructor and assignment operator not implemented.
|
||||
//! Non-copyable: copy constructor and assignment operator not implemented.
|
||||
ChartRuleLookupManager(const ChartRuleLookupManager &);
|
||||
//! Non-copyable: copy constructor and assignment operator not implemented.
|
||||
ChartRuleLookupManager &operator=(const ChartRuleLookupManager &);
|
||||
|
||||
const InputType &m_sentence;
|
||||
|
Loading…
Reference in New Issue
Block a user