summaryrefslogtreecommitdiff
path: root/decoder/scfg_translator.cc
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2013-06-20 01:28:43 +0200
committerPatrick Simianer <p@simianer.de>2013-06-20 01:28:43 +0200
commitb84dbcec63a488c85ef32591a1a751571a4ec808 (patch)
treeb15737c3f9e0d18c36a8d84d52e6c0bb270190f9 /decoder/scfg_translator.cc
parent4ee4f74ae8cf88fd2335267c26cbfb73f3ef8f28 (diff)
parentf1ce46ec9b1b8efcc4a91a149454acf03c01db02 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'decoder/scfg_translator.cc')
-rw-r--r--decoder/scfg_translator.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/decoder/scfg_translator.cc b/decoder/scfg_translator.cc
index 3b43b586..6f0b003b 100644
--- a/decoder/scfg_translator.cc
+++ b/decoder/scfg_translator.cc
@@ -12,6 +12,7 @@
#include "grammar.h"
#include "bottom_up_parser.h"
#include "sentence_metadata.h"
+#include "stringlib.h"
#include "tdict.h"
#include "viterbi.h"
#include "verbose.h"
@@ -68,7 +69,11 @@ PassThroughGrammar::PassThroughGrammar(const Lattice& input, const string& cat,
const int j = alts[k].dist2next + i;
const string& src = TD::Convert(alts[k].label);
if (ss.count(alts[k].label) == 0) {
- TRulePtr pt(new TRule("[" + cat + "] ||| " + src + " ||| " + src + " ||| PassThrough=1"));
+ int length = static_cast<int>(log(UTF8StringLen(src)) / log(1.6)) + 1;
+ if (length > 6) length = 6;
+ string len_feat = "PassThrough_0=1";
+ len_feat[12] += length;
+ TRulePtr pt(new TRule("[" + cat + "] ||| " + src + " ||| " + src + " ||| PassThrough=1 " + len_feat));
pt->a_.push_back(AlignmentPoint(0,0));
AddRule(pt);
RefineRule(pt, ctf_level);