summaryrefslogtreecommitdiff
path: root/utils/sparse_vector.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-17 22:05:59 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-17 22:05:59 +0000
commitaddc7291bd44db96a01f399f8ee4efbe226245e2 (patch)
treef21c713ea6a3e5b95a3e28ffdc18be0bc2a5faf1 /utils/sparse_vector.h
parent06d0d5cc15bfc18748030b1ddcf5329d850a76f1 (diff)
vest generate / map vector print / read compatability
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@585 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils/sparse_vector.h')
-rw-r--r--utils/sparse_vector.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/utils/sparse_vector.h b/utils/sparse_vector.h
index e3904403..5d0dac27 100644
--- a/utils/sparse_vector.h
+++ b/utils/sparse_vector.h
@@ -95,7 +95,7 @@ public:
typedef char const* Str;
template <class O>
- void print(O &o,Str pre="",Str post="",Str kvsep="=",Str pairsep=" ") const {
+ void print(O &o,Str kvsep="=",Str pairsep=" ",Str pre="",Str post="") const {
o << pre;
bool first=true;
for (const_iterator i=values_.begin(),e=values_.end();i!=e;++i) {
@@ -121,7 +121,7 @@ public:
// either key val alternating whitespace sep, or key=val (kvsep char is '='). end at eof or terminator (non-ws) char
template <class S>
- void read(S &s,DupPolicy dp=NO_DUPS,bool use_kvsep=true,char kvsep='=',bool stop_at_terminator=false,char terminator=')') {
+ void read(S &s,DupPolicy dp=NO_DUPS,bool use_kvsep=true,char kvsep='=',bool use_pairsep=true,char optional_pairsep=';',bool stop_at_terminator=false,char terminator=')') {
values_.clear();
std::string id;
WordID k;
@@ -130,11 +130,12 @@ public:
#define SPARSE_MUST_READ(x) if (!(x)) error(#x);
int ki;
while (s) {
- if (stop_at_terminator) {
+ if (stop_at_terminator||use_pairsep) {
char c;
if (!(s>>c)) goto eof;
- s.unget();
- if (c==terminator) return;
+ if (stop_at_terminator && c==terminator) return;
+ if (!use_pairsep || c!=optional_pairsep)
+ s.unget();
}
if (!(s>>id)) goto eof;
if (use_kvsep && (ki=id.find(kvsep))!=std::string::npos) {