summaryrefslogtreecommitdiff
path: root/decoder/nt_span.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-13 03:51:20 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-13 03:51:20 +0000
commit84009c98d9a0a2e3ecd801ebb92ed47ee3f3328b (patch)
tree9fa1f2467d4c7b82444652498d31622c99d69ebd /decoder/nt_span.h
parent46349d90291dc755225863552eb19beb1038c505 (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-xdecoder/nt_span.h22
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;
}
};