2010-07-18 03:23:09 +04:00
// $Id$
2010-04-12 14:15:49 +04:00
// vim:tabstop=2
/***********************************************************************
Moses - factored phrase - based language decoder
Copyright ( C ) 2010 Hieu Hoang
2011-02-24 15:36:50 +03:00
2010-04-12 14:15:49 +04:00
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 .
2011-02-24 15:36:50 +03:00
2010-04-12 14:15:49 +04:00
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 .
2011-02-24 15:36:50 +03:00
2010-04-12 14:15:49 +04:00
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
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-04-08 21:16:10 +04:00
# pragma once
# include <vector>
# include "ChartCell.h"
# include "ChartTranslationOptionCollection.h"
# include "ChartCellCollection.h"
2011-03-11 16:08:43 +03:00
# include "InputType.h"
# include "WordsRange.h"
# include "ChartTrellisPathList.h"
# include "SentenceStats.h"
# include "TranslationSystem.h"
# include "ChartRuleLookupManager.h"
2010-04-08 21:16:10 +04:00
2011-03-11 16:08:43 +03:00
namespace Moses
2010-04-08 21:16:10 +04:00
{
2011-03-11 16:08:43 +03:00
class ChartHypothesis ;
class ChartTrellisPathList ;
2010-04-08 21:16:10 +04:00
2011-03-11 16:08:43 +03:00
class ChartManager
2010-04-08 21:16:10 +04:00
{
protected :
2011-03-11 19:28:36 +03:00
InputType const & m_source ; /**< source sentence to be translated */
2011-02-24 15:36:50 +03:00
ChartCellCollection m_hypoStackColl ;
2011-03-11 16:08:43 +03:00
ChartTranslationOptionCollection m_transOptColl ; /**< pre-computed list of translation options for the phrases in this sentence */
2011-03-11 19:28:36 +03:00
std : : auto_ptr < SentenceStats > m_sentenceStats ;
const TranslationSystem * m_system ;
2011-02-24 15:36:50 +03:00
clock_t m_start ; /**< starting time, used for logging */
2011-03-11 19:28:36 +03:00
std : : vector < ChartRuleLookupManager * > m_ruleLookupManagers ;
2011-02-24 15:36:50 +03:00
2010-04-08 21:16:10 +04:00
public :
2011-03-11 19:28:36 +03:00
ChartManager ( InputType const & source , const TranslationSystem * system ) ;
2011-03-11 16:08:43 +03:00
~ ChartManager ( ) ;
2011-02-24 15:36:50 +03:00
void ProcessSentence ( ) ;
2011-03-11 16:08:43 +03:00
const ChartHypothesis * GetBestHypothesis ( ) const ;
void CalcNBest ( size_t count , ChartTrellisPathList & ret , bool onlyDistinct = 0 ) const ;
2010-04-08 21:16:10 +04:00
2011-02-24 15:36:50 +03:00
void GetSearchGraph ( long translationId , std : : ostream & outputSearchGraphStream ) const ;
2011-09-24 18:48:52 +04:00
void FindReachableHypotheses ( const ChartHypothesis * hypo , std : : map < const ChartHypothesis * , bool > & reachable ) const ; /* auxilliary function for GetSearchGraph */
2010-04-08 21:16:10 +04:00
2011-03-11 19:28:36 +03:00
const InputType & GetSource ( ) const {
2011-02-24 15:36:50 +03:00
return m_source ;
}
2011-03-11 19:28:36 +03:00
const TranslationSystem * GetTranslationSystem ( ) const {
2011-02-24 15:36:50 +03:00
return m_system ;
}
2011-03-11 19:28:36 +03:00
SentenceStats & GetSentenceStats ( ) const {
2010-04-08 21:16:10 +04:00
return * m_sentenceStats ;
}
2011-02-24 15:36:50 +03:00
/***
* to be called after processing a sentence ( which may consist of more than just calling ProcessSentence ( ) )
*/
void CalcDecoderStatistics ( ) const ;
2011-03-11 19:28:36 +03:00
void ResetSentenceStats ( const InputType & source ) {
m_sentenceStats = std : : auto_ptr < SentenceStats > ( new SentenceStats ( source ) ) ;
2010-04-08 21:16:10 +04:00
}
2011-02-24 15:36:50 +03:00
2010-04-08 21:16:10 +04:00
} ;
}