diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-04-18 01:39:20 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-04-18 01:39:20 -0400 |
commit | 390bfd5a0bf1701b6274acbc8f335a4b6c68a52b (patch) | |
tree | b70cc1b4ebf3859b5bd4fe514f4589334d2a454f /rst_parser/arc_ff.cc | |
parent | ea830224a256aa85702f74d3a0073839d30b6747 (diff) |
last of the mcdonald 05 features
Diffstat (limited to 'rst_parser/arc_ff.cc')
-rw-r--r-- | rst_parser/arc_ff.cc | 25 |
1 files changed, 24 insertions, 1 deletions
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<WordID, vector<int> > 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<WordID, vector<int> >::iterator j = pcs.begin(); j != pcs.end(); ++j) { + const WordID posj = j->first; + vector<int>& cs = j->second; + cs.push_back(cs.back() + (posj == posi ? 1 : 0)); + } + } } template <typename A> @@ -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<WordID, vector<int> >::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); + } + } } } }; |