diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-13 03:51:20 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-13 03:51:20 +0000 |
commit | e60301e1be0a0d5bb44f1efd40ff43316121d4d3 (patch) | |
tree | 93e446221d57736b5b21e4a8d800deb332a037e1 /decoder/nt_span.h | |
parent | b8bd1c28a4feb3983eeaf907250d923cd9f89d2c (diff) |
binarized cfg names improved
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@538 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/nt_span.h')
-rwxr-xr-x | decoder/nt_span.h | 22 |
1 files changed, 16 insertions, 6 deletions
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<<for_null; + else + o<<'<'<<l<<','<<r<<'>'; + } friend inline std::ostream &operator<<(std::ostream &o,Span const& s) { - if (s.l<0) - return o; - return o<<'<'<<s.l<<','<<s.r<<'>'; + 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<<TD::Convert(nt); + s.print(o,for_span_null); + } else + s.print(o,for_null); + } friend inline std::ostream &operator<<(std::ostream &o,NTSpan const& t) { - if (t.nt>0) - o<<TD::Convert(t.nt); - return o << t.s; + t.print(o);return o; } }; |