summaryrefslogtreecommitdiff
path: root/decoder/tree_fragment.h
diff options
context:
space:
mode:
authorChris Dyer <redpony@gmail.com>2014-07-01 13:49:47 -0400
committerChris Dyer <redpony@gmail.com>2014-07-01 13:49:47 -0400
commitf3255478edc9b04fd13d4e74a2fbf37aeb981202 (patch)
treec7fb4875c55abcc411c2557255e5203c3b7aa15c /decoder/tree_fragment.h
parent9a9abc5f6e9b3f26daf5f276434c1fd7f0c83da2 (diff)
track spans in t2s translation
Diffstat (limited to 'decoder/tree_fragment.h')
-rw-r--r--decoder/tree_fragment.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/decoder/tree_fragment.h b/decoder/tree_fragment.h
index 8bb7251a..6b4842ee 100644
--- a/decoder/tree_fragment.h
+++ b/decoder/tree_fragment.h
@@ -43,9 +43,10 @@ inline bool IsTerminal(unsigned x) {
struct TreeFragmentProduction {
TreeFragmentProduction() {}
- TreeFragmentProduction(int nttype, const std::vector<unsigned>& r) : lhs(nttype), rhs(r) {}
+ TreeFragmentProduction(int nttype, const std::vector<unsigned>& r) : lhs(nttype), rhs(r), span(std::make_pair<short,short>(-1,-1)) {}
unsigned lhs;
std::vector<unsigned> rhs;
+ std::pair<short, short> span; // the span of the node (in input, or not set for rules)
};
// this data structure represents a tree or forest
@@ -76,6 +77,10 @@ class TreeFragment {
// np keeps track of the nodes (nonterminals) that have been built
// symp keeps track of the terminal symbols that have been built
void ParseRec(const StringPiece& tree, bool afs, unsigned cp, unsigned symp, unsigned np, unsigned* pcp, unsigned* psymp, unsigned* pnp);
+
+ // used by constructor to set up span indices for logging/alignment purposes
+ int SetupSpansRec(unsigned cur, int left);
+
public:
unsigned root;
unsigned char frontier_sites;