2015-08-06 02:51:02 +03:00
|
|
|
// -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*-
|
2008-06-11 14:52:57 +04:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
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_StaticData_h
|
|
|
|
#define moses_StaticData_h
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2010-08-10 17:12:00 +04:00
|
|
|
#include <stdexcept>
|
2010-01-28 13:39:43 +03:00
|
|
|
#include <limits>
|
2008-06-11 14:52:57 +04:00
|
|
|
#include <list>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2010-01-28 13:39:43 +03:00
|
|
|
#include <utility>
|
2011-08-18 01:13:21 +04:00
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
2009-08-07 20:47:54 +04:00
|
|
|
|
|
|
|
#ifdef WITH_THREADS
|
2013-05-10 15:30:01 +04:00
|
|
|
#include <boost/thread.hpp>
|
2009-08-07 20:47:54 +04:00
|
|
|
#include <boost/thread/mutex.hpp>
|
|
|
|
#endif
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
#include "Parameter.h"
|
|
|
|
#include "SentenceStats.h"
|
2010-09-17 18:25:08 +04:00
|
|
|
#include "ScoreComponentCollection.h"
|
2013-11-01 19:16:47 +04:00
|
|
|
#include "moses/FF/Factory.h"
|
2014-05-20 00:54:08 +04:00
|
|
|
#include "moses/PP/Factory.h"
|
2008-10-30 21:43:17 +03:00
|
|
|
|
2015-08-06 02:51:02 +03:00
|
|
|
#include "moses/parameters/AllOptions.h"
|
2015-05-27 22:45:55 +03:00
|
|
|
#include "moses/parameters/BookkeepingOptions.h"
|
2015-05-11 02:34:24 +03:00
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
class InputType;
|
2014-01-14 21:27:11 +04:00
|
|
|
class DecodeGraph;
|
2008-06-11 14:52:57 +04:00
|
|
|
class DecodeStep;
|
|
|
|
|
2013-08-18 00:10:15 +04:00
|
|
|
class DynamicCacheBasedLanguageModel;
|
2014-01-13 18:41:52 +04:00
|
|
|
class PhraseDictionaryDynamicCacheBased;
|
2013-08-18 00:10:15 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
typedef std::pair<std::string, float> UnknownLHSEntry;
|
|
|
|
typedef std::vector<UnknownLHSEntry> UnknownLHSList;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2016-08-08 17:33:24 +03:00
|
|
|
/** Contains global variables and constants.
|
2012-06-29 02:29:46 +04:00
|
|
|
* Only 1 object of this class should be instantiated.
|
|
|
|
* A const object of this class is accessible by any function during decoding by calling StaticData::Instance();
|
|
|
|
*/
|
2008-06-11 14:52:57 +04:00
|
|
|
class StaticData
|
|
|
|
{
|
2014-01-17 21:59:36 +04:00
|
|
|
friend class HyperParameterAsWeight;
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
private:
|
2015-08-06 02:51:02 +03:00
|
|
|
static StaticData s_instance;
|
2011-02-24 16:14:42 +03:00
|
|
|
protected:
|
2011-02-24 19:17:38 +03:00
|
|
|
Parameter *m_parameter;
|
2015-12-10 06:17:36 +03:00
|
|
|
boost::shared_ptr<AllOptions> m_options;
|
2015-05-11 02:34:24 +03:00
|
|
|
|
2013-05-31 15:28:57 +04:00
|
|
|
mutable ScoreComponentCollection m_allWeights;
|
2012-12-19 18:37:00 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
std::vector<DecodeGraph*> m_decodeGraphs;
|
2014-01-14 21:27:11 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
// Initial = 0 = can be used when creating poss trans
|
|
|
|
// Other = 1 = used to calculate LM score once all steps have been processed
|
|
|
|
float
|
|
|
|
m_wordDeletionWeight;
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
// PhraseTrans, Generation & LanguageModelScore has multiple weights.
|
2015-08-06 02:51:02 +03:00
|
|
|
// int m_maxDistortion;
|
2011-02-24 16:14:42 +03:00
|
|
|
// do it differently from old pharaoh
|
|
|
|
// -ve = no limit on distortion
|
|
|
|
// 0 = no disortion (monotone in old pharaoh)
|
2011-02-24 19:17:38 +03:00
|
|
|
bool m_reorderingConstraint; //! use additional reordering constraints
|
2015-05-27 22:45:55 +03:00
|
|
|
BookkeepingOptions m_bookkeeping_options;
|
2015-06-02 12:02:39 +03:00
|
|
|
|
2015-05-27 22:45:55 +03:00
|
|
|
|
2015-01-21 19:07:50 +03:00
|
|
|
bool m_requireSortingAfterSourceContext;
|
2011-02-24 16:14:42 +03:00
|
|
|
|
|
|
|
mutable size_t m_verboseLevel;
|
2013-08-18 00:10:15 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
std::string m_factorDelimiter; //! by default, |, but it can be changed
|
|
|
|
|
|
|
|
|
|
|
|
size_t m_lmcache_cleanup_threshold; //! number of translations after which LM claenup is performed (0=never, N=after N translations; default is 1)
|
|
|
|
|
2012-09-21 11:55:37 +04:00
|
|
|
std::string m_outputUnknownsFile; //! output unknowns in this file
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
// Initial = 0 = can be used when creating poss trans
|
|
|
|
// Other = 1 = used to calculate LM score once all steps have been processed
|
|
|
|
Word m_inputDefaultNonTerminal, m_outputDefaultNonTerminal;
|
|
|
|
SourceLabelOverlap m_sourceLabelOverlap;
|
|
|
|
UnknownLHSList m_unknownLHS;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-09-23 02:29:56 +04:00
|
|
|
int m_threadCount;
|
2015-12-11 13:12:54 +03:00
|
|
|
// long m_startTranslationId;
|
2013-06-03 15:33:18 +04:00
|
|
|
|
2013-05-31 15:28:57 +04:00
|
|
|
// alternate weight settings
|
2013-06-05 17:06:04 +04:00
|
|
|
mutable std::string m_currentWeightSetting;
|
2013-06-06 17:48:52 +04:00
|
|
|
std::map< std::string, ScoreComponentCollection* > m_weightSetting; // core weights
|
|
|
|
std::map< std::string, std::set< std::string > > m_weightSettingIgnoreFF; // feature function
|
|
|
|
std::map< std::string, std::set< size_t > > m_weightSettingIgnoreDP; // decoding path
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2014-01-14 21:27:11 +04:00
|
|
|
bool m_useLegacyPT;
|
2015-12-11 13:12:54 +03:00
|
|
|
// bool m_defaultNonTermOnlyForEmptyRange;
|
|
|
|
// S2TParsingAlgorithm m_s2tParsingAlgorithm;
|
2014-01-14 21:27:11 +04:00
|
|
|
|
|
|
|
FeatureRegistry m_registry;
|
2014-05-20 00:54:08 +04:00
|
|
|
PhrasePropertyFactory m_phrasePropertyFactory;
|
2013-07-18 20:00:07 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
StaticData();
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
void LoadChartDecodingParameters();
|
|
|
|
void LoadNonTerminals();
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
//! load decoding steps
|
2015-01-07 06:25:31 +03:00
|
|
|
void LoadDecodeGraphs();
|
2015-11-12 03:00:40 +03:00
|
|
|
void LoadDecodeGraphsOld(const std::vector<std::string> &mappingVector,
|
2015-11-03 22:36:43 +03:00
|
|
|
const std::vector<size_t> &maxChartSpans);
|
2015-11-12 03:00:40 +03:00
|
|
|
void LoadDecodeGraphsNew(const std::vector<std::string> &mappingVector,
|
2015-11-03 22:36:43 +03:00
|
|
|
const std::vector<size_t> &maxChartSpans);
|
2011-08-19 20:09:36 +04:00
|
|
|
|
2014-01-14 21:27:11 +04:00
|
|
|
void NoCache();
|
|
|
|
|
|
|
|
std::string m_binPath;
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2014-01-16 22:34:33 +04:00
|
|
|
// soft NT lookup for chart models
|
2014-03-21 14:53:15 +04:00
|
|
|
std::vector<std::vector<Word> > m_softMatchesMap;
|
2013-10-02 23:02:05 +04:00
|
|
|
|
2014-03-03 17:56:19 +04:00
|
|
|
const StatefulFeatureFunction* m_treeStructure;
|
|
|
|
|
2015-04-27 18:31:22 +03:00
|
|
|
void ini_oov_options();
|
|
|
|
bool ini_output_options();
|
|
|
|
bool ini_performance_options();
|
|
|
|
|
|
|
|
void initialize_features();
|
2016-08-08 17:33:24 +03:00
|
|
|
|
|
|
|
// Coordinate space name map for matching spaces across XML input ("coord"
|
|
|
|
// tag) and feature functions that assign or use coordinates on target phrases
|
|
|
|
std::map< std::string const, size_t > m_coordSpaceMap;
|
2016-08-13 13:37:31 +03:00
|
|
|
size_t m_coordSpaceNextID;
|
2016-08-08 17:33:24 +03:00
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
public:
|
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
//! destructor
|
|
|
|
~StaticData();
|
2011-08-19 20:09:36 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
//! return static instance for use like global variable
|
|
|
|
static const StaticData& Instance() {
|
|
|
|
return s_instance;
|
|
|
|
}
|
|
|
|
|
2011-08-19 20:09:36 +04:00
|
|
|
//! do NOT call unless you know what you're doing
|
|
|
|
static StaticData& InstanceNonConst() {
|
|
|
|
return s_instance;
|
|
|
|
}
|
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
/** delete current static instance and replace with another.
|
|
|
|
* Used by gui front end
|
|
|
|
*/
|
|
|
|
#ifdef WIN32
|
|
|
|
static void Reset() {
|
|
|
|
s_instance = StaticData();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-10-31 15:50:52 +03:00
|
|
|
//! Load data into static instance. This function is required as
|
|
|
|
// LoadData() is not const
|
2012-07-31 00:07:19 +04:00
|
|
|
static bool LoadDataStatic(Parameter *parameter, const std::string &execPath);
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2011-02-24 19:17:38 +03:00
|
|
|
//! Main function to load everything. Also initialize the Parameter object
|
2011-02-24 16:14:42 +03:00
|
|
|
bool LoadData(Parameter *parameter);
|
2012-04-29 08:37:48 +04:00
|
|
|
void ClearData();
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2014-11-20 14:21:50 +03:00
|
|
|
const Parameter &GetParameter() const {
|
|
|
|
return *m_parameter;
|
2011-02-24 16:14:42 +03:00
|
|
|
}
|
|
|
|
|
2015-12-10 06:17:36 +03:00
|
|
|
AllOptions::ptr const
|
2015-12-12 03:00:41 +03:00
|
|
|
options() const {
|
2015-08-08 02:00:45 +03:00
|
|
|
return m_options;
|
2015-08-06 02:51:02 +03:00
|
|
|
}
|
|
|
|
|
2015-12-09 03:00:35 +03:00
|
|
|
size_t
|
2015-12-06 04:43:17 +03:00
|
|
|
GetVerboseLevel() const {
|
2011-02-24 16:14:42 +03:00
|
|
|
return m_verboseLevel;
|
|
|
|
}
|
2015-12-06 04:43:17 +03:00
|
|
|
|
2015-12-09 03:00:35 +03:00
|
|
|
void
|
2015-12-06 04:43:17 +03:00
|
|
|
SetVerboseLevel(int x) const {
|
2011-02-24 16:14:42 +03:00
|
|
|
m_verboseLevel = x;
|
|
|
|
}
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2015-04-30 08:05:11 +03:00
|
|
|
const ScoreComponentCollection&
|
2015-05-02 13:45:24 +03:00
|
|
|
GetAllWeights() const {
|
|
|
|
return m_allWeights;
|
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2011-08-19 20:09:36 +04:00
|
|
|
void SetAllWeights(const ScoreComponentCollection& weights) {
|
2010-10-07 02:06:49 +04:00
|
|
|
m_allWeights = weights;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Weight for a single-valued feature
|
2013-02-22 00:03:35 +04:00
|
|
|
float GetWeight(const FeatureFunction* sp) const {
|
2010-10-07 02:06:49 +04:00
|
|
|
return m_allWeights.GetScoreForProducer(sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Weight for a single-valued feature
|
2013-02-22 00:03:35 +04:00
|
|
|
void SetWeight(const FeatureFunction* sp, float weight) ;
|
2010-10-07 02:06:49 +04:00
|
|
|
|
|
|
|
|
|
|
|
//Weights for feature with fixed number of values
|
2013-02-22 00:03:35 +04:00
|
|
|
std::vector<float> GetWeights(const FeatureFunction* sp) const {
|
2010-10-07 02:06:49 +04:00
|
|
|
return m_allWeights.GetScoresForProducer(sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Weights for feature with fixed number of values
|
2013-02-22 00:03:35 +04:00
|
|
|
void SetWeights(const FeatureFunction* sp, const std::vector<float>& weights);
|
2011-08-19 20:09:36 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
const std::string& GetFactorDelimiter() const {
|
|
|
|
return m_factorDelimiter;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t GetLMCacheCleanupThreshold() const {
|
|
|
|
return m_lmcache_cleanup_threshold;
|
|
|
|
}
|
|
|
|
|
2012-09-21 11:55:37 +04:00
|
|
|
const std::string& GetOutputUnknownsFile() const {
|
|
|
|
return m_outputUnknownsFile;
|
|
|
|
}
|
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
const UnknownLHSList &GetUnknownLHS() const {
|
|
|
|
return m_unknownLHS;
|
|
|
|
}
|
|
|
|
|
|
|
|
float GetRuleCountThreshold() const {
|
|
|
|
return 999999; /* TODO wtf! */
|
|
|
|
}
|
|
|
|
|
2015-01-08 15:37:34 +03:00
|
|
|
void ReLoadBleuScoreFeatureParameter(float weight);
|
|
|
|
|
2011-08-19 20:09:36 +04:00
|
|
|
Parameter* GetParameter() {
|
|
|
|
return m_parameter;
|
|
|
|
}
|
2010-09-17 18:46:00 +04:00
|
|
|
|
2011-09-23 02:29:56 +04:00
|
|
|
int ThreadCount() const {
|
|
|
|
return m_threadCount;
|
|
|
|
}
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2012-07-31 00:07:19 +04:00
|
|
|
void SetExecPath(const std::string &path);
|
|
|
|
const std::string &GetBinDirectory() const;
|
2012-11-14 23:01:25 +04:00
|
|
|
|
|
|
|
bool NeedAlignmentInfo() const {
|
2015-05-27 22:45:55 +03:00
|
|
|
return m_bookkeeping_options.need_alignment_info;
|
2013-05-29 21:16:15 +04:00
|
|
|
}
|
2012-11-14 23:01:25 +04:00
|
|
|
|
2013-05-31 15:28:57 +04:00
|
|
|
bool GetHasAlternateWeightSettings() const {
|
|
|
|
return m_weightSetting.size() > 0;
|
|
|
|
}
|
|
|
|
|
2013-06-06 18:51:31 +04:00
|
|
|
/** Alternate weight settings allow the wholesale ignoring of
|
2013-06-06 17:48:52 +04:00
|
|
|
feature functions. This function checks if a feature function
|
|
|
|
should be evaluated given the current weight setting */
|
2013-06-05 22:44:43 +04:00
|
|
|
bool IsFeatureFunctionIgnored( const FeatureFunction &ff ) const {
|
|
|
|
if (!GetHasAlternateWeightSettings()) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-06-06 18:51:31 +04:00
|
|
|
std::map< std::string, std::set< std::string > >::const_iterator lookupIgnoreFF
|
2015-01-14 22:21:11 +03:00
|
|
|
= m_weightSettingIgnoreFF.find( m_currentWeightSetting );
|
2013-06-05 22:44:43 +04:00
|
|
|
if (lookupIgnoreFF == m_weightSettingIgnoreFF.end()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const std::string &ffName = ff.GetScoreProducerDescription();
|
|
|
|
const std::set< std::string > &ignoreFF = lookupIgnoreFF->second;
|
|
|
|
return ignoreFF.count( ffName );
|
|
|
|
}
|
|
|
|
|
2013-06-06 18:51:31 +04:00
|
|
|
/** Alternate weight settings allow the wholesale ignoring of
|
|
|
|
decoding graphs (typically a translation table). This function
|
|
|
|
checks if a feature function should be evaluated given the
|
2013-06-06 17:48:52 +04:00
|
|
|
current weight setting */
|
|
|
|
bool IsDecodingGraphIgnored( const size_t id ) const {
|
|
|
|
if (!GetHasAlternateWeightSettings()) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-06-06 18:51:31 +04:00
|
|
|
std::map< std::string, std::set< size_t > >::const_iterator lookupIgnoreDP
|
2015-01-14 22:21:11 +03:00
|
|
|
= m_weightSettingIgnoreDP.find( m_currentWeightSetting );
|
2013-06-06 17:48:52 +04:00
|
|
|
if (lookupIgnoreDP == m_weightSettingIgnoreDP.end()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const std::set< size_t > &ignoreDP = lookupIgnoreDP->second;
|
|
|
|
return ignoreDP.count( id );
|
|
|
|
}
|
|
|
|
|
2013-06-06 18:51:31 +04:00
|
|
|
/** process alternate weight settings
|
2013-06-05 17:06:04 +04:00
|
|
|
* (specified with [alternate-weight-setting] in config file) */
|
2013-05-31 15:28:57 +04:00
|
|
|
void SetWeightSetting(const std::string &settingName) const {
|
2013-06-05 17:06:04 +04:00
|
|
|
|
|
|
|
// if no change in weight setting, do nothing
|
|
|
|
if (m_currentWeightSetting == settingName) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// model must support alternate weight settings
|
|
|
|
if (!GetHasAlternateWeightSettings()) {
|
2015-01-07 07:07:06 +03:00
|
|
|
std::cerr << "Warning: Input specifies weight setting, but model does not support alternate weight settings.";
|
2013-06-05 17:06:04 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find the setting
|
|
|
|
m_currentWeightSetting = settingName;
|
2013-05-31 15:28:57 +04:00
|
|
|
std::map< std::string, ScoreComponentCollection* >::const_iterator i =
|
|
|
|
m_weightSetting.find( settingName );
|
2013-06-05 17:06:04 +04:00
|
|
|
|
2013-05-31 15:28:57 +04:00
|
|
|
// if not found, resort to default
|
|
|
|
if (i == m_weightSetting.end()) {
|
2015-01-07 07:07:06 +03:00
|
|
|
std::cerr << "Warning: Specified weight setting " << settingName
|
2015-01-14 14:07:42 +03:00
|
|
|
<< " does not exist in model, using default weight setting instead";
|
2013-05-31 15:28:57 +04:00
|
|
|
i = m_weightSetting.find( "default" );
|
2013-06-05 17:06:04 +04:00
|
|
|
m_currentWeightSetting = "default";
|
2013-05-31 15:28:57 +04:00
|
|
|
}
|
2013-06-05 17:06:04 +04:00
|
|
|
|
|
|
|
// set weights
|
2013-05-31 15:28:57 +04:00
|
|
|
m_allWeights = *(i->second);
|
|
|
|
}
|
|
|
|
|
2012-12-19 19:38:57 +04:00
|
|
|
float GetWeightWordPenalty() const;
|
2012-12-19 18:37:00 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
const std::vector<DecodeGraph*>& GetDecodeGraphs() const {
|
|
|
|
return m_decodeGraphs;
|
|
|
|
}
|
2012-12-21 19:28:34 +04:00
|
|
|
|
2012-12-21 19:59:52 +04:00
|
|
|
//sentence (and thread) specific initialisationn and cleanup
|
2015-03-26 21:25:54 +03:00
|
|
|
void InitializeForInput(ttasksptr const& ttask) const;
|
|
|
|
void CleanUpAfterSentenceProcessing(ttasksptr const& ttask) const;
|
2013-01-17 21:15:10 +04:00
|
|
|
|
2013-05-31 23:21:02 +04:00
|
|
|
void LoadFeatureFunctions();
|
2013-02-07 00:05:00 +04:00
|
|
|
bool CheckWeights() const;
|
2014-01-20 19:54:17 +04:00
|
|
|
void LoadSparseWeightsFromConfig();
|
2013-06-05 17:06:04 +04:00
|
|
|
bool LoadWeightSettings();
|
|
|
|
bool LoadAlternateWeightSettings();
|
2013-05-10 15:30:01 +04:00
|
|
|
|
2013-11-22 23:13:09 +04:00
|
|
|
std::map<std::string, std::string> OverrideFeatureNames();
|
2013-06-07 20:32:01 +04:00
|
|
|
void OverrideFeatures();
|
|
|
|
|
2014-01-15 19:42:02 +04:00
|
|
|
const FeatureRegistry &GetFeatureRegistry() const {
|
|
|
|
return m_registry;
|
|
|
|
}
|
2013-11-01 19:16:47 +04:00
|
|
|
|
2014-06-08 11:44:59 +04:00
|
|
|
const PhrasePropertyFactory &GetPhrasePropertyFactory() const {
|
|
|
|
return m_phrasePropertyFactory;
|
|
|
|
}
|
2014-05-20 00:54:08 +04:00
|
|
|
|
2013-10-03 14:05:53 +04:00
|
|
|
/** check whether we should be using the old code to support binary phrase-table.
|
|
|
|
** eventually, we'll stop support the binary phrase-table and delete this legacy code
|
|
|
|
**/
|
2013-10-02 23:02:05 +04:00
|
|
|
void CheckLEGACYPT();
|
2013-10-03 14:33:48 +04:00
|
|
|
bool GetUseLegacyPT() const {
|
|
|
|
return m_useLegacyPT;
|
|
|
|
}
|
2013-10-02 23:02:05 +04:00
|
|
|
|
2014-03-21 14:53:15 +04:00
|
|
|
void SetSoftMatches(std::vector<std::vector<Word> >& softMatchesMap) {
|
|
|
|
m_softMatchesMap = softMatchesMap;
|
2014-01-16 22:34:33 +04:00
|
|
|
}
|
|
|
|
|
2014-03-21 14:53:15 +04:00
|
|
|
const std::vector< std::vector<Word> >& GetSoftMatches() const {
|
|
|
|
return m_softMatchesMap;
|
2014-01-16 22:34:33 +04:00
|
|
|
}
|
|
|
|
|
2014-02-24 00:07:28 +04:00
|
|
|
void ResetWeights(const std::string &denseWeights, const std::string &sparseFile);
|
2014-03-03 17:56:19 +04:00
|
|
|
|
|
|
|
// need global access for output of tree structure
|
|
|
|
const StatefulFeatureFunction* GetTreeStructure() const {
|
2014-05-19 17:34:27 +04:00
|
|
|
return m_treeStructure;
|
2014-01-16 22:34:33 +04:00
|
|
|
}
|
|
|
|
|
2014-03-03 17:56:19 +04:00
|
|
|
void SetTreeStructure(const StatefulFeatureFunction* treeStructure) {
|
2014-05-19 17:34:27 +04:00
|
|
|
m_treeStructure = treeStructure;
|
2014-01-16 22:34:33 +04:00
|
|
|
}
|
|
|
|
|
2015-01-21 19:07:50 +03:00
|
|
|
bool RequireSortingAfterSourceContext() const {
|
|
|
|
return m_requireSortingAfterSourceContext;
|
|
|
|
}
|
|
|
|
|
2016-08-08 17:33:24 +03:00
|
|
|
// Coordinate spaces
|
|
|
|
size_t GetCoordSpace(std::string space) const;
|
|
|
|
size_t MapCoordSpace(std::string space);
|
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
|