From f3255478edc9b04fd13d4e74a2fbf37aeb981202 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 1 Jul 2014 13:49:47 -0400 Subject: track spans in t2s translation --- decoder/tree_fragment.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'decoder/tree_fragment.h') 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& r) : lhs(nttype), rhs(r) {} + TreeFragmentProduction(int nttype, const std::vector& r) : lhs(nttype), rhs(r), span(std::make_pair(-1,-1)) {} unsigned lhs; std::vector rhs; + std::pair 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; -- cgit v1.2.3