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 | 3528804d9c9bfc4c9deded8d1d123119521765f2 (patch) | |
tree | f5ccb38bf55d23452b966cfd4fff73c55de3dae4 /rst_parser | |
parent | 600d87af320e790a31f1d902ae48331cd371012b (diff) |
last of the mcdonald 05 features
Diffstat (limited to 'rst_parser')
-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); + } + } } } }; |