+* Fixed bug in tokenizeString() and Evidence::addEvidenceTabFile()
+ (a tab character at the end of a line was incorrectly discarded - bug reported by Priya)
+* Replaced all Name members by name() virtual functions and removed global variable DAINames
+ (this fixes a bug in matlab/dai.cpp reported by Thomas Mensink)
+
+
libDAI-0.2.7 (2010-08-19)
-------------------------
-* Replaced all Name members by name() virtual functions and removed global variable DAINames
- (this fixes a bug in matlab/dai.cpp reported by Thomas Mensink)
* Removed interfaces deprecated in 0.2.6.
* Fixed a bug in JTree::findMaximum() (reported by zhengyun84 and Dhruv Batra):
if one or more variables had a MAP belief with more than one maximum, an
void Evidence::addEvidenceTabFile( std::istream &is, std::map<std::string, Var> &varMap ) {
std::string line;
getline( is, line );
- size_t line_number = 0;
+ size_t line_number = 2;
// Parse header
std::vector<std::string> header_fields;
line_number++;
std::vector<std::string> fields;
- fields = tokenizeString( line, true );
+ fields = tokenizeString( line, true, "\t" );
if( fields.size() != vars.size() )
DAI_THROWE(INVALID_EVIDENCE_FILE,"Invalid number of fields in line " + boost::lexical_cast<std::string>(line_number));
vector<string> tokens;
string::size_type start = 0;
- while( start < s.size() ) {
+ while( start <= s.size() ) {
string::size_type end = s.find_first_of( delim, start );
if( end == string::npos )
end = s.size();
// skip to next non-delimiter
start = s.find_first_not_of( delim, start );
if( start == string::npos )
- start = s.size();
+ break;
} else { // we found a token
tokens.push_back( s.substr(start, end - start) );
start = end + 1;
s = "";
tokens = tokenizeString( s, true, " \t" );
- BOOST_CHECK_EQUAL( tokens.size(), 0 );
+ BOOST_CHECK_EQUAL( tokens[0], "" );
+ BOOST_CHECK_EQUAL( tokens.size(), 1 );
s = " ";
tokens = tokenizeString( s, true, " \t" );
- BOOST_CHECK_EQUAL( tokens.size(), 1 );
+ BOOST_CHECK_EQUAL( tokens.size(), 2 );
BOOST_CHECK_EQUAL( tokens[0], "" );
+ BOOST_CHECK_EQUAL( tokens[1], "" );
s = " \t";
tokens = tokenizeString( s, true, " \t" );
- BOOST_CHECK_EQUAL( tokens.size(), 2 );
+ BOOST_CHECK_EQUAL( tokens.size(), 3 );
BOOST_CHECK_EQUAL( tokens[0], "" );
BOOST_CHECK_EQUAL( tokens[1], "" );
+ BOOST_CHECK_EQUAL( tokens[2], "" );
s = " \tHello";
tokens = tokenizeString( s, true, " \t" );
s = " \tHello\r\n there !\r";
tokens = tokenizeString( s, true, " \t\r\n" );
- BOOST_CHECK_EQUAL( tokens.size(), 7 );
+ BOOST_CHECK_EQUAL( tokens.size(), 8 );
BOOST_CHECK_EQUAL( tokens[0], "" );
BOOST_CHECK_EQUAL( tokens[1], "" );
BOOST_CHECK_EQUAL( tokens[2], "Hello" );
BOOST_CHECK_EQUAL( tokens[4], "" );
BOOST_CHECK_EQUAL( tokens[5], "there" );
BOOST_CHECK_EQUAL( tokens[6], "!" );
+ BOOST_CHECK_EQUAL( tokens[7], "" );
s = "";