From 390bfd5a0bf1701b6274acbc8f335a4b6c68a52b Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Wed, 18 Apr 2012 01:39:20 -0400 Subject: last of the mcdonald 05 features --- rst_parser/arc_ff.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'rst_parser') diff --git a/rst_parser/arc_ff.cc b/rst_parser/arc_ff.cc index fba36e24..2992cde2 100644 --- a/rst_parser/arc_ff.cc +++ b/rst_parser/arc_ff.cc @@ -11,9 +11,21 @@ struct ArcFFImpl { const string kROOT; const string kLEFT_POS; const string kRIGHT_POS; + map > pcs; void PrepareForInput(const TaggedSentence& sent) { - (void) sent; + pcs.clear(); + for (int i = 0; i < sent.pos.size(); ++i) + pcs[sent.pos[i]].resize(1, 0); + pcs[sent.pos[0]][0] = 1; + for (int i = 1; i < sent.pos.size(); ++i) { + const WordID posi = sent.pos[i]; + for (map >::iterator j = pcs.begin(); j != pcs.end(); ++j) { + const WordID posj = j->first; + vector& cs = j->second; + cs.push_back(cs.back() + (posj == posi ? 1 : 0)); + } + } } template @@ -102,6 +114,17 @@ struct ArcFFImpl { Fire(features, "posLR", head_pos, mod_pos, head_pos_L, mod_pos_R); Fire(features, "posRL", head_pos, mod_pos, head_pos_R, mod_pos_L); Fire(features, "lexRL", head_word, head_pos_L, mod_pos_L); + + // between features + int left = min(h,m); + int right = max(h,m); + if (right - left > 2) { + ++left; + for (map >::const_iterator it = pcs.begin(); it != pcs.end(); ++it) { + if (it->second[left] != it->second[right]) + Fire(features, "BT", head_pos, TD::Convert(it->first), mod_pos); + } + } } } }; -- cgit v1.2.3