summaryrefslogtreecommitdiff
path: root/decoder/tree_fragment.h
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-07-04 13:32:22 +0200
committerPatrick Simianer <p@simianer.de>2014-07-04 13:32:22 +0200
commit38226f8be5b54ccd79e2456216f7486a9249780d (patch)
tree39a8edc7bc34d665b65478a0bda1eeadf0475086 /decoder/tree_fragment.h
parent9351b82d65713cc076c8097427f21f1c7ad4f5d2 (diff)
parentf3255478edc9b04fd13d4e74a2fbf37aeb981202 (diff)
Merge remote-tracking branch 'upstream/master'
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;