diff -c v1/Common.cxx v3/Common.cxx
*** v1/Common.cxx	Tue Sep  5 11:30:33 2000
--- v3/Common.cxx	Wed Sep 20 16:44:38 2000
***************
*** 23,26 ****
  
  const int Version  = 3;
  const int Revision = 0;
! const char *RevComment = ".1";
--- 23,26 ----
  
  const int Version  = 3;
  const int Revision = 0;
! const char *RevComment = ".3";
diff -c v1/GetOptClass.cxx v3/GetOptClass.cxx
*** v1/GetOptClass.cxx	Tue Sep  5 11:22:15 2000
--- v3/GetOptClass.cxx	Wed Sep 20 16:44:38 2000
***************
*** 23,29 ****
  
  //
  // 10 april 2000: Fixed a problem with get_N_option
! //
  
  #include <fstream>
  #include <string>
--- 23,29 ----
  
  //
  // 10 april 2000: Fixed a problem with get_N_option
! // 23-08-200 : free the result of verbosity_to_string
  
  #include <fstream>
  #include <string>
***************
*** 184,190 ****
      }
      if ( TestFileName != "" ){
        cerr << "Multiple testfile name " << TestFileName << " ignored.\n"
! 	   << "since -f leave_one_out is also specified" << endl;
      }
      if ( LocalAlgo != IB1 ) {
        cerr << "option -a ignored, since it conflicts with -t leave_one_out\n"
--- 184,190 ----
      }
      if ( TestFileName != "" ){
        cerr << "Multiple testfile name " << TestFileName << " ignored.\n"
! 	   << "since -t leave_one_out is also specified" << endl;
      }
      if ( LocalAlgo != IB1 ) {
        cerr << "option -a ignored, since it conflicts with -t leave_one_out\n"
***************
*** 473,485 ****
  
  inline void show_version_info(void)
  {
!   cerr << "TiMBL " << Version << "." << Revision
         << ", compiled on " << __DATE__ << ", " << __TIME__ << endl;
    exit(1);
  }
  
  bool GetOptClass::definitive_options( TimblExperiment *Exp, 
! 					     bool first ){
    char optline[3 * OPT_LENGTH];
    if ( !sparse_bin_set && !to_late_for_bin && 
         (LocalInputFormat != UnknownInputFormat || LocalAlgo != LOO ) ){
--- 473,485 ----
  
  inline void show_version_info(void)
  {
!   cerr << "TiMBL " << Version << "." << Revision << RevComment
         << ", compiled on " << __DATE__ << ", " << __TIME__ << endl;
    exit(1);
  }
  
  bool GetOptClass::definitive_options( TimblExperiment *Exp, 
! 				      bool first ){
    char optline[3 * OPT_LENGTH];
    if ( !sparse_bin_set && !to_late_for_bin && 
         (LocalInputFormat != UnknownInputFormat || LocalAlgo != LOO ) ){
***************
*** 533,540 ****
  	  if ( Exp->SetOption( optline ) ){
  	    sprintf( optline, "PROGRESS: %d", local_progress );
  	    if ( Exp->SetOption( optline ) ){
! 	      sprintf( optline, "VERBOSITY: %s", 
! 		       verbosity_to_string(MyVerbosity) );
  	      if ( Exp->SetOption( optline ) ){
  		int i;
  		for ( i=0; i < MaxFeats+1; i++ ){
--- 533,541 ----
  	  if ( Exp->SetOption( optline ) ){
  	    sprintf( optline, "PROGRESS: %d", local_progress );
  	    if ( Exp->SetOption( optline ) ){
! 	      const char *tmp = verbosity_to_string(MyVerbosity);
! 	      sprintf( optline, "VERBOSITY: %s", tmp );
! 	      free( const_cast<char *>(tmp) );
  	      if ( Exp->SetOption( optline ) ){
  		int i;
  		for ( i=0; i < MaxFeats+1; i++ ){
***************
*** 543,553 ****
  		  if (!Exp->SetOption( optline ) )
  		    return false;
  		}
! 		if ( do_query ){
! 		  Exp->ShowSettings( );
! 		  do_query = false;
  		}
- 		return true;
  	      }
  	    }
  	  }
--- 544,558 ----
  		  if (!Exp->SetOption( optline ) )
  		    return false;
  		}
! 		sprintf( optline, "TREE_ORDER: %s", 
! 			 order_to_string(LocalOrder) );
! 		if ( Exp->SetOption( optline ) ){
! 		  if ( do_query ){
! 		    Exp->ShowSettings( );
! 		    do_query = false;
! 		  }
! 		  return true;
  		}
  	      }
  	    }
  	  }
diff -c v1/IBtree.cxx v3/IBtree.cxx
*** v1/IBtree.cxx	Tue Sep  5 11:22:15 2000
--- v3/IBtree.cxx	Wed Sep 20 16:44:38 2000
***************
*** 19,24 ****
--- 19,30 ----
   *	Timbl@kub.nl
   */
  
+ // bug fixed 23-08-2000 Ko: replaced "magic number" 80 with MAX_BUFFER_SIZE
+ //                          in read_local and read_list
+ //           20-09-2000 Ko: Changed read_local. Shouldn't add targetvalues but
+ //                          look them up! (they are added by read_distribution)
+ //
+ 
  #include <cstdlib>
  #include <cstdio>
  #include <string>
***************
*** 206,212 ****
  {
    IBtree *result = new IBtree;
    tree_size++;
!   char buf[80];
    is >> buf;
    result->FValue = Feats[level]->add_value( buf, NULL );
    is >> buf;
--- 212,218 ----
  {
    IBtree *result = new IBtree;
    tree_size++;
!   char buf[MAX_BUFFER_SIZE];
    is >> buf;
    result->FValue = Feats[level]->add_value( buf, NULL );
    is >> buf;
***************
*** 216,229 ****
      return NULL;
    }
    is >> buf;
!   result->TValue = Targ->add_value( buf );
    if ( look_ahead(is) == '{' ){
      result->TDistribution = new ValueDistribution();
!     result->TDistribution->read_distribution( is, Targ, false );
      //    cerr << "Dist = " << TopDistribution << endl;
      // also we have to update the targetinformation of the featurevalue
      // so we can recalculate the statistics later on.
!     result->FValue->ReconstructDistribution( result->TDistribution );
    }
    if ( look_ahead(is) == '[' ){
      result->link = read_list( is, Feats, Targ, level+1 );
--- 222,237 ----
      return NULL;
    }
    is >> buf;
!   result->TValue = (TargetValue*)Targ->Lookup( buf );
    if ( look_ahead(is) == '{' ){
      result->TDistribution = new ValueDistribution();
!     if ( !result->TDistribution->read_distribution( is, Targ, false ) )
!       Error( "problems reading a distribution from InstanceBase file" );
      //    cerr << "Dist = " << TopDistribution << endl;
      // also we have to update the targetinformation of the featurevalue
      // so we can recalculate the statistics later on.
!     if ( result->FValue->ValFreq() > 0 )
!       result->FValue->ReconstructDistribution( result->TDistribution );
    }
    if ( look_ahead(is) == '[' ){
      result->link = read_list( is, Feats, Targ, level+1 );
***************
*** 256,262 ****
    IBtree *result = NULL, **pnt;
    pnt = &result;
    bool goon = true;
!   char buf[80];
    if ( Version < 3 )
      is >> buf; // skip the opening `[` (old style)
    while ( goon ) {
--- 264,270 ----
    IBtree *result = NULL, **pnt;
    pnt = &result;
    bool goon = true;
!   char buf[MAX_BUFFER_SIZE];
    if ( Version < 3 )
      is >> buf; // skip the opening `[` (old style)
    while ( goon ) {
***************
*** 300,306 ****
      is >> buf;
      // Now read the TopDistribution, to get the Targets
      // in the right order in Targ
!     TopDistribution->read_distribution( is, Targs, true );
      //    cerr << "Top = " << TopDistribution << endl;
      if ( look_ahead( is ) == '[' ){
        InstBase = read_list( is, Feats, Targs, 0 );
--- 308,315 ----
      is >> buf;
      // Now read the TopDistribution, to get the Targets
      // in the right order in Targ
!     if ( !TopDistribution->read_distribution( is, Targs, true ) )
!       Error( "problems reading Top Distribution " );
      //    cerr << "Top = " << TopDistribution << endl;
      if ( look_ahead( is ) == '[' ){
        InstBase = read_list( is, Feats, Targs, 0 );
***************
*** 506,512 ****
      result = false;
    }
    else if ( !InvAss ){
-     //    IBtree *Arr[Depth];
      IBtree **Arr = new IBtree *[Depth+1];
      IBtree *pnt = InstBase;
      int CurI = 0, Feat = 0;
--- 515,520 ----
diff -c v1/Instance.cxx v3/Instance.cxx
*** v1/Instance.cxx	Tue Sep  5 11:30:34 2000
--- v3/Instance.cxx	Wed Sep 20 16:44:39 2000
***************
*** 20,27 ****
   */
  
  //
! // bug fixed 27-3-2000 Ko : ChiSquareStatistics: Resizing of n_i_dot was wrong
! // 
  #include <iostream>
  #include <strstream>
  #include <iomanip>
--- 20,31 ----
   */
  
  //
! // bug fixed 27-03-2000 Ko: ChiSquareStatistics: Resizing of n_i_dot was wrong
! //           03-07-2000 Ko: NumStatistics: Test for ValFreq() >=0 should be
! //                             a test for ValFreq() > 0.
! //           20-09-2000 Ko: Repaired problem with Target::add_value, which made
! //                          TotalValues() useless. Also affected: read_distribution
! //
  #include <iostream>
  #include <strstream>
  #include <iomanip>
***************
*** 44,51 ****
  #define BIN_SIZE 20
  
  
! ostream& operator<<(ostream& s, const FeatureValue* fv )
! { 
   if ( fv )
      s << fv->TokVal->Name();
    else
--- 48,54 ----
  #define BIN_SIZE 20
  
  
! ostream& operator<<(ostream& s, const FeatureValue* fv ){ 
   if ( fv )
      s << fv->TokVal->Name();
    else
***************
*** 53,60 ****
    return s;
  }
  
! ostream& operator<<(ostream& s, const TargetValue* tv )
! { 
    if ( tv )
      s << tv->TokVal->Name();
    else
--- 56,62 ----
    return s;
  }
  
! ostream& operator<<(ostream& s, const TargetValue* tv ){ 
    if ( tv )
      s << tv->TokVal->Name();
    else
***************
*** 233,260 ****
    }
  }
  
! void ValueDistribution::read_distribution( istream &is, 
  					   Target *Targ,
! 					   bool do_fr )
! {
    // read a distribution from stream is into Target
    // if do_f we also adjust the value of Frequency of the Target, which is
    // otherwise 1. Special case when reading the TopDistribution.
    //
    TargetValue *target;
    char buf[STR_LEN];
    int freq;
    is >> buf;   // skip {
    do {
      is >> buf;
!     target = Targ->add_value( buf );
!     is >> buf;
!     freq = atoi( buf );
!     if ( do_fr )
!       target->ValFreq( freq );
      (*this)[target] = freq;
    } while ( look_ahead(is) != '}' );
    is >> buf;   // skip }
  }
  
  
--- 235,270 ----
    }
  }
  
! bool ValueDistribution::read_distribution( istream &is, 
  					   Target *Targ,
! 					   bool do_fr ){
    // read a distribution from stream is into Target
    // if do_f we also adjust the value of Frequency of the Target, which is
    // otherwise 1. Special case when reading the TopDistribution.
    //
+   bool result = true;
    TargetValue *target;
    char buf[STR_LEN];
+   char buf2[STR_LEN];
    int freq;
    is >> buf;   // skip {
    do {
      is >> buf;
!     is >> buf2;
!     freq = atoi( buf2 );
!     if ( do_fr ){
!       target = Targ->add_value( buf, freq );
!     }
!     else
!       target = (TargetValue*)Targ->Lookup( buf );
!     if ( !target ){
!       result = false;
!       break;
!     }
      (*this)[target] = freq;
    } while ( look_ahead(is) != '}' );
    is >> buf;   // skip }
+   return result;
  }
  
  
***************
*** 266,272 ****
    double randnum = (double)rand()/(double)RAND_MAX;
    randnum *= (Max-Min);
    randnum += Min;
!   return (int)rint(randnum);
  }
  
  const TargetValue *ValueDistribution::BestTarget( bool& tie,
--- 276,282 ----
    double randnum = (double)rand()/(double)RAND_MAX;
    randnum *= (Max-Min);
    randnum += Min;
!   return (int)floor(randnum+0.5);
  }
  
  const TargetValue *ValueDistribution::BestTarget( bool& tie,
***************
*** 360,367 ****
    index = I;
  }
  
! FeatureValue::FeatureValue( char *s )
! {
    SValueClassProb = NULL;
    Frequency = 0;
    index = -1;
--- 370,376 ----
    index = I;
  }
  
! FeatureValue::FeatureValue( char *s ){
    SValueClassProb = NULL;
    Frequency = 0;
    index = -1;
***************
*** 392,407 ****
    return index;
  }
  
- int BaseFeatTargClass::localmaplookup( int ID )
- {
-   int index=-1;
-   IImaptype::iterator map_iterator;
-   if ((map_iterator = Mapping.find( ID )) != Mapping.end()){
-     index = (*map_iterator).second;
-   }
-   return index;
- }
- 
  int BaseFeatTargClass::EffectiveValues() {
    int result = 0;
    int i;
--- 401,406 ----
***************
*** 411,421 ****
    return result;
  }
  
! FeatureValue *Feature::add_value( char *valstr, TargetValue *tv )
! {
    HashInfo *Tok = TokenTree->Hash( valstr );
    int index = localmapping( Tok->Index() );
-   TotalVals++;
    if ( index >= CurSize )
      enlarge_values_array( index );
    if(  ValuesArray[index] == NULL ){
--- 410,427 ----
    return result;
  }
  
! unsigned int BaseFeatTargClass::TotalValues() {
!   unsigned int result = 0;
!   int i;
!   for ( i=0; i < ArraySize(); i++ )
!     result += ValuesArray[i]->ValFreq();
!   return result;
! }
! 
! FeatureValue *Feature::add_value( char *valstr, 
! 				  TargetValue *tv ){
    HashInfo *Tok = TokenTree->Hash( valstr );
    int index = localmapping( Tok->Index() );
    if ( index >= CurSize )
      enlarge_values_array( index );
    if(  ValuesArray[index] == NULL ){
***************
*** 432,438 ****
  {
    bool result = false;
    if ( FV ){
-     TotalVals++;
      FV->incr_val_freq();
      if ( tv )
        FV->TargetDist[tv] += 1;
--- 438,443 ----
***************
*** 445,451 ****
  {
    bool result = false;
    if ( FV ){
-     TotalVals--;
      FV->decr_val_freq();
      if ( tv )
        FV->TargetDist[tv] -= 1;
--- 450,455 ----
***************
*** 460,466 ****
    Increment = Inc;
    TokenTree = T;
    array_size = 0;
-   TotalVals = 0;
    ValuesArray = (ValueClass **)malloc( sizeof(ValueClass*) * CurSize );
    assert( ValuesArray != NULL );
    int i;
--- 464,469 ----
***************
*** 517,523 ****
  
  bool Feature::prepare_numeric_stats( )
  { 
!   double tmp, Total = 0.0;
    int freq;
    bool first = true;
    int i;
--- 520,526 ----
  
  bool Feature::prepare_numeric_stats( )
  { 
!   double tmp;
    int freq;
    bool first = true;
    int i;
***************
*** 539,545 ****
  	  Min = tmp;
  	else if ( tmp > Max )
  	  Max = tmp;
- 	Total += tmp * freq;
        }
      }
    }
--- 542,547 ----
***************
*** 550,555 ****
--- 552,558 ----
  {
    int place;
    double tmp, Prob, FVEntropy, Freq;
+   unsigned int TotalVals = TotalValues();
    char dumname[STR_LEN];
    FeatureValue **FVBin = new FeatureValue *[BIN_SIZE];
    Entropy = 0.0;
***************
*** 560,566 ****
    }
    int j;
    for ( j=0; j < ArraySize(); j++ ){
!     if ( ValuesArray[j]->ValFreq() >= 0 ){
        string2double( ValuesArray[j]->Name(), tmp );
        place = (int)(floor((tmp - Min)/(Max-Min) * (BIN_SIZE-1)) );
        FVBin[place]->TargetDist.Merge( &((FeatureValue *)ValuesArray[j])->TargetDist );
--- 563,569 ----
    }
    int j;
    for ( j=0; j < ArraySize(); j++ ){
!     if ( ValuesArray[j]->ValFreq() > 0 ){
        string2double( ValuesArray[j]->Name(), tmp );
        place = (int)(floor((tmp - Min)/(Max-Min) * (BIN_SIZE-1)) );
        FVBin[place]->TargetDist.Merge( &((FeatureValue *)ValuesArray[j])->TargetDist );
***************
*** 581,587 ****
  	FVEntropy += Prob * Log2(Prob);
  	hlp = hlp->Next();
        }
!       Entropy += -FVEntropy * Freq / (double)TotalValues();
      }
    }
    Entropy = fabs( Entropy );
--- 584,590 ----
  	FVEntropy += Prob * Log2(Prob);
  	hlp = hlp->Next();
        }
!       Entropy += -FVEntropy * Freq / (double)TotalVals;
      }
    }
    Entropy = fabs( Entropy );
***************
*** 596,602 ****
    for ( m=0; m < BIN_SIZE; m++ ){
      Freq = ((FeatureValue*)FVBin[m])->ValFreq();
      if ( Freq ){
!       Prob = Freq / (double)TotalValues();
        SplitInfo += Prob * Log2(Prob);
      } 
      delete (FeatureValue*)FVBin[m];
--- 599,605 ----
    for ( m=0; m < BIN_SIZE; m++ ){
      Freq = ((FeatureValue*)FVBin[m])->ValFreq();
      if ( Freq ){
!       Prob = Freq / (double)TotalVals;
        SplitInfo += Prob * Log2(Prob);
      } 
      delete (FeatureValue*)FVBin[m];
***************
*** 617,622 ****
--- 620,626 ----
  void Feature::Statistics( double DBentropy )
  {
    double Prob = 0.0;
+   unsigned int TotalVals = TotalValues();
    Entropy = 0.0;
    // Loop over the values.
    VDlist *hlp;
***************
*** 634,640 ****
  	FVEntropy += Prob * Log2(Prob);
  	hlp = hlp->Next();
        }
!       Entropy += -FVEntropy * Freq / (double)TotalValues();
      }
    } //end i
    
--- 638,644 ----
  	FVEntropy += Prob * Log2(Prob);
  	hlp = hlp->Next();
        }
!       Entropy += -FVEntropy * Freq / (double)TotalVals;
      }
    } //end i
    
***************
*** 649,655 ****
    pnt = (FeatureValue **)ValuesArray;
    int j;
    for ( j=0; j < ArraySize(); j++ ){
!     Prob = pnt[j]->ValFreq() / (double)TotalValues();
      if ( Prob > 0 )
        SplitInfo += Prob * Log2(Prob);
    } 
--- 653,659 ----
    pnt = (FeatureValue **)ValuesArray;
    int j;
    for ( j=0; j < ArraySize(); j++ ){
!     Prob = pnt[j]->ValFreq() / (double)TotalVals;
      if ( Prob > 0 )
        SplitInfo += Prob * Log2(Prob);
    } 
***************
*** 945,962 ****
    }
  }
  
! TargetValue *Target::add_value( char *valstr )
! {
    HashInfo *Tok = TokenTree->Hash( valstr );
    int index = localmapping( Tok->Index() );
-   TotalVals++;
    if ( index >= CurSize )
      enlarge_values_array( index );
    if(  ValuesArray[index] == NULL ){
      ValuesArray[index] = new TargetValue( Tok, index );
    }
    else
!     ValuesArray[index]->incr_val_freq();
    return (TargetValue *)ValuesArray[index];
  }
  
--- 949,965 ----
    }
  }
  
! TargetValue *Target::add_value( char *valstr, int freq ){
    HashInfo *Tok = TokenTree->Hash( valstr );
    int index = localmapping( Tok->Index() );
    if ( index >= CurSize )
      enlarge_values_array( index );
    if(  ValuesArray[index] == NULL ){
      ValuesArray[index] = new TargetValue( Tok, index );
+     ValuesArray[index]->ValFreq( freq );
    }
    else
!     ValuesArray[index]->ValFreq( ValuesArray[index]->ValFreq() + freq );
    return (TargetValue *)ValuesArray[index];
  }
  
***************
*** 964,970 ****
  {
    bool result = false;
    if ( TV ){
-     TotalVals++;
      TV->incr_val_freq();
      result = true;
    }
--- 967,972 ----
***************
*** 975,981 ****
  {
    bool result = false;
    if ( TV ){
-     TotalVals--;
      TV->decr_val_freq();
      result = true;
    }
--- 977,982 ----
diff -c v1/Instance.h v3/Instance.h
*** v1/Instance.h	Tue Sep  5 11:22:15 2000
--- v3/Instance.h	Wed Sep 20 16:44:45 2000
***************
*** 20,26 ****
  #define INSTANCE_H
  
  
! #define OWN_MEM_HANDLING YES
  
  
  #include "Stack.h"
--- 20,26 ----
  #define INSTANCE_H
  
  
! // #define OWN_MEM_HANDLING YES
  
  
  #include "Stack.h"
***************
*** 77,83 ****
    const TargetValue* BestTarget( ) const;
    void Merge( ValueDistribution *vd );
    void Clear(){ delete distribution; distribution = NULL; };
!   void read_distribution( istream &, Target *, bool );
    void DistToString( string& ) const;
    bool ZeroDist() 
      { return ( distribution == 0 || 
--- 77,83 ----
    const TargetValue* BestTarget( ) const;
    void Merge( ValueDistribution *vd );
    void Clear(){ delete distribution; distribution = NULL; };
!   bool read_distribution( istream &, Target *, bool );
    void DistToString( string& ) const;
    bool ZeroDist() 
      { return ( distribution == 0 || 
***************
*** 150,160 ****
  
  template <class ContentType>
  void SparseArrayClass<ContentType>::Assign( const int I, 
! 					    const ContentType val )
    // search for I, if not there: add entry 
    // assigns prob with val;
    // adjusts Dimension when necessary
- {
    SA_list<ContentType> *tmp, **pnt = &contents;
    while ( *pnt ){
      if ( I < (*pnt)->index ){
--- 150,159 ----
  
  template <class ContentType>
  void SparseArrayClass<ContentType>::Assign( const int I, 
! 					    const ContentType val ){
    // search for I, if not there: add entry 
    // assigns prob with val;
    // adjusts Dimension when necessary
    SA_list<ContentType> *tmp, **pnt = &contents;
    while ( *pnt ){
      if ( I < (*pnt)->index ){
***************
*** 178,185 ****
  };
  
  template <class ContentType> ostream& operator<<
! (ostream& os, SparseArrayClass<ContentType>* SArr )
! {
    if ( SArr ) {
      int old_prec = os.precision();
      os.precision(3);
--- 177,183 ----
  };
  
  template <class ContentType> ostream& operator<<
! (ostream& os, SparseArrayClass<ContentType>* SArr ){
    if ( SArr ) {
      int old_prec = os.precision();
      os.precision(3);
***************
*** 201,208 ****
    return os;
  };
  
! class FeatureValue: public ValueClass 
! {
    friend ostream& operator<<( ostream&, const FeatureValue * );
   public:
    FeatureValue( HashInfo *, int );
--- 199,206 ----
    return os;
  };
  
! class FeatureValue: public ValueClass {
!   friend class Feature;
    friend ostream& operator<<( ostream&, const FeatureValue * );
   public:
    FeatureValue( HashInfo *, int );
***************
*** 228,245 ****
    ~BaseFeatTargClass();
    int ArraySize() { return array_size; };
    int EffectiveValues();
!   unsigned int TotalValues() { return TotalVals; };
!   int localmapping( int );
!   int localmaplookup( int );
    ValueClass *Lookup( char * );
   protected:
    int CurSize;
    int Increment;
-   unsigned int TotalVals;
    int array_size;
    StringHash *TokenTree;
    IImaptype Mapping;
    void enlarge_values_array( int );
    ValueClass *get_value_index( int I ) { return ValuesArray[I]; };
  };
  
--- 226,241 ----
    ~BaseFeatTargClass();
    int ArraySize() { return array_size; };
    int EffectiveValues();
!   unsigned int TotalValues();
    ValueClass *Lookup( char * );
   protected:
    int CurSize;
    int Increment;
    int array_size;
    StringHash *TokenTree;
    IImaptype Mapping;
    void enlarge_values_array( int );
+   int localmapping( int );
    ValueClass *get_value_index( int I ) { return ValuesArray[I]; };
  };
  
***************
*** 247,253 ****
  class Target: public BaseFeatTargClass {
   public:
    Target( int a, int b, StringHash *T ): BaseFeatTargClass(a,b,T) {};
!   TargetValue *add_value( char * );
    bool decrement_value( TargetValue * );
    bool increment_value( TargetValue * );
  };
--- 243,249 ----
  class Target: public BaseFeatTargClass {
   public:
    Target( int a, int b, StringHash *T ): BaseFeatTargClass(a,b,T) {};
!   TargetValue *add_value( char *, int freq = 1 );
    bool decrement_value( TargetValue * );
    bool increment_value( TargetValue * );
  };
diff -c v1/MBLClass.cxx v3/MBLClass.cxx
*** v1/MBLClass.cxx	Tue Sep  5 11:22:16 2000
--- v3/MBLClass.cxx	Wed Sep 20 16:44:39 2000
***************
*** 23,28 ****
--- 23,29 ----
  //                                 The TargetDist must be increased as well
  //                 HideInstance: The TargetDist should be decreased.
  // 10-4-2000: Ko : Solved a problem with large output in write_perm
+ // 20-09-2000 Ko : made LearningInfo global and correct (i hope).
  //
  
  #include <fstream>
***************
*** 422,428 ****
    return true;
  };
  
! #endif
  
  bool MBLClass::ShowWeights( ostream &os )
  {
--- 423,429 ----
    return true;
  };
  
! #endif // BUILD_SERVER
  
  bool MBLClass::ShowWeights( ostream &os )
  {
***************
*** 568,575 ****
  
  void MBLClass::InitWeights(void)
  {
!   if ( TreeOrder == DataFile )
!     Weighting = UserDefined;
    int i;
    for ( i=0; i< NumOfFeatures; i++ ){
      if ( Features[i]->Ignore )
--- 569,576 ----
  
  void MBLClass::InitWeights(void)
  {
! //    if ( TreeOrder == DataFile )
! //      Weighting = UserDefined;
    int i;
    for ( i=0; i< NumOfFeatures; i++ ){
      if ( Features[i]->Ignore )
***************
*** 712,718 ****
  	time_stamp( "Calculating Entropy " );
  	calculate_fv_entropy( false );
  	if ( verbosity & FEAT_W ){
! 	  learning_info( cerr, DataLines, SkippedLines );
  	  result = true;
  	}
        }
--- 713,722 ----
  	time_stamp( "Calculating Entropy " );
  	calculate_fv_entropy( false );
  	if ( verbosity & FEAT_W ){
! 	  cerr << "Lines of data     : " << DataLines << endl;
! 	  if ( SkippedLines != 0 )
! 	    cerr << "SkippedLines      : " << SkippedLines << endl;
! 	  LearningInfo( cerr );
  	  result = true;
  	}
        }
***************
*** 1413,1424 ****
    }
  }
  
! void MBLClass::learning_info( ostream& s, int Total, int Skipped )
! {
    int i;
!   s << "Lines of data     : " << Total << endl;
!   if ( Skipped != 0 )
!   s << "SkippedLines      : " << Skipped << endl;
    s.precision(8);
    s.setf(ios::showpoint );
    s << "DB Entropy        : " << DBEntropy << endl;
--- 1417,1425 ----
    }
  }
  
! void MBLClass::LearningInfo( ostream& s ){
    int i;
!   calculate_fv_entropy( true );
    s.precision(8);
    s.setf(ios::showpoint );
    s << "DB Entropy        : " << DBEntropy << endl;
***************
*** 3075,3080 ****
--- 3076,3083 ----
  	if ( isspace(Buffer[j]) ){
  	  result++;
  	  while ( isspace( Buffer[++j] ) );
+ 	  if ( Buffer[j] == '\0' )
+ 	    result--; // we had some trailing spaces
  	}
        };
        break;
diff -c v1/MBLClass.h v3/MBLClass.h
*** v1/MBLClass.h	Tue Sep  5 11:22:16 2000
--- v3/MBLClass.h	Wed Sep 20 16:44:45 2000
***************
*** 123,128 ****
--- 123,129 ----
    void FatalError( const char*... );
    int SockNum() const { return Socket; };
    int MaxFeats() { return MaxFeatures; };
+   void LearningInfo( ostream& );
  protected:
    MBLClass() {};
    MBLClass( AlgorithmType, const int N = 1000, const char * = NULL );
***************
*** 241,247 ****
    inline bool set_input_format( InputFormatType );
    inline void show_input_format( );
    inline void set_order(void);
-   void learning_info( ostream&, int, int );
    void calc_perm( double * );
    inline void write_perm(void);
    inline void write_perm_special(ostream&);
--- 242,247 ----
diff -c v1/Options.h v3/Options.h
*** v1/Options.h	Tue Sep  5 11:22:16 2000
--- v3/Options.h	Wed Sep 20 16:44:45 2000
***************
*** 16,21 ****
--- 16,23 ----
   *	Timbl@kub.nl
   */
  
+ // Bug fixed 23-08-2000 Ko: Free-in the result of verbosity_to_string
+ 
  #ifndef OPTIONS_H
  #define OPTIONS_H
  
***************
*** 108,122 ****
      return result;
    };
    ostream& show_opt( ostream &os ){
      os.width(20);
      os.setf( ios::left, ios::adjustfield );
!     os << Name << " : " << verbosity_to_string(*V);
      return os;
    };
    ostream& show_full( ostream &os ){
      os.width(20);
      os.setf( ios::left, ios::adjustfield );
!     os << Name << " : " << verbosity_to_string(*V);
      return os;
    };
  };
--- 110,128 ----
      return result;
    };
    ostream& show_opt( ostream &os ){
+     const char *tmp = verbosity_to_string(*V);
      os.width(20);
      os.setf( ios::left, ios::adjustfield );
!     os << Name << " : " << tmp;
!     free( const_cast<char *>(tmp) );
      return os;
    };
    ostream& show_full( ostream &os ){
+     const char *tmp = verbosity_to_string(*V);
      os.width(20);
      os.setf( ios::left, ios::adjustfield );
!     os << Name << " : " << tmp;
!     free(  const_cast<char *>(tmp) );
      return os;
    };
  };
Common subdirectories: v1/SPARC and v3/SPARC
diff -c v1/ServerProcs.cxx v3/ServerProcs.cxx
*** v1/ServerProcs.cxx	Tue Sep  5 11:22:16 2000
--- v3/ServerProcs.cxx	Wed Sep 20 16:44:39 2000
***************
*** 19,24 ****
--- 19,25 ----
   *	Timbl@kub.nl
   */
  
+ #ifdef BUILD_SERVER
  #define _REENTRANT
  #include <iostream>
  #include <strstream>
***************
*** 455,457 ****
--- 456,459 ----
    }
  }
  
+ #endif // BUILD_SERVER
diff -c v1/SocketBasics.cxx v3/SocketBasics.cxx
*** v1/SocketBasics.cxx	Tue Sep  5 11:22:16 2000
--- v3/SocketBasics.cxx	Wed Sep 20 16:44:39 2000
***************
*** 17,23 ****
   * or send mail to:
   *	Timbl@kub.nl
   */
! 
  #include <iostream>
  #include <cstdio>
  #include <string>
--- 17,23 ----
   * or send mail to:
   *	Timbl@kub.nl
   */
! #ifdef BUILD_SERVER
  #include <iostream>
  #include <cstdio>
  #include <string>
***************
*** 233,235 ****
--- 233,236 ----
    return  write_line( socknum, line.c_str() );
  }
  
+ #endif // BUILD_SERVER
diff -c v1/Timbl.cxx v3/Timbl.cxx
*** v1/Timbl.cxx	Tue Sep  5 11:22:16 2000
--- v3/Timbl.cxx	Wed Sep 20 16:44:39 2000
***************
*** 91,99 ****
        cerr << "nothing to test or train!\n" << endl;
        exit(1);
      }
!     if ( !GlobalOptPars.definitive_options( Run, false ) ||
  	 !Run->GetInstanceBase( GlobalOptPars.TreeInFileName ) )
        exit(1);
      if ( GlobalOptPars.NamesFileName != "" )
        Run->WriteNamesFile( GlobalOptPars.NamesFileName );
      bool more_to_do;
--- 91,102 ----
        cerr << "nothing to test or train!\n" << endl;
        exit(1);
      }
!     if ( !GlobalOptPars.definitive_options( Run, true ) ||
  	 !Run->GetInstanceBase( GlobalOptPars.TreeInFileName ) )
        exit(1);
+     //    Run->LearningInfo( cerr );
+     if ( GlobalOptPars.SaveTree() )
+       Run->WriteInstanceBase( GlobalOptPars.TreeOutFileName );
      if ( GlobalOptPars.NamesFileName != "" )
        Run->WriteNamesFile( GlobalOptPars.NamesFileName );
      bool more_to_do;
***************
*** 132,141 ****
      } while ( more_to_do );
    }
    else {
-     char optline[3 * OPT_LENGTH];
-     sprintf( optline, "TREE_ORDER: %s", 
- 	     order_to_string(GlobalOptPars.Order()) );
-     Run->SetOption( optline );
      if ( !GlobalOptPars.definitive_options( Run, true ) )
        exit(1);
      Run->PrepareExperiment( GlobalOptPars.DataFileName );
--- 135,140 ----
diff -c v1/TimblClient.cxx v3/TimblClient.cxx
*** v1/TimblClient.cxx	Tue Sep  5 11:22:16 2000
--- v3/TimblClient.cxx	Wed Sep 20 16:44:39 2000
***************
*** 26,34 ****
  #include <cctype>
  #include <ctime>
  
  
  #ifdef BUILD_SERVER
- #include "TimblExperiment.h"
  #include "ServerProcs.h"
  #else
  void RunClient( istream& Input, ostream& Output, 
--- 26,34 ----
  #include <cctype>
  #include <ctime>
  
+ #include "TimblExperiment.h"
  
  #ifdef BUILD_SERVER
  #include "ServerProcs.h"
  #else
  void RunClient( istream& Input, ostream& Output, 
diff -c v1/Types.cxx v3/Types.cxx
*** v1/Types.cxx	Tue Sep  5 11:22:16 2000
--- v3/Types.cxx	Wed Sep 20 16:44:39 2000
***************
*** 19,24 ****
--- 19,26 ----
   *	Timbl@kub.nl
   */
  
+ // bug fixed 23-08-2000 Ko: verbosity_to_string now returns a copy of c_str()
+ 
  #include <string>
  #include <cstdlib>
  #include <cstring>
***************
*** 275,281 ****
  	Outline += VerbStrings[i][(full?1:0)];
        }
    }
!   return Outline.c_str();
  }
  
  const char *verbosity_to_string( VerbosityFlags v, bool full )
--- 277,283 ----
  	Outline += VerbStrings[i][(full?1:0)];
        }
    }
!   return strdup( Outline.c_str() );
  }
  
  const char *verbosity_to_string( VerbosityFlags v, bool full )
Common subdirectories: v1/X86 and v3/X86
Only in v3: patch300-302
Only in v3: patch301-302

