mosesdecoder/moses/TranslationModel/PhraseDictionaryTreeAdaptor.h

82 lines
2.2 KiB
C
Raw Normal View History

// $Id$
#ifndef moses_PhraseDictionaryTreeAdaptor_h
#define moses_PhraseDictionaryTreeAdaptor_h
#include "moses/TypeDef.h"
#include "moses/TargetPhraseCollection.h"
#include "moses/TranslationModel/PhraseDictionary.h"
#include <vector>
2013-06-21 17:36:55 +04:00
#ifdef WITH_THREADS
2013-06-21 17:36:55 +04:00
#include <boost/thread/tss.hpp>
#else
#include <boost/scoped_ptr.hpp>
#endif
namespace Moses
{
class Phrase;
class PDTAimp;
class WordsRange;
class InputType;
/*** Implementation of a phrase table in a trie that is binarized and
2012-06-29 02:29:46 +04:00
* stored on disk. Wrapper around PDTAimp class
*/
class PhraseDictionaryTreeAdaptor : public PhraseDictionary
{
typedef PhraseDictionary MyBase;
2013-03-04 22:15:05 +04:00
#ifdef WITH_THREADS
2013-03-04 22:15:05 +04:00
boost::thread_specific_ptr<PDTAimp> m_implementation;
#else
boost::scoped_ptr<PDTAimp> m_implementation;
#endif
2013-03-04 22:15:05 +04:00
friend class PDTAimp;
PhraseDictionaryTreeAdaptor();
PhraseDictionaryTreeAdaptor(const PhraseDictionaryTreeAdaptor&);
void operator=(const PhraseDictionaryTreeAdaptor&);
PDTAimp& GetImplementation();
const PDTAimp& GetImplementation() const;
2013-03-04 22:15:05 +04:00
public:
2013-02-22 23:17:57 +04:00
PhraseDictionaryTreeAdaptor(const std::string &line);
virtual ~PhraseDictionaryTreeAdaptor();
void Load();
// enable/disable caching
// you enable caching if you request the target candidates for a source phrase multiple times
// if you do caching somewhere else, disable it
// good settings for current Moses: disable for first factor, enable for other factors
// default: enable
void EnableCache();
void DisableCache();
// get translation candidates for a given source phrase
// returns null pointer if nothing found
TargetPhraseCollection const* GetTargetPhraseCollectionNonCacheLEGACY(Phrase const &src) const;
2013-03-05 18:02:55 +04:00
void InitializeForInput(InputType const& source);
2013-03-04 22:15:05 +04:00
void CleanUpAfterSentenceProcessing(InputType const& source);
virtual ChartRuleLookupManager *CreateRuleLookupManager(
const ChartParser &,
const ChartCellCollectionBase &,
std::size_t) {
UTIL_THROW(util::Exception, "SCFG decoding not supported with binary phrase table");
return 0;
}
2013-08-07 14:48:18 +04:00
// legacy
2013-08-24 00:34:10 +04:00
const TargetPhraseCollectionWithSourcePhrase *GetTargetPhraseCollectionLEGACY(InputType const& src,WordsRange const & srcRange) const;
2013-08-07 14:48:18 +04:00
};
}
#endif