| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef moses_PhraseDictionaryGroup_h |
| | #define moses_PhraseDictionaryGroup_h |
| |
|
| | #include <boost/dynamic_bitset.hpp> |
| | #include <boost/unordered_map.hpp> |
| | #include <boost/thread/shared_mutex.hpp> |
| |
|
| | #include "moses/StaticData.h" |
| | #include "moses/TargetPhrase.h" |
| | #include "moses/Util.h" |
| |
|
| | #include "moses/FF/LexicalReordering/LexicalReordering.h" |
| |
|
| | #include "moses/TranslationModel/PhraseDictionary.h" |
| |
|
| | #ifdef PT_UG |
| | #include "moses/TranslationModel/UG/mmsapt.h" |
| | #endif |
| |
|
| | namespace Moses |
| | { |
| |
|
| | struct PDGroupPhrase { |
| | TargetPhrase* m_targetPhrase; |
| | std::vector<float> m_scores; |
| | boost::dynamic_bitset<> m_seenBy; |
| |
|
| | PDGroupPhrase() : m_targetPhrase(NULL) { } |
| |
|
| | PDGroupPhrase(TargetPhrase* targetPhrase, const std::vector<float>& scores, const size_t nModels) |
| | : m_targetPhrase(targetPhrase), |
| | m_scores(scores), |
| | m_seenBy(nModels) { } |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | class PhraseDictionaryGroup: public PhraseDictionary |
| | { |
| |
|
| | public: |
| | PhraseDictionaryGroup(const std::string& line); |
| | void Load(AllOptions::ptr const& opts); |
| | TargetPhraseCollection::shared_ptr |
| | CreateTargetPhraseCollection(const ttasksptr& ttask, |
| | const Phrase& src) const; |
| | std::vector<std::vector<float> > getWeights(size_t numWeights, |
| | bool normalize) const; |
| | void CacheForCleanup(TargetPhraseCollection::shared_ptr tpc); |
| | void CleanUpAfterSentenceProcessing(const InputType& source); |
| | void CleanUpComponentModels(const InputType& source); |
| | |
| | void GetTargetPhraseCollectionBatch(const ttasksptr& ttask, |
| | const InputPathList &inputPathQueue) const; |
| | TargetPhraseCollection::shared_ptr GetTargetPhraseCollectionLEGACY( |
| | const Phrase& src) const; |
| | TargetPhraseCollection::shared_ptr GetTargetPhraseCollectionLEGACY( |
| | const ttasksptr& ttask, const Phrase& src) const; |
| | void InitializeForInput(ttasksptr const& ttask); |
| | ChartRuleLookupManager* CreateRuleLookupManager(const ChartParser&, |
| | const ChartCellCollectionBase&, std::size_t); |
| | void SetParameter(const std::string& key, const std::string& value); |
| |
|
| | protected: |
| | std::vector<std::string> m_memberPDStrs; |
| | std::vector<PhraseDictionary*> m_memberPDs; |
| | std::vector<FeatureFunction*> m_pdFeature; |
| | size_t m_numModels; |
| | size_t m_totalModelScores; |
| | boost::dynamic_bitset<> m_seenByAll; |
| | |
| | bool m_phraseCounts; |
| | |
| | bool m_wordCounts; |
| | |
| | bool m_modelBitmapCounts; |
| | |
| | bool m_restrict; |
| | |
| | bool m_haveDefaultScores; |
| | std::vector<float> m_defaultScores; |
| | |
| | bool m_defaultAverageOthers; |
| | size_t m_scoresPerModel; |
| | |
| | bool m_haveMmsaptLrFunc; |
| | |
| | std::vector<LexicalReordering**> m_mmsaptLrFuncs; |
| |
|
| | typedef std::vector<TargetPhraseCollection::shared_ptr > PhraseCache; |
| | #ifdef WITH_THREADS |
| | boost::shared_mutex m_lock_cache; |
| | typedef std::map<boost::thread::id, PhraseCache> SentenceCache; |
| | #else |
| | typedef PhraseCache SentenceCache; |
| | #endif |
| | SentenceCache m_sentenceCache; |
| |
|
| | PhraseCache& GetPhraseCache() { |
| | #ifdef WITH_THREADS |
| | { |
| | |
| | boost::shared_lock<boost::shared_mutex> read_lock(m_lock_cache); |
| | SentenceCache::iterator i = m_sentenceCache.find( |
| | boost::this_thread::get_id()); |
| | if (i != m_sentenceCache.end()) |
| | return i->second; |
| | } |
| | boost::unique_lock<boost::shared_mutex> lock(m_lock_cache); |
| | return m_sentenceCache[boost::this_thread::get_id()]; |
| | #else |
| | return m_sentenceCache; |
| | #endif |
| | } |
| | }; |
| |
|
| | } |
| |
|
| | #endif |
| |
|