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:
authorUlrich Germann <Ulrich.Germann@gmail.com>2015-12-02 23:43:56 +0300
committerUlrich Germann <Ulrich.Germann@gmail.com>2015-12-02 23:43:56 +0300
commit5a6328644721e05141593a1d3e0fd378a8d96561 (patch)
tree8b0146c8960697658cd40ebf423888c11d7a5416 /moses/BaseManager.cpp
parent33f4e9391537728d2e1e1638611f99db42e91567 (diff)
Code cleanup and bug fix in (Base)Manager::OutputSurface:
Mark-up of unkown words in output.
Diffstat (limited to 'moses/BaseManager.cpp')
-rw-r--r--moses/BaseManager.cpp53
1 files changed, 30 insertions, 23 deletions
diff --git a/moses/BaseManager.cpp b/moses/BaseManager.cpp
index bd35e2098..5e2c87692 100644
--- a/moses/BaseManager.cpp
+++ b/moses/BaseManager.cpp
@@ -94,31 +94,38 @@ OutputSearchGraphAsHypergraph(std::string const& fname, size_t const precision)
/***
* print surface factor only for the given phrase
*/
-void BaseManager::OutputSurface(std::ostream &out, const Phrase &phrase,
- const std::vector<FactorType> &outputFactorOrder,
- bool reportAllFactors) const
+void
+BaseManager::
+OutputSurface(std::ostream &out, Phrase const& phrase) const
{
- UTIL_THROW_IF2(outputFactorOrder.size() == 0,
- "Cannot be empty phrase");
- if (reportAllFactors == true) {
- out << phrase;
- } else {
- size_t size = phrase.GetSize();
- for (size_t pos = 0 ; pos < size ; pos++) {
- const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[0]);
- out << *factor;
- UTIL_THROW_IF2(factor == NULL,
- "Empty factor 0 at position " << pos);
-
- for (size_t i = 1 ; i < outputFactorOrder.size() ; i++) {
- const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[i]);
- UTIL_THROW_IF2(factor == NULL,
- "Empty factor " << i << " at position " << pos);
-
- out << "|" << *factor;
- }
- out << " ";
+ std::vector<FactorType> const& factor_order = options().output.factor_order;
+
+ bool markUnknown = options().unk.mark;
+ std::string const& fd = options().output.FactorDelimiter;
+
+ size_t size = phrase.GetSize();
+ for (size_t pos = 0 ; pos < size ; pos++) {
+ const Factor *factor = phrase.GetFactor(pos, factor_order[0]);
+ UTIL_THROW_IF2(factor == NULL, "Empty factor 0 at position " << pos);
+
+ const Word &word = phrase.GetWord(pos);
+ if(markUnknown && word.IsOOV()) {
+ out << options().unk.prefix;
+ }
+
+ out << *factor;
+
+ for (size_t i = 1 ; i < factor_order.size() ; i++) {
+ const Factor *factor = phrase.GetFactor(pos, factor_order[i]);
+ UTIL_THROW_IF2(!factor, "Empty factor " << i << " at position " << pos);
+ out << fd << *factor;
+ }
+
+ if(markUnknown && word.IsOOV()) {
+ out << options().unk.suffix;
}
+
+ out << " ";
}
}