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 16:14:42 +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 16:14:42 +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 16:14:42 +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 <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "PhraseDictionary.h"
|
2011-12-01 22:26:05 +04:00
|
|
|
#include "../../OnDiskPt/OnDiskWrapper.h"
|
|
|
|
#include "../../OnDiskPt/Word.h"
|
|
|
|
#include "../../OnDiskPt/PhraseNode.h"
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
class TargetPhraseCollection;
|
2011-03-11 16:08:43 +03:00
|
|
|
class DottedRuleStackOnDisk;
|
2010-08-10 17:12:00 +04:00
|
|
|
class WordPenaltyProducer;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2012-06-29 02:29:46 +04:00
|
|
|
/** Implementation of on-disk phrase table for hierarchical/syntax model.
|
|
|
|
*/
|
2010-04-08 21:16:10 +04:00
|
|
|
class PhraseDictionaryOnDisk : public PhraseDictionary
|
|
|
|
{
|
2011-02-24 16:14:42 +03:00
|
|
|
typedef PhraseDictionary MyBase;
|
|
|
|
friend std::ostream& operator<<(std::ostream&, const PhraseDictionaryOnDisk&);
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
protected:
|
2011-02-24 16:14:42 +03:00
|
|
|
OnDiskPt::OnDiskWrapper m_dbWrapper;
|
|
|
|
const LMList* m_languageModels;
|
|
|
|
const WordPenaltyProducer* m_wpProducer;
|
|
|
|
std::vector<FactorType> m_inputFactorsVec, m_outputFactorsVec;
|
|
|
|
std::vector<float> m_weight;
|
|
|
|
std::string m_filePath;
|
|
|
|
|
|
|
|
void LoadTargetLookup();
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
public:
|
2011-02-24 16:14:42 +03:00
|
|
|
PhraseDictionaryOnDisk(size_t numScoreComponent, PhraseDictionaryFeature* feature)
|
|
|
|
: MyBase(numScoreComponent, feature), m_languageModels(NULL)
|
|
|
|
{}
|
|
|
|
virtual ~PhraseDictionaryOnDisk();
|
|
|
|
|
|
|
|
PhraseTableImplementation GetPhraseTableImplementation() const {
|
|
|
|
return OnDisk;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
const WordPenaltyProducer* wpProducer);
|
|
|
|
|
2011-08-30 16:25:50 +04:00
|
|
|
std::string GetScoreProducerDescription(unsigned) const {
|
2011-02-24 16:14:42 +03:00
|
|
|
return "BerkeleyPt";
|
|
|
|
}
|
|
|
|
|
|
|
|
// PhraseDictionary impl
|
|
|
|
//! find list of translations that can translates src. Only for phrase input
|
|
|
|
virtual const TargetPhraseCollection *GetTargetPhraseCollection(const Phrase& src) const;
|
|
|
|
|
|
|
|
void InitializeForInput(const InputType& input);
|
|
|
|
void CleanUp();
|
|
|
|
|
2011-01-24 22:14:19 +03:00
|
|
|
virtual ChartRuleLookupManager *CreateRuleLookupManager(
|
2011-02-24 16:14:42 +03:00
|
|
|
const InputType &,
|
2011-04-05 00:43:02 +04:00
|
|
|
const ChartCellCollection &);
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
|
|
|
|
2011-01-24 22:14:19 +03:00
|
|
|
} // namespace Moses
|