summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-02 19:23:08 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-02 19:23:08 +0000
commit7f772c1ade536ae1e51a1da3e8e78301646aaa0d (patch)
tree242d4720a701c45755d14b02117dc5ada81f700a /decoder
parent11c4cc3836e9e0e38bc4250500381ce7723799ee (diff)
filter and score in a single file
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@118 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rw-r--r--decoder/sparse_vector.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/decoder/sparse_vector.h b/decoder/sparse_vector.h
index 66c9b10d..896e8c43 100644
--- a/decoder/sparse_vector.h
+++ b/decoder/sparse_vector.h
@@ -187,17 +187,26 @@ public:
return result /= x;
}
- std::ostream &operator<<(std::ostream &out) const {
+ std::ostream &operator<<(std::ostream& out) const {
+ Write(true, &out);
+ return out;
+ }
+
+ void Write(const bool with_semi, std::ostream* os) const {
bool first = true;
for (typename MapType::const_iterator
it = values_.begin(); it != values_.end(); ++it) {
// by definition feature id 0 is a dummy value
if (it->first == 0) continue;
- out << (first ? "" : ";")
- << FD::Convert(it->first) << '=' << it->second;
+ if (with_semi) {
+ (*os) << (first ? "" : ";")
+ << FD::Convert(it->first) << '=' << it->second;
+ } else {
+ (*os) << (first ? "" : " ")
+ << FD::Convert(it->first) << '=' << it->second;
+ }
first = false;
}
- return out;
}
bool operator<(const SparseVector<T> &other) const {