mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-17 07:20:48 +03:00
Allow user to specify whether PhraseDictionaryMemoryPerSentenceOnDemand are probability values or not
This commit is contained in:
parent
76a8850487
commit
a18b6676b1
@ -8,7 +8,7 @@ using namespace std;
|
||||
namespace Moses
|
||||
{
|
||||
PhraseDictionaryMemoryPerSentenceOnDemand::PhraseDictionaryMemoryPerSentenceOnDemand(const std::string &line)
|
||||
: PhraseDictionary(line, true)
|
||||
: PhraseDictionary(line, true), m_valuesAreProbabilities(true)
|
||||
{
|
||||
ReadParameters();
|
||||
}
|
||||
@ -67,8 +67,10 @@ void PhraseDictionaryMemoryPerSentenceOnDemand::InitializeForInput(ttasksptr con
|
||||
|
||||
// score for this phrase table
|
||||
vector<float> scores = Tokenize<float>(toks[2]);
|
||||
std::transform(scores.begin(), scores.end(), scores.begin(),TransformScore);
|
||||
std::transform(scores.begin(), scores.end(), scores.begin(),FloorScore);
|
||||
if (m_valuesAreProbabilities) {
|
||||
std::transform(scores.begin(), scores.end(), scores.begin(),TransformScore);
|
||||
std::transform(scores.begin(), scores.end(), scores.begin(),FloorScore);
|
||||
}
|
||||
target->GetScoreBreakdown().PlusEquals(this, scores);
|
||||
|
||||
// score of all other ff when this rule is being loaded
|
||||
@ -129,6 +131,8 @@ PhraseDictionaryMemoryPerSentenceOnDemand::SetParameter(const std::string& key,
|
||||
{
|
||||
if (key == "path") {
|
||||
UTIL_THROW(util::Exception, "PhraseDictionaryMemoryPerSentenceOnDemand does not support key \"path\".");
|
||||
} else if (key == "valuesAreProbabilities") {
|
||||
m_valuesAreProbabilities = Scan<bool>(value);
|
||||
} else {
|
||||
PhraseDictionary::SetParameter(key, value);
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ protected:
|
||||
typedef boost::unordered_map<Phrase, TargetPhraseCollection::shared_ptr> Coll;
|
||||
mutable boost::thread_specific_ptr<Coll> m_coll;
|
||||
|
||||
bool m_valuesAreProbabilities;
|
||||
|
||||
Coll &GetColl() const;
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user