|
@@ -89,8 +89,53 @@ void Codebook::clear ()
|
|
|
|
|
|
void Codebook::restore ( istream & is, int format )
|
|
|
{
|
|
|
- is >> thresholds;
|
|
|
- is >> informativeMeasure;
|
|
|
+ if (is.good())
|
|
|
+ {
|
|
|
+ std::string tmp;
|
|
|
+ is >> tmp; //class name
|
|
|
+
|
|
|
+ if ( ! this->isStartTag( tmp, "Codebook" ) )
|
|
|
+ {
|
|
|
+ std::cerr << " WARNING - attempt to restore Codebook, but start flag " << tmp << " does not match! Aborting... " << std::endl;
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool b_endOfBlock = false;
|
|
|
+
|
|
|
+ while ( !b_endOfBlock )
|
|
|
+ {
|
|
|
+ is >> tmp; // start of block
|
|
|
+
|
|
|
+ if ( this->isEndTag( tmp, "Codebook" ) )
|
|
|
+ {
|
|
|
+ b_endOfBlock = true;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ tmp = this->removeStartTag ( tmp );
|
|
|
+ if ( tmp.compare("thresholds") == 0 )
|
|
|
+ {
|
|
|
+ is >> thresholds;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("informativeMeasure") == 0 )
|
|
|
+ {
|
|
|
+ is >> informativeMeasure;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+ else if ( tmp.compare("classnos") == 0 )
|
|
|
+ {
|
|
|
+ is >> classnos;
|
|
|
+ is >> tmp; // end of block
|
|
|
+ tmp = this->removeEndTag ( tmp );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// is >> classnos;
|
|
|
|
|
|
//TODO use a flag for compatibility with old systems?
|
|
@@ -111,9 +156,26 @@ void Codebook::restore ( istream & is, int format )
|
|
|
|
|
|
void Codebook::store ( ostream & os, int format ) const
|
|
|
{
|
|
|
- os << this->thresholds << endl;
|
|
|
- os << this->informativeMeasure << endl;
|
|
|
- os << this->classnos << endl;
|
|
|
+ if (os.good())
|
|
|
+ {
|
|
|
+ // show starting point
|
|
|
+ os << this->createStartTag( "Codebook" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "thresholds" ) << std::endl;
|
|
|
+ os << this->thresholds << endl;
|
|
|
+ os << this->createEndTag( "thresholds" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "informativeMeasure" ) << std::endl;
|
|
|
+ os << this->informativeMeasure << endl;
|
|
|
+ os << this->createEndTag( "informativeMeasure" ) << std::endl;
|
|
|
+
|
|
|
+ os << this->createStartTag( "classnos" ) << std::endl;
|
|
|
+ os << this->classnos << endl;
|
|
|
+ os << this->createEndTag( "classnos" ) << std::endl;
|
|
|
+
|
|
|
+ // done
|
|
|
+ os << this->createEndTag( "Codebook" ) << std::endl;
|
|
|
+ }
|
|
|
// os << this->i_noOfNearestClustersToConsidere << endl;
|
|
|
// os << this->s_section << endl;
|
|
|
//
|
|
@@ -148,4 +210,4 @@ void Codebook::setHardAssignment( const bool & _hardAssignment )
|
|
|
bool Codebook::getHardAssignment ( ) const
|
|
|
{
|
|
|
return this->b_hardAssignment;
|
|
|
-}
|
|
|
+}
|