2012-07-18 17:52:48 +04:00
|
|
|
/***********************************************************************
|
|
|
|
Moses - statistical machine translation system
|
|
|
|
Copyright (C) 2006-2011 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
|
|
|
|
|
2012-11-27 19:08:31 +04:00
|
|
|
#include "moses/TranslationModel/PhraseDictionary.h"
|
2012-11-12 23:56:18 +04:00
|
|
|
#include "moses/InputType.h"
|
|
|
|
#include "moses/NonTerminal.h"
|
|
|
|
#include "moses/fuzzy-match/FuzzyMatchWrapper.h"
|
|
|
|
#include "Trie.h"
|
2012-07-18 17:52:48 +04:00
|
|
|
#include "PhraseDictionaryNodeSCFG.h"
|
|
|
|
#include "PhraseDictionarySCFG.h"
|
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
2012-07-23 17:07:36 +04:00
|
|
|
class PhraseDictionaryNodeSCFG;
|
2012-07-18 17:52:48 +04:00
|
|
|
|
|
|
|
/** Implementation of a SCFG rule table in a trie. Looking up a rule of
|
|
|
|
* length n symbols requires n look-ups to find the TargetPhraseCollection.
|
|
|
|
*/
|
2012-08-14 02:53:14 +04:00
|
|
|
class PhraseDictionaryFuzzyMatch : public PhraseDictionary
|
2012-07-18 17:52:48 +04:00
|
|
|
{
|
2012-08-14 02:53:14 +04:00
|
|
|
friend std::ostream& operator<<(std::ostream&, const PhraseDictionaryFuzzyMatch&);
|
2012-07-18 17:52:48 +04:00
|
|
|
friend class RuleTableLoader;
|
|
|
|
|
|
|
|
public:
|
2012-08-14 02:53:14 +04:00
|
|
|
PhraseDictionaryFuzzyMatch(size_t numScoreComponents,
|
2012-07-18 20:59:21 +04:00
|
|
|
PhraseDictionaryFeature* feature);
|
2012-07-23 17:31:05 +04:00
|
|
|
bool Load(const std::vector<FactorType> &input
|
|
|
|
, const std::vector<FactorType> &output
|
2012-07-23 19:36:39 +04:00
|
|
|
, const std::string &initStr
|
2012-07-23 17:31:05 +04:00
|
|
|
, const std::vector<float> &weight
|
|
|
|
, size_t tableLimit,
|
|
|
|
const LMList& languageModels,
|
|
|
|
const WordPenaltyProducer* wpProducer);
|
2012-07-18 17:52:48 +04:00
|
|
|
|
2012-07-19 21:59:50 +04:00
|
|
|
const PhraseDictionaryNodeSCFG &GetRootNode(const InputType &source) const;
|
2012-07-18 17:52:48 +04:00
|
|
|
|
|
|
|
ChartRuleLookupManager *CreateRuleLookupManager(
|
|
|
|
const InputType &,
|
2012-10-11 17:27:30 +04:00
|
|
|
const ChartCellCollectionBase &);
|
2012-07-23 17:07:36 +04:00
|
|
|
void InitializeForInput(InputType const& inputSentence);
|
2012-07-19 20:56:46 +04:00
|
|
|
void CleanUp(const InputType& source);
|
|
|
|
|
|
|
|
virtual const TargetPhraseCollection *GetTargetPhraseCollection(const Phrase& src) const
|
2012-07-27 03:10:49 +04:00
|
|
|
{
|
|
|
|
assert(false);
|
2012-10-11 17:27:30 +04:00
|
|
|
return NULL;
|
2012-07-27 03:10:49 +04:00
|
|
|
}
|
2012-07-19 20:56:46 +04:00
|
|
|
virtual DecodeType GetDecodeType() const
|
2012-07-27 03:10:49 +04:00
|
|
|
{
|
|
|
|
assert(false);
|
|
|
|
}
|
2012-07-18 17:52:48 +04:00
|
|
|
|
|
|
|
TO_STRING();
|
|
|
|
|
|
|
|
protected:
|
2012-07-23 17:07:36 +04:00
|
|
|
TargetPhraseCollection &GetOrCreateTargetPhraseCollection(PhraseDictionaryNodeSCFG &rootNode
|
2012-07-19 21:59:50 +04:00
|
|
|
, const Phrase &source
|
|
|
|
, const TargetPhrase &target
|
|
|
|
, const Word &sourceLHS);
|
2012-07-18 17:52:48 +04:00
|
|
|
|
2012-07-23 17:07:36 +04:00
|
|
|
PhraseDictionaryNodeSCFG &GetOrCreateNode(PhraseDictionaryNodeSCFG &rootNode
|
2012-07-19 21:59:50 +04:00
|
|
|
, const Phrase &source
|
2012-07-18 17:52:48 +04:00
|
|
|
, const TargetPhrase &target
|
|
|
|
, const Word &sourceLHS);
|
|
|
|
|
2012-07-23 17:07:36 +04:00
|
|
|
void SortAndPrune(PhraseDictionaryNodeSCFG &rootNode);
|
2012-07-19 21:59:50 +04:00
|
|
|
PhraseDictionaryNodeSCFG &GetRootNode(const InputType &source);
|
|
|
|
|
|
|
|
std::map<long, PhraseDictionaryNodeSCFG> m_collection;
|
2012-07-19 22:36:46 +04:00
|
|
|
std::vector<std::string> m_config;
|
2012-07-23 15:26:15 +04:00
|
|
|
|
|
|
|
const std::vector<FactorType> *m_input, *m_output;
|
|
|
|
const LMList *m_languageModels;
|
|
|
|
const WordPenaltyProducer *m_wpProducer;
|
|
|
|
const std::vector<float> *m_weight;
|
2012-07-27 03:10:49 +04:00
|
|
|
|
2012-08-14 02:53:14 +04:00
|
|
|
tmmt::FuzzyMatchWrapper *m_FuzzyMatchWrapper;
|
2012-07-23 15:26:15 +04:00
|
|
|
|
2012-07-18 17:52:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Moses
|