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>
|
2012-11-27 19:08:31 +04:00
|
|
|
#include "moses/TranslationModel/PhraseDictionary.h"
|
2012-11-12 23:56:18 +04:00
|
|
|
#include "OnDiskPt/OnDiskWrapper.h"
|
|
|
|
#include "OnDiskPt/Word.h"
|
|
|
|
#include "OnDiskPt/PhraseNode.h"
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2013-06-21 17:38:45 +04:00
|
|
|
#ifdef WITH_THREADS
|
|
|
|
#include <boost/thread/tss.hpp>
|
2013-07-01 20:37:24 +04:00
|
|
|
#else
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2013-06-21 17:38:45 +04:00
|
|
|
#endif
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
class TargetPhraseCollection;
|
2011-03-11 16:08:43 +03:00
|
|
|
class DottedRuleStackOnDisk;
|
2013-07-07 05:14:51 +04:00
|
|
|
class InputPath;
|
2013-07-31 15:25:34 +04:00
|
|
|
class ChartParser;
|
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.
|
2013-05-29 21:16:15 +04:00
|
|
|
*/
|
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&);
|
2014-01-27 21:53:53 +04:00
|
|
|
friend class ChartRuleLookupManagerOnDisk;
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
protected:
|
2013-07-01 20:37:24 +04:00
|
|
|
#ifdef WITH_THREADS
|
2013-03-05 18:02:55 +04:00
|
|
|
boost::thread_specific_ptr<OnDiskPt::OnDiskWrapper> m_implementation;
|
2013-07-01 20:37:24 +04:00
|
|
|
#else
|
|
|
|
boost::scoped_ptr<OnDiskPt::OnDiskWrapper> m_implementation;
|
|
|
|
#endif
|
2013-03-05 18:02:55 +04:00
|
|
|
|
2014-01-27 21:53:53 +04:00
|
|
|
size_t m_maxSpanDefault, m_maxSpanLabelled;
|
|
|
|
|
2013-03-05 18:02:55 +04:00
|
|
|
OnDiskPt::OnDiskWrapper &GetImplementation();
|
|
|
|
const OnDiskPt::OnDiskWrapper &GetImplementation() const;
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2013-08-16 15:34:31 +04:00
|
|
|
void GetTargetPhraseCollectionBatch(InputPath &inputPath) const;
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
public:
|
2013-06-20 15:50:41 +04:00
|
|
|
PhraseDictionaryOnDisk(const std::string &line);
|
2013-06-14 21:34:47 +04:00
|
|
|
~PhraseDictionaryOnDisk();
|
|
|
|
void Load();
|
2011-02-24 16:14:42 +03:00
|
|
|
|
|
|
|
// PhraseDictionary impl
|
2011-01-24 22:14:19 +03:00
|
|
|
virtual ChartRuleLookupManager *CreateRuleLookupManager(
|
2013-07-31 15:25:34 +04:00
|
|
|
const ChartParser &parser,
|
2014-03-14 12:49:09 +04:00
|
|
|
const ChartCellCollectionBase &,
|
|
|
|
std::size_t);
|
2013-03-05 18:02:55 +04:00
|
|
|
|
|
|
|
virtual void InitializeForInput(InputType const& source);
|
2013-08-16 15:34:31 +04:00
|
|
|
void GetTargetPhraseCollectionBatch(const InputPathList &inputPathQueue) const;
|
2013-03-05 18:02:55 +04:00
|
|
|
|
2013-08-16 16:47:39 +04:00
|
|
|
const TargetPhraseCollection *GetTargetPhraseCollection(const OnDiskPt::PhraseNode *ptNode) const;
|
|
|
|
const TargetPhraseCollection *GetTargetPhraseCollectionNonCache(const OnDiskPt::PhraseNode *ptNode) const;
|
2013-08-16 16:26:21 +04:00
|
|
|
|
2014-01-27 21:53:53 +04:00
|
|
|
void SetParameter(const std::string& key, const std::string& value);
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
|
|
|
|
2011-01-24 22:14:19 +03:00
|
|
|
} // namespace Moses
|