diff options
author | Chris Dyer <cdyer@Chriss-MacBook-Air.local> | 2013-05-06 22:18:08 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@Chriss-MacBook-Air.local> | 2013-05-06 22:18:08 -0400 |
commit | 2e4b60f35c40af366be40fe7089f21a5c1ad8e71 (patch) | |
tree | f08d3084a1dcc7ca2ec49e8e764c333ff8d9e012 /decoder | |
parent | b7ea2615bc9bb69031ff714ddce1539c9f1bda2d (diff) |
add passthrough length features
Diffstat (limited to 'decoder')
-rw-r--r-- | decoder/scfg_translator.cc | 7 |
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); |