diff options
author | Chris Dyer <redpony@gmail.com> | 2014-10-09 00:43:57 -0400 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2014-10-09 00:43:57 -0400 |
commit | 4ebd159797a5db525fce7433e03858f8de96dce6 (patch) | |
tree | 2b56949600aa4c83f1490cd51b1e7e6517b3cb44 /decoder/tree_fragment.cc | |
parent | 53ab488ed99daecd726dfb2abce4cc278f09706f (diff) |
make tree terminals available to feature functions
Diffstat (limited to 'decoder/tree_fragment.cc')
-rw-r--r-- | decoder/tree_fragment.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/decoder/tree_fragment.cc b/decoder/tree_fragment.cc index 42f7793a..5f717c5b 100644 --- a/decoder/tree_fragment.cc +++ b/decoder/tree_fragment.cc @@ -64,6 +64,13 @@ int TreeFragment::SetupSpansRec(unsigned cur, int left) { return right; } +vector<int> TreeFragment::Terminals() const { + vector<int> terms; + for (auto& x : *this) + if (IsTerminal(x)) terms.push_back(x); + return terms; +} + // cp is the character index in the tree // np keeps track of the nodes (nonterminals) that have been built // symp keeps track of the terminal symbols that have been built |