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
commit36b0eac74f5d8f8674659826a72276b47d687bd6 (patch)
treeaf55f23790cb50810637af56e3de8fcdb6db7868 /decoder
parent0f0ffedff50f371128a1305e475dafdc19aaa26c (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 {