2010-07-18 03:23:09 +04:00
|
|
|
// $Id$
|
2010-04-08 21:16:10 +04:00
|
|
|
// 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
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "PhraseDictionary.h"
|
2010-07-18 02:29:06 +04:00
|
|
|
#include "PhraseDictionaryNodeSCFG.h"
|
2010-04-08 21:16:10 +04:00
|
|
|
#include "CellCollection.h"
|
2011-01-13 03:25:10 +03:00
|
|
|
#include "InputType.h"
|
|
|
|
#include "WordConsumed.h"
|
|
|
|
#include "NonTerminal.h"
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
2010-09-23 21:39:32 +04:00
|
|
|
class ChartTranslationOptionList;
|
2010-04-08 21:16:10 +04:00
|
|
|
class ProcessedRuleStack;
|
|
|
|
class ProcessedRuleColl;
|
|
|
|
|
|
|
|
/*** Implementation of a phrase table in a trie. Looking up a phrase of
|
|
|
|
* length n words requires n look-ups to find the TargetPhraseCollection.
|
|
|
|
*/
|
2010-07-18 02:29:06 +04:00
|
|
|
class PhraseDictionarySCFG : public PhraseDictionary
|
2010-04-08 21:16:10 +04:00
|
|
|
{
|
|
|
|
typedef PhraseDictionary MyBase;
|
2010-07-18 02:29:06 +04:00
|
|
|
friend std::ostream& operator<<(std::ostream&, const PhraseDictionarySCFG&);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
protected:
|
2010-07-18 02:29:06 +04:00
|
|
|
PhraseDictionaryNodeSCFG m_collection;
|
2010-04-08 21:16:10 +04:00
|
|
|
std::string m_filePath;
|
|
|
|
|
|
|
|
TargetPhraseCollection &GetOrCreateTargetPhraseCollection(const Phrase &source, const TargetPhrase &target);
|
2010-07-18 02:29:06 +04:00
|
|
|
PhraseDictionaryNodeSCFG &GetOrCreateNode(const Phrase &source, const TargetPhrase &target);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
bool Load(const std::vector<FactorType> &input
|
|
|
|
, const std::vector<FactorType> &output
|
|
|
|
, std::istream &inStream
|
|
|
|
, const std::vector<float> &weight
|
|
|
|
, size_t tableLimit
|
|
|
|
, const LMList &languageModels
|
2010-08-10 17:12:00 +04:00
|
|
|
, const WordPenaltyProducer* wpProducer);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
void CreateSourceLabels(std::vector<Word> &sourceLabels
|
|
|
|
, const std::vector<std::string> &sourceLabelsStr) const;
|
|
|
|
Word CreateCoveredWord(const Word &origSourceLabel, const InputType &src, const WordsRange &range) const;
|
|
|
|
|
|
|
|
public:
|
2010-07-18 02:29:06 +04:00
|
|
|
PhraseDictionarySCFG(size_t numScoreComponent, PhraseDictionaryFeature* feature)
|
2010-04-08 21:16:10 +04:00
|
|
|
: MyBase(numScoreComponent, feature)
|
|
|
|
{
|
|
|
|
}
|
2010-07-18 02:29:06 +04:00
|
|
|
virtual ~PhraseDictionarySCFG();
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
std::string GetScoreProducerDescription() const
|
|
|
|
{ return "Hieu's Reordering Model"; }
|
|
|
|
|
|
|
|
PhraseTableImplementation GetPhraseTableImplementation() const
|
|
|
|
{ return Memory; }
|
|
|
|
|
|
|
|
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
|
2010-08-10 17:12:00 +04:00
|
|
|
, const WordPenaltyProducer* wpProducer);
|
2011-01-24 22:14:19 +03:00
|
|
|
|
|
|
|
const PhraseDictionaryNodeSCFG &GetRootNode() const
|
|
|
|
{ return m_collection; }
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
const TargetPhraseCollection *GetTargetPhraseCollection(const Phrase &source) const;
|
|
|
|
|
|
|
|
void AddEquivPhrase(const Phrase &source, const TargetPhrase &targetPhrase);
|
|
|
|
|
|
|
|
void AddEquivPhrase(TargetPhraseCollection &targetPhraseColl, TargetPhrase *targetPhrase);
|
|
|
|
|
|
|
|
// for mert
|
|
|
|
void SetWeightTransModel(const std::vector<float> &weightT);
|
|
|
|
|
|
|
|
TO_STRING();
|
|
|
|
|
|
|
|
void InitializeForInput(const InputType& i);
|
|
|
|
|
|
|
|
void CleanUp();
|
2011-01-24 22:14:19 +03:00
|
|
|
|
|
|
|
ChartRuleLookupManager *CreateRuleLookupManager(
|
|
|
|
const InputType &,
|
|
|
|
const CellCollection &);
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
2011-01-24 22:14:19 +03:00
|
|
|
|
|
|
|
} // namespace Moses
|