2008-06-11 14:52:57 +04:00
|
|
|
// $Id$
|
|
|
|
// vim:tabstop=2
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
Moses - factored phrase-based language decoder
|
|
|
|
Copyright (C) 2006 University of Edinburgh
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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-02-24 14:15:44 +03:00
|
|
|
#ifndef moses_PhraseDictionaryMemory_h
|
|
|
|
#define moses_PhraseDictionaryMemory_h
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2012-11-27 19:08:31 +04:00
|
|
|
#include "moses/TranslationModel/PhraseDictionary.h"
|
|
|
|
#include "moses/TranslationModel/PhraseDictionaryNode.h"
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
/*** Implementation of a phrase table in a trie. Looking up a phrase of
|
|
|
|
* length n words requires n look-ups to find the TargetPhraseCollection.
|
|
|
|
*/
|
|
|
|
class PhraseDictionaryMemory : public PhraseDictionary
|
|
|
|
{
|
2011-02-24 16:14:42 +03:00
|
|
|
typedef PhraseDictionary MyBase;
|
|
|
|
friend std::ostream& operator<<(std::ostream&, const PhraseDictionaryMemory&);
|
2008-06-11 14:52:57 +04:00
|
|
|
|
|
|
|
protected:
|
2011-02-24 16:14:42 +03:00
|
|
|
PhraseDictionaryNode m_collection;
|
|
|
|
|
|
|
|
TargetPhraseCollection *CreateTargetPhraseCollection(const Phrase &source);
|
2008-06-11 14:52:57 +04:00
|
|
|
|
|
|
|
public:
|
2011-02-24 16:14:42 +03:00
|
|
|
PhraseDictionaryMemory(size_t numScoreComponent, PhraseDictionaryFeature* feature)
|
|
|
|
: PhraseDictionary(numScoreComponent,feature) {}
|
|
|
|
virtual ~PhraseDictionaryMemory();
|
|
|
|
|
|
|
|
bool Load(const std::vector<FactorType> &input
|
|
|
|
, const std::vector<FactorType> &output
|
|
|
|
, const std::string &filePath
|
|
|
|
, const std::vector<float> &weight
|
|
|
|
, size_t tableLimit
|
|
|
|
, const LMList &languageModels
|
|
|
|
, float weightWP);
|
|
|
|
|
|
|
|
const TargetPhraseCollection *GetTargetPhraseCollection(const Phrase &source) const;
|
|
|
|
|
|
|
|
// for mert
|
|
|
|
virtual void InitializeForInput(InputType const&) {
|
|
|
|
/* Don't do anything source specific here as this object is shared between threads.*/
|
|
|
|
}
|
|
|
|
|
2011-01-24 22:14:19 +03:00
|
|
|
virtual ChartRuleLookupManager *CreateRuleLookupManager(
|
2011-02-24 16:14:42 +03:00
|
|
|
const InputType &,
|
2012-10-11 17:27:30 +04:00
|
|
|
const ChartCellCollectionBase &) {
|
2011-11-18 16:07:41 +04:00
|
|
|
CHECK(false);
|
2011-01-24 22:14:19 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
TO_STRING();
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
};
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
}
|
2010-02-24 14:15:44 +03:00
|
|
|
#endif
|