mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-24 04:12:47 +03:00
Enable the bias weights to be (re)set by the server.
This commit is contained in:
parent
5a0168a6fa
commit
47a488767e
@ -36,6 +36,7 @@ using namespace irstlm;
|
||||
#include "moses/Phrase.h"
|
||||
#include "moses/InputFileStream.h"
|
||||
#include "moses/StaticData.h"
|
||||
#include "moses/TranslationTask.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -285,6 +286,9 @@ FFState* LanguageModelIRST::EvaluateWhenAppliedWithContext(ttasksptr const& ttas
|
||||
return ret.release();
|
||||
}
|
||||
|
||||
//get the context_weight map here
|
||||
std::map<std::string, float> context_weight = ttasks->GetContextWeights();
|
||||
|
||||
//[begin, end) in STL-like fashion.
|
||||
const int begin = (const int) hypo.GetCurrTargetWordsRange().GetStartPos();
|
||||
const int end = (const int) hypo.GetCurrTargetWordsRange().GetEndPos() + 1;
|
||||
|
@ -60,6 +60,10 @@ namespace Moses
|
||||
init(context_weights, docname2docid);
|
||||
}
|
||||
|
||||
std::map<std::string, float>& SamplingBias::getBiasMap() {
|
||||
return m_bias_map;
|
||||
}
|
||||
|
||||
void
|
||||
DocumentBias
|
||||
::init_from_json
|
||||
@ -96,6 +100,7 @@ namespace Moses
|
||||
<< x.first << " " << x.second << std::endl;
|
||||
}
|
||||
}
|
||||
m_bias_map = bias;
|
||||
init(bias, docname2docid);
|
||||
|
||||
// using xmlrpc_parse_json didn't always work (parser errors)
|
||||
|
@ -20,6 +20,8 @@ namespace Moses
|
||||
public:
|
||||
int loglevel;
|
||||
std::ostream* log;
|
||||
std::map<std::string, float> m_bias_map; //Map to store the biasmap as you get it from the server
|
||||
std::map<std::string, float>& getBiasMap();
|
||||
virtual float
|
||||
operator[](id_type const ID) const = 0;
|
||||
// returns (unnormalized bias) for the class of item ID
|
||||
|
@ -791,6 +791,9 @@ namespace Moses
|
||||
= btfix.SetupDocumentBias(m_bias_server, context_words, m_bias_log);
|
||||
context->bias->loglevel = m_bias_loglevel;
|
||||
context->bias->log = m_bias_log;
|
||||
//Reset the bias in the ttaskptr so that other functions
|
||||
//so that other functions can utilize the biases;
|
||||
ttask->ReSetContextWeights(context->bias->getBiasMap());
|
||||
}
|
||||
if (!context->cache1) context->cache1.reset(new pstats::cache_t);
|
||||
if (!context->cache2) context->cache2.reset(new pstats::cache_t);
|
||||
|
@ -36,6 +36,13 @@ TranslationTask::GetContextWeights() const
|
||||
return m_context_weights;
|
||||
}
|
||||
|
||||
void
|
||||
TranslationTask
|
||||
::ReSetContextWeights(std::map<std::string, float> const& new_weights)
|
||||
{
|
||||
m_context_weights = new_weights;
|
||||
}
|
||||
|
||||
void
|
||||
TranslationTask
|
||||
::SetContextString(std::string const& context)
|
||||
|
@ -118,6 +118,8 @@ public:
|
||||
|
||||
std::map<std::string, float> const& GetContextWeights() const;
|
||||
void SetContextWeights(std::string const& context_weights);
|
||||
void ReSetContextWeights(std::map<std::string, float> const& new_weights);
|
||||
|
||||
|
||||
protected:
|
||||
boost::shared_ptr<Moses::InputType> m_source;
|
||||
|
Loading…
Reference in New Issue
Block a user