From e60301e1be0a0d5bb44f1efd40ff43316121d4d3 Mon Sep 17 00:00:00 2001 From: graehl Date: Fri, 13 Aug 2010 03:51:20 +0000 Subject: binarized cfg names improved git-svn-id: https://ws10smt.googlecode.com/svn/trunk@538 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/cfg.cc | 4 ++-- decoder/cfg_format.h | 3 ++- decoder/nt_span.h | 22 ++++++++++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'decoder') diff --git a/decoder/cfg.cc b/decoder/cfg.cc index aa9e5f30..8fc5b10f 100755 --- a/decoder/cfg.cc +++ b/decoder/cfg.cc @@ -22,8 +22,8 @@ WordID BinName(CFG::BinRhs const& b,CFG::NTs const& N,CFG::NTs const& M) int n=w; if (n>0) o << TD::Convert(n); \ else { \ int i=-n; \ - CFG::NT const&nt = i diff --git a/decoder/nt_span.h b/decoder/nt_span.h index 46234b07..a918f301 100755 --- a/decoder/nt_span.h +++ b/decoder/nt_span.h @@ -8,10 +8,15 @@ struct Span { int l,r; Span() : l(-1) { } + bool is_null() const { return l<0; } + void print(std::ostream &o,char const* for_null="") const { + if (is_null()) + o<'; + } friend inline std::ostream &operator<<(std::ostream &o,Span const& s) { - if (s.l<0) - return o; - return o<<'<'<'; + s.print(o);return o; } }; @@ -20,10 +25,15 @@ struct NTSpan { WordID nt; // awkward: this is a positive index, used in TD. but represented as negative in mixed terminal/NT space in rules/hgs. NTSpan() : nt(0) { } // prints as possibly empty name (whatever you set of nt,s will show) + void print(std::ostream &o,char const* for_span_null="_",char const* for_null="") const { + if (nt>0) { + o<0) - o<