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
path: root/moses/FF
diff options
context:
space:
mode:
authorAles Tamchyna <tamchyna@ufal.mff.cuni.cz>2016-04-04 17:32:39 +0300
committerAles Tamchyna <tamchyna@ufal.mff.cuni.cz>2016-04-04 17:32:39 +0300
commit2a58011d377042b2cf28c386417f1959a7055842 (patch)
tree21f27a8086cd65bc82773c0083e8cc05fec72a7e /moses/FF
parent90f6f4d4a7cc2bc4ab32d479763387c05122f606 (diff)
vw corner cases when looking inside factors
Diffstat (limited to 'moses/FF')
-rw-r--r--moses/FF/VW/VWFeatureContext.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/moses/FF/VW/VWFeatureContext.h b/moses/FF/VW/VWFeatureContext.h
index b42ddf1d3..cd7722f7c 100644
--- a/moses/FF/VW/VWFeatureContext.h
+++ b/moses/FF/VW/VWFeatureContext.h
@@ -71,6 +71,12 @@ protected:
if (m_targetFactors.size() != 1)
UTIL_THROW2("You can only use factor-positions when a single target-side factor is defined.");
const std::string &fullFactor = word.GetFactor(m_targetFactors[0])->GetString().as_string();
+
+ // corner cases: at sentence beginning/end, we don't have the correct factors set up
+ // similarly for UNK
+ if (fullFactor == BOS_ || fullFactor == EOS_ || fullFactor == UNKNOWN_FACTOR)
+ return fullFactor;
+
std::string subFactor(m_factorPositions.size(), 'x'); // initialize string with correct size and placeholder chars
for (size_t i = 0; i < m_factorPositions.size(); i++)
subFactor[i] = fullFactor[m_factorPositions[i]];