Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2016-11-08 18:30:16 +0300
committerHieu Hoang <hieuhoang@gmail.com>2016-11-08 18:30:16 +0300
commit948af8f35472f5878a91c76531891634a1b67210 (patch)
tree3d70c8402007d7f928b3cc7db48eee6b148c1ea1
parentf31471f22cf5553e8cb0255ae95cdcf14aae3883 (diff)
add drop params to UnknowWordPenalty
-rw-r--r--contrib/moses2/TranslationModel/UnknownWordPenalty.cpp47
-rw-r--r--contrib/moses2/TranslationModel/UnknownWordPenalty.h1
2 files changed, 29 insertions, 19 deletions
diff --git a/contrib/moses2/TranslationModel/UnknownWordPenalty.cpp b/contrib/moses2/TranslationModel/UnknownWordPenalty.cpp
index f08b31d4a..d786b2cff 100644
--- a/contrib/moses2/TranslationModel/UnknownWordPenalty.cpp
+++ b/contrib/moses2/TranslationModel/UnknownWordPenalty.cpp
@@ -25,8 +25,9 @@ using namespace std;
namespace Moses2
{
-UnknownWordPenalty::UnknownWordPenalty(size_t startInd, const std::string &line) :
- PhraseTable(startInd, line)
+UnknownWordPenalty::UnknownWordPenalty(size_t startInd, const std::string &line)
+:PhraseTable(startInd, line)
+,m_drop(false)
{
m_tuneable = false;
ReadParameters();
@@ -39,7 +40,10 @@ UnknownWordPenalty::~UnknownWordPenalty()
void UnknownWordPenalty::SetParameter(const std::string& key, const std::string& value)
{
- if (key == "prefix") {
+ if (key == "drop") {
+ m_drop = Scan<bool>(value);
+ }
+ else if (key == "prefix") {
m_prefix = value;
}
else if (key == "suffix") {
@@ -119,27 +123,32 @@ TargetPhrases *UnknownWordPenalty::Lookup(const Manager &mgr, MemPool &pool,
tps = new (pool.Allocate<TargetPhrases>()) TargetPhrases(pool, 1);
+ size_t numWords = m_drop ? 0 : 1;
+
TargetPhraseImpl *target =
new (pool.Allocate<TargetPhraseImpl>()) TargetPhraseImpl(pool, *this,
- system, 1);
- Moses2::Word &word = (*target)[0];
+ system, numWords);
- if (m_prefix.empty() && m_suffix.empty()) {
- word[0] = factor;
- }
- else {
- stringstream strm;
- if (!m_prefix.empty()) {
- strm << m_prefix;
+ if (!m_drop) {
+ Moses2::Word &word = (*target)[0];
+
+ if (m_prefix.empty() && m_suffix.empty()) {
+ word[0] = factor;
}
- strm << factor->GetString();
- if (!m_suffix.empty()) {
- strm << m_suffix;
+ else {
+ stringstream strm;
+ if (!m_prefix.empty()) {
+ strm << m_prefix;
+ }
+ strm << factor->GetString();
+ if (!m_suffix.empty()) {
+ strm << m_suffix;
+ }
+
+ FactorCollection &fc = system.GetVocab();
+ const Factor *targetFactor = fc.AddFactor(strm.str(), system, false);
+ word[0] = targetFactor;
}
-
- FactorCollection &fc = system.GetVocab();
- const Factor *targetFactor = fc.AddFactor(strm.str(), system, false);
- word[0] = targetFactor;
}
Scores &scores = target->GetScores();
diff --git a/contrib/moses2/TranslationModel/UnknownWordPenalty.h b/contrib/moses2/TranslationModel/UnknownWordPenalty.h
index 3adb5bbc2..52c235a36 100644
--- a/contrib/moses2/TranslationModel/UnknownWordPenalty.h
+++ b/contrib/moses2/TranslationModel/UnknownWordPenalty.h
@@ -81,6 +81,7 @@ protected:
const Moses2::Range &subPhraseRange,
SCFG::InputPath &outPath) const;
protected:
+ bool m_drop;
std::string m_prefix, m_suffix;
};