diff -c ./v0/Common.cxx ./v2/Common.cxx
*** ./v0/Common.cxx	Tue Sep  5 11:22:32 2000
--- ./v2/Common.cxx	Tue Sep  5 11:29:47 2000
***************
*** 23,26 ****
  
  const int Version  = 3;
  const int Revision = 0;
! 
--- 23,26 ----
  
  const int Version  = 3;
  const int Revision = 0;
! const char *RevComment = ".2";
diff -c ./v0/Common.h ./v2/Common.h
*** ./v0/Common.h	Tue Sep  5 11:22:34 2000
--- ./v2/Common.h	Tue Sep  5 11:29:48 2000
***************
*** 34,41 ****
  
  extern const int Version;
  extern const int Revision;
  
- 
  inline char look_ahead( istream &is )
  {
    char ch;
--- 34,41 ----
  
  extern const int Version;
  extern const int Revision;
+ extern const char *RevComment;
  
  inline char look_ahead( istream &is )
  {
    char ch;
diff -c ./v0/GetOptClass.cxx ./v2/GetOptClass.cxx
*** ./v0/GetOptClass.cxx	Tue Sep  5 11:22:34 2000
--- ./v2/GetOptClass.cxx	Tue Sep  5 11:29:48 2000
***************
*** 21,26 ****
--- 21,30 ----
   *	Timbl@kub.nl
   */
  
+ //
+ // 10 april 2000: Fixed a problem with get_N_option
+ //
+ 
  #include <fstream>
  #include <string>
  #include <cstdio>
***************
*** 337,344 ****
      if ( *Option++ == '-' ){
        while( isspace(*Option) ) Option++;
        if ( *Option++ == 'N' ) {
- 	Result = atoi( Option );
  	MaxFeatsSet = true;
  	break;
        }
      }
--- 341,355 ----
      if ( *Option++ == '-' ){
        while( isspace(*Option) ) Option++;
        if ( *Option++ == 'N' ) {
  	MaxFeatsSet = true;
+ 	Result = 0;
+ 	if ( *Option )
+ 	  Result = atoi( Option );
+ 	else if (opt < Argc )
+ 	  Result = atoi( Argv[opt] );
+ 	if ( Result == 0 ){
+ 	  cerr << "missing a number after N option" << endl;
+ 	}
  	break;
        }
      }
diff -c ./v0/Instance.cxx ./v2/Instance.cxx
*** ./v0/Instance.cxx	Tue Sep  5 11:22:35 2000
--- ./v2/Instance.cxx	Tue Sep  5 11:29:48 2000
***************
*** 19,24 ****
--- 19,29 ----
   *	Timbl@kub.nl
   */
  
+ //
+ // 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.
+ //
  #include <iostream>
  #include <strstream>
  #include <iomanip>
***************
*** 380,387 ****
    if ((map_iterator = Mapping.find( ID )) == Mapping.end()){
      // Token was not found in map, so we insert a new copy of it here
      //
!     Mapping.insert( IImaptype::value_type( ID, NumVals ));
!     index = NumVals++;
    }
    else{
      index = (*map_iterator).second;
--- 385,392 ----
    if ((map_iterator = Mapping.find( ID )) == Mapping.end()){
      // Token was not found in map, so we insert a new copy of it here
      //
!     Mapping.insert( IImaptype::value_type( ID, array_size ));
!     index = array_size++;
    }
    else{
      index = (*map_iterator).second;
***************
*** 389,394 ****
--- 394,418 ----
    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;
+   for ( i=0; i < ArraySize(); i++ )
+     if ( ValuesArray[i]->ValFreq() > 0 )
+       result++;
+   return result;
+ }
+ 
  FeatureValue *Feature::add_value( char *valstr, TargetValue *tv )
  {
    HashInfo *Tok = TokenTree->Hash( valstr );
***************
*** 406,418 ****
    return (FeatureValue *)ValuesArray[index];
  }
  
  BaseFeatTargClass::BaseFeatTargClass( int Size, int Inc, StringHash *T )
  {
    CurSize = Size;
    Increment = Inc;
    TokenTree = T;
!   Scraped = 0;
!   NumVals = 0;
    TotalVals = 0;
    ValuesArray = (ValueClass **)malloc( sizeof(ValueClass*) * CurSize );
    assert( ValuesArray != NULL );
--- 430,467 ----
    return (FeatureValue *)ValuesArray[index];
  }
  
+ bool Feature::increment_value( FeatureValue *FV, TargetValue *tv )
+ {
+   bool result = false;
+   if ( FV ){
+     TotalVals++;
+     FV->incr_val_freq();
+     if ( tv )
+       FV->TargetDist[tv] += 1;
+     result = true;
+   }
+   return result;
+ }
+ 
+ bool Feature::decrement_value( FeatureValue *FV, TargetValue *tv )
+ {
+   bool result = false;
+   if ( FV ){
+     TotalVals--;
+     FV->decr_val_freq();
+     if ( tv )
+       FV->TargetDist[tv] -= 1;
+     result = true;
+   }
+   return result;
+ }
+ 
  BaseFeatTargClass::BaseFeatTargClass( int Size, int Inc, StringHash *T )
  {
    CurSize = Size;
    Increment = Inc;
    TokenTree = T;
!   array_size = 0;
    TotalVals = 0;
    ValuesArray = (ValueClass **)malloc( sizeof(ValueClass*) * CurSize );
    assert( ValuesArray != NULL );
***************
*** 470,480 ****
  
  bool Feature::prepare_numeric_stats( )
  { 
!   double tmp, Total = 0.0;
    int freq;
    bool first = true;
    int i;
!   for ( i=0; i < NumOfValues(); i++ ){
      freq = ValuesArray[i]->ValFreq();
      if ( freq ){
        if ( !string2double( ValuesArray[i]->Name(), tmp ) ){
--- 519,529 ----
  
  bool Feature::prepare_numeric_stats( )
  { 
!   double tmp;
    int freq;
    bool first = true;
    int i;
!   for ( i=0; i < ArraySize(); i++ ){
      freq = ValuesArray[i]->ValFreq();
      if ( freq ){
        if ( !string2double( ValuesArray[i]->Name(), tmp ) ){
***************
*** 492,498 ****
  	  Min = tmp;
  	else if ( tmp > Max )
  	  Max = tmp;
- 	Total += tmp * freq;
        }
      }
    }
--- 541,546 ----
***************
*** 512,521 ****
      FVBin[i] = new FeatureValue( dumname );
    }
    int j;
!   for ( j=0; j < NumOfValues(); j++ ){
!     string2double( ValuesArray[j]->Name(), tmp );
!     place = (int)(floor((tmp - Min)/(Max-Min) * (BIN_SIZE-1)) );
!     FVBin[place]->TargetDist.Merge( &((FeatureValue *)ValuesArray[j])->TargetDist );
    }
    int k;
    for ( k=0; k < BIN_SIZE; k++ ){
--- 560,571 ----
      FVBin[i] = new FeatureValue( dumname );
    }
    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 );
!     }
    }
    int k;
    for ( k=0; k < BIN_SIZE; k++ ){
***************
*** 573,584 ****
    VDlist *hlp;
    FeatureValue **pnt = (FeatureValue**)ValuesArray;
    int i;
!   for ( i=0; i < NumOfValues(); i++ ){
      // Entropy for this FV pair.
      //
      double FVEntropy = 0.0;
      double Freq = pnt[i]->ValFreq();
!     if ( Freq ){
        hlp = pnt[i]->TargetDist.First();
        while ( hlp ){
  	Prob = hlp->Freq() / Freq;
--- 623,634 ----
    VDlist *hlp;
    FeatureValue **pnt = (FeatureValue**)ValuesArray;
    int i;
!   for ( i=0; i < ArraySize(); i++ ){
      // Entropy for this FV pair.
      //
      double FVEntropy = 0.0;
      double Freq = pnt[i]->ValFreq();
!     if ( Freq > 0 ){
        hlp = pnt[i]->TargetDist.First();
        while ( hlp ){
  	Prob = hlp->Freq() / Freq;
***************
*** 599,607 ****
    SplitInfo = 0.0;
    pnt = (FeatureValue **)ValuesArray;
    int j;
!   for ( j=0; j < NumOfValues(); j++ ){
      Prob = pnt[j]->ValFreq() / (double)TotalValues();
!     if ( Prob )
        SplitInfo += Prob * Log2(Prob);
    } 
    SplitInfo = -SplitInfo;
--- 649,657 ----
    SplitInfo = 0.0;
    pnt = (FeatureValue **)ValuesArray;
    int j;
!   for ( j=0; j < ArraySize(); j++ ){
      Prob = pnt[j]->ValFreq() / (double)TotalValues();
!     if ( Prob > 0 )
        SplitInfo += Prob * Log2(Prob);
    } 
    SplitInfo = -SplitInfo;
***************
*** 617,624 ****
  {
    VDlist *pnt;
    FeatureValue **FVA = (FeatureValue **)ValuesArray;
!   int Size = Targets->NumOfValues();
!   int Num_Vals = NumOfValues();
    long int n_dot_dot = 0;
    double tmp;
    if ( !n_dot_j ) {
--- 667,674 ----
  {
    VDlist *pnt;
    FeatureValue **FVA = (FeatureValue **)ValuesArray;
!   int Size = Targets->ArraySize();
!   int Num_Vals = ArraySize();
    long int n_dot_dot = 0;
    double tmp;
    if ( !n_dot_j ) {
***************
*** 635,641 ****
      }
      if ( SaveNum < Num_Vals ){
        delete [] n_i_dot;
!       n_i_dot = new long int[Size];
        SaveNum = Num_Vals;
      }
    }
--- 685,691 ----
      }
      if ( SaveNum < Num_Vals ){
        delete [] n_i_dot;
!       n_i_dot = new long int[Num_Vals];
        SaveNum = Num_Vals;
      }
    }
***************
*** 695,702 ****
  void Feature::SharedVarianceStatistics( Target *Targ )
  {
    int NumInst = Targ->TotalValues();
!   int NumCats = Targ->NumOfValues();
!   int k = min( NumCats, NumOfValues() ) - 1 ;
    if ( k == 0 )
      SharedVariance = 0;
    else
--- 745,752 ----
  void Feature::SharedVarianceStatistics( Target *Targ )
  {
    int NumInst = Targ->TotalValues();
!   int NumCats = Targ->EffectiveValues();
!   int k = min( NumCats, EffectiveValues() ) - 1 ;
    if ( k == 0 )
      SharedVariance = 0;
    else
***************
*** 707,713 ****
  {
    if ( VDmatrix ){
      int i;
!     for ( i = 0; i < NumOfValues(); i++)
        free(VDmatrix[i]);
      free(VDmatrix);
    }
--- 757,763 ----
  {
    if ( VDmatrix ){
      int i;
!     for ( i = 0; i < ArraySize(); i++)
        free(VDmatrix[i]);
      free(VDmatrix);
    }
***************
*** 722,738 ****
  {
    int i, j;
    if ( !Prestore_failed && VDmatrix == NULL ){
!     if ( NumOfValues() > 1000 ){
        Prestore_failed = true;
        return false;
      }
!     VDmatrix = (double**)malloc( NumOfValues() * sizeof(double*) );
      if ( VDmatrix == NULL ){
        Prestore_failed = true;
        return false;
      }
!     for (i = 0; i < NumOfValues(); i++) {
!       VDmatrix[i] = (double *)malloc( NumOfValues() * sizeof(double) );
        if ( VDmatrix[i] == NULL ){
  	int si;
  	for ( si = i-1; si >= 0; si-- )
--- 772,788 ----
  {
    int i, j;
    if ( !Prestore_failed && VDmatrix == NULL ){
!     if ( ArraySize() > 1000 ){
        Prestore_failed = true;
        return false;
      }
!     VDmatrix = (double**)malloc( ArraySize() * sizeof(double*) );
      if ( VDmatrix == NULL ){
        Prestore_failed = true;
        return false;
      }
!     for (i = 0; i < ArraySize(); i++) {
!       VDmatrix[i] = (double *)malloc( ArraySize() * sizeof(double) );
        if ( VDmatrix[i] == NULL ){
  	int si;
  	for ( si = i-1; si >= 0; si-- )
***************
*** 745,752 ****
      }
      // Now we have the memory. Calculate and store.
      //
!     for ( i = 0; i< NumOfValues(); i++ ){
!       for ( j=0; j < NumOfValues(); j++ ){
  	double result = 0.0;
  	SA_list<double> *p1 = 
  	  ((FeatureValue *)ValuesArray[i])->SValueClassProb->First();
--- 795,802 ----
      }
      // Now we have the memory. Calculate and store.
      //
!     for ( i = 0; i< ArraySize(); i++ ){
!       for ( j=0; j < ArraySize(); j++ ){
  	double result = 0.0;
  	SA_list<double> *p1 = 
  	  ((FeatureValue *)ValuesArray[i])->SValueClassProb->First();
***************
*** 785,791 ****
  {
    FeatureValue **FVA = (FeatureValue **)ValuesArray;
    int i;
!   for ( i = 0; i < NumOfValues(); i++ ){
      if ( FVA[i]->SValueClassProb )
        os << FVA[i] << FVA[i]->SValueClassProb << endl;
    }
--- 835,841 ----
  {
    FeatureValue **FVA = (FeatureValue **)ValuesArray;
    int i;
!   for ( i = 0; i < ArraySize(); i++ ){
      if ( FVA[i]->SValueClassProb )
        os << FVA[i] << FVA[i]->SValueClassProb << endl;
    }
***************
*** 802,808 ****
    FeatureValue **FVA = (FeatureValue **)ValuesArray;
    // clear all existing arrays
    int i;
!   for ( i = 0; i < NumOfValues(); i++ ){
      if ( FVA[i]->SValueClassProb ){
        delete FVA[i]->SValueClassProb;
      }
--- 852,858 ----
    FeatureValue **FVA = (FeatureValue **)ValuesArray;
    // clear all existing arrays
    int i;
!   for ( i = 0; i < ArraySize(); i++ ){
      if ( FVA[i]->SValueClassProb ){
        delete FVA[i]->SValueClassProb;
      }
***************
*** 853,859 ****
    }
    // check if we've got all the values, assign a default if not so
    int j;
!   for ( j = 0; j < NumOfValues(); j++ ){
      if ( FVA[j]->SValueClassProb == NULL ){
        FVA[j]->SValueClassProb = new SparseArrayClass<double>( Num );
        FVA[j]->SValueClassProb->Assign( 0, -1.0 );
--- 903,909 ----
    }
    // check if we've got all the values, assign a default if not so
    int j;
!   for ( j = 0; j < ArraySize(); j++ ){
      if ( FVA[j]->SValueClassProb == NULL ){
        FVA[j]->SValueClassProb = new SparseArrayClass<double>( Num );
        FVA[j]->SValueClassProb->Assign( 0, -1.0 );
***************
*** 869,875 ****
    //
  {
    if ( shrt ){
!     cout << " a " << NumOfValues() << "x" << NumOfValues() 
  	 << " matrix" << endl;
    }
    else {
--- 919,925 ----
    //
  {
    if ( shrt ){
!     cout << " a " << ArraySize() << "x" << ArraySize() 
  	 << " matrix" << endl;
    }
    else {
***************
*** 876,882 ****
      int old_prec = cout.precision();
      cout.setf( ios::scientific );
      int i;
!     for ( i=0; i< NumOfValues(); i++ ){
        cout.width(6);
        cout.setf(ios::left, ios::adjustfield);
        cout << (FeatureValue *)ValuesArray[i] << ":";
--- 926,932 ----
      int old_prec = cout.precision();
      cout.setf( ios::scientific );
      int i;
!     for ( i=0; i< ArraySize(); i++ ){
        cout.width(6);
        cout.setf(ios::left, ios::adjustfield);
        cout << (FeatureValue *)ValuesArray[i] << ":";
***************
*** 884,890 ****
        cout.precision(3);
        cout.setf(ios::right, ios::adjustfield);
        int j;
!       for ( j = 0; j < NumOfValues(); j++) {
  	cout.width(12); 
  	cout.precision(3);
  	cout.setf(ios::right, ios::adjustfield);
--- 934,940 ----
        cout.precision(3);
        cout.setf(ios::right, ios::adjustfield);
        int j;
!       for ( j = 0; j < ArraySize(); j++) {
  	cout.width(12); 
  	cout.precision(3);
  	cout.setf(ios::right, ios::adjustfield);
***************
*** 911,916 ****
--- 961,988 ----
    return (TargetValue *)ValuesArray[index];
  }
  
+ bool Target::increment_value( TargetValue *TV )
+ {
+   bool result = false;
+   if ( TV ){
+     TotalVals++;
+     TV->incr_val_freq();
+     result = true;
+   }
+   return result;
+ }
+ 
+ bool Target::decrement_value( TargetValue *TV )
+ {
+   bool result = false;
+   if ( TV ){
+     TotalVals--;
+     TV->decr_val_freq();
+     result = true;
+   }
+   return result;
+ }
+ 
  Instance::Instance( int len )
  {
    FV = new FeatureValue*[len];
diff -c ./v0/Instance.h ./v2/Instance.h
*** ./v0/Instance.h	Tue Sep  5 11:22:36 2000
--- ./v2/Instance.h	Tue Sep  5 11:29:48 2000
***************
*** 226,246 ****
    ValueClass **ValuesArray;
    BaseFeatTargClass( int, int, StringHash * );
    ~BaseFeatTargClass();
!   int NumOfValues() { return NumVals; };
!   unsigned int TotalValues() { return TotalVals - Scraped; };
!   int Scraped;
    int localmapping( int );
    ValueClass *Lookup( char * );
   protected:
    int CurSize;
    int Increment;
    unsigned int TotalVals;
!   int NumVals;
    StringHash *TokenTree;
    IImaptype Mapping;
    void enlarge_values_array( int );
!   ValueClass *get_value_index( int I )
!   { return ValuesArray[I]; };
  };
  
  
--- 226,246 ----
    ValueClass **ValuesArray;
    BaseFeatTargClass( int, int, StringHash * );
    ~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]; };
  };
  
  
***************
*** 248,253 ****
--- 248,255 ----
   public:
    Target( int a, int b, StringHash *T ): BaseFeatTargClass(a,b,T) {};
    TargetValue *add_value( char * );
+   bool decrement_value( TargetValue * );
+   bool increment_value( TargetValue * );
  };
  
  class Feature: public BaseFeatTargClass {
***************
*** 288,293 ****
--- 290,297 ----
      };
    ~Feature();
    FeatureValue *add_value( char *, TargetValue * );
+   bool decrement_value( FeatureValue *, TargetValue * );
+   bool increment_value( FeatureValue *, TargetValue * );
    bool store_vd_matrix( );
    void delete_vd_matrix( void );
    void print_vd_matrix( bool s = false );
diff -c ./v0/MBLClass.cxx ./v2/MBLClass.cxx
*** ./v0/MBLClass.cxx	Tue Sep  5 11:22:36 2000
--- ./v2/MBLClass.cxx	Tue Sep  5 11:29:48 2000
***************
*** 18,23 ****
--- 18,30 ----
   *	Timbl@kub.nl
   */
  
+ //
+ // 27-3-2000: Ko : UnHideInstance: Features[i] should be  Permfeatures[i]
+ //                                 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
+ //
+ 
  #include <fstream>
  #include <strstream>
  #include <iomanip>
***************
*** 500,516 ****
  inline void MBLClass::write_perm(void)
  {
    int j;
!   ostrstream outstr;
!   outstr << "Feature Permutation based on "
! 	 << order_to_string(TreeOrder, true) << " :\n";
!   outstr << "< ";
    for ( j=0; j < NumOfFeatures-1; j++ ){
!     outstr << Permutation[j]+1 << ", ";
    }
!   outstr << Permutation[j]+1 << " >" << ends;
!   char *pnt = outstr.str();
!   Info( pnt );
!   delete [] pnt;
  }
  
  inline void MBLClass::write_perm_special( ostream &os )
--- 507,519 ----
  inline void MBLClass::write_perm(void)
  {
    int j;
!   Info( "Feature Permutation based on %s :",
! 	order_to_string(TreeOrder, true) );
!   cerr << "< ";
    for ( j=0; j < NumOfFeatures-1; j++ ){
!     cerr << Permutation[j]+1 << ", ";
    }
!   cerr << Permutation[j]+1 << " >" << endl;
  }
  
  inline void MBLClass::write_perm_special( ostream &os )
***************
*** 743,761 ****
        Order[i] = Features[i]->SharedVariance;
        break;
      case OneoverFeature:
!       Order[i] =  1.0 / Features[i]->NumOfValues();
        break;
      case GRoverFeature:
!       Order[i] =  Features[i]->GainRatio / Features[i]->NumOfValues();
        break;
      case IGoverFeature:
!       Order[i] =  Features[i]->InfoGain / Features[i]->NumOfValues();
        break;
      case X2overFeature:
!       Order[i] =  Features[i]->ChiSquare / Features[i]->NumOfValues();
        break;
      case SVoverFeature:
!       Order[i] =  Features[i]->SharedVariance / Features[i]->NumOfValues();
        break;
      case OneoverSplitInfo:
        Order[i] =  1.0 / Features[i]->SplitInfo;
--- 746,764 ----
        Order[i] = Features[i]->SharedVariance;
        break;
      case OneoverFeature:
!       Order[i] =  1.0 / Features[i]->ArraySize();
        break;
      case GRoverFeature:
!       Order[i] =  Features[i]->GainRatio / Features[i]->ArraySize();
        break;
      case IGoverFeature:
!       Order[i] =  Features[i]->InfoGain / Features[i]->ArraySize();
        break;
      case X2overFeature:
!       Order[i] =  Features[i]->ChiSquare / Features[i]->ArraySize();
        break;
      case SVoverFeature:
!       Order[i] =  Features[i]->SharedVariance / Features[i]->ArraySize();
        break;
      case OneoverSplitInfo:
        Order[i] =  1.0 / Features[i]->SplitInfo;
***************
*** 973,982 ****
        //
        out << "Targets : ";
        int t;
!       for ( t=0; t < Targets->NumOfValues()-1; t++ ) {
  	out << tv[t] << ", ";
        } 
!       out << tv[Targets->NumOfValues()-1] << "." << endl << endl;
        int i;
        for ( i = 0; i < NumOfFeatures; i++ )
  	if ( Features[i]->Ignore )
--- 976,985 ----
        //
        out << "Targets : ";
        int t;
!       for ( t=0; t < Targets->ArraySize()-1; t++ ) {
  	out << tv[t] << ", ";
        } 
!       out << tv[Targets->ArraySize()-1] << "." << endl << endl;
        int i;
        for ( i = 0; i < NumOfFeatures; i++ )
  	if ( Features[i]->Ignore )
***************
*** 997,1003 ****
  
  bool MBLClass::allocate_arrays()
  {
!   int Dim = Targets->NumOfValues();
    int i,j;
    for ( j = 0; j < NumOfFeatures; j++) {
      if ( !Features[j]->Ignore ) {
--- 1000,1006 ----
  
  bool MBLClass::allocate_arrays()
  {
!   int Dim = Targets->ArraySize();
    int i,j;
    for ( j = 0; j < NumOfFeatures; j++) {
      if ( !Features[j]->Ignore ) {
***************
*** 1004,1010 ****
        FeatureValue **FVA = (FeatureValue **)Features[j]->ValuesArray;
        // Loop over all values.
        //
!       for ( i=0; i < Features[j]->NumOfValues(); i++ ){
  	// Loop over all classes.
  	if ( FVA[i]->SValueClassProb == NULL ){
  	  if ( !(FVA[i]->SValueClassProb = 
--- 1007,1013 ----
        FeatureValue **FVA = (FeatureValue **)Features[j]->ValuesArray;
        // Loop over all values.
        //
!       for ( i=0; i < Features[j]->ArraySize(); i++ ){
  	// Loop over all classes.
  	if ( FVA[i]->SValueClassProb == NULL ){
  	  if ( !(FVA[i]->SValueClassProb = 
***************
*** 1034,1042 ****
  	  FeatureValue **FVA = (FeatureValue **)Features[j]->ValuesArray;
  	  // Loop over all values.
  	  //
! 	  for ( i=0; i < Features[j]->NumOfValues(); i++ ){
  	    double freq = FVA[i]->ValFreq();
! 	    if ( freq ){
  	      // Loop over all classes.
  	      //
  	      VDlist *tmp = FVA[i]->TargetDist.First( );
--- 1037,1045 ----
  	  FeatureValue **FVA = (FeatureValue **)Features[j]->ValuesArray;
  	  // Loop over all values.
  	  //
! 	  for ( i=0; i < Features[j]->ArraySize(); i++ ){
  	    double freq = FVA[i]->ValFreq();
! 	    if ( freq > 0 ){
  	      // Loop over all classes.
  	      //
  	      VDlist *tmp = FVA[i]->TargetDist.First( );
***************
*** 1325,1331 ****
      for ( k = 0; k < EffectiveFeatures; k++ ){
        register int j = Permutation[k];
        CurrInst->FV[k] = (FeatureValue*)Features[j]->Lookup( OrgInput[j] );
!     } // i
      // and the Target
      CurrInst->TV = (TargetValue*)Targets->Lookup( OrgInput[NumOfFeatures] );
      break;
--- 1328,1334 ----
      for ( k = 0; k < EffectiveFeatures; k++ ){
        register int j = Permutation[k];
        CurrInst->FV[k] = (FeatureValue*)Features[j]->Lookup( OrgInput[j] );
!     } // k
      // and the Target
      CurrInst->TV = (TargetValue*)Targets->Lookup( OrgInput[NumOfFeatures] );
      break;
***************
*** 1419,1425 ****
    s.precision(8);
    s.setf(ios::showpoint );
    s << "DB Entropy        : " << DBEntropy << endl;
!   s << "Number of Classes : " << Targets->NumOfValues() << endl;
    s << endl;
    if ( verbosity & FEAT_W ){
      s << "Feats\tVals\tX-square\tVariance\tInfoGain\tGainRatio" << endl;
--- 1422,1429 ----
    s.precision(8);
    s.setf(ios::showpoint );
    s << "DB Entropy        : " << DBEntropy << endl;
!   //  s << "Number of Classes : " << Targets->ArraySize() << endl;
!   s << "Number of Classes : " << Targets->EffectiveValues() << endl;
    s << endl;
    if ( verbosity & FEAT_W ){
      s << "Feats\tVals\tX-square\tVariance\tInfoGain\tGainRatio" << endl;
***************
*** 1433,1439 ****
        else{
  	s.width(7);
  	s.setf(ios::right, ios::adjustfield);
! 	s << Features[i]->NumOfValues()
  	  << "\t" << Features[i]->ChiSquare
  	  << "\t" << Features[i]->SharedVariance
  	  << "\t" << Features[i]->InfoGain
--- 1437,1444 ----
        else{
  	s.width(7);
  	s.setf(ios::right, ios::adjustfield);
! 	//	s << Features[i]->ArraySize()
! 	s << Features[i]->EffectiveValues()
  	  << "\t" << Features[i]->ChiSquare
  	  << "\t" << Features[i]->SharedVariance
  	  << "\t" << Features[i]->InfoGain
***************
*** 1470,1476 ****
        if ( verbosity )
  	Info( "Saving Weights in %s", FileName );
        outfile << "# DB Entropy: " << DBEntropy << endl;
!       outfile << "# Classes: " << Targets->NumOfValues() << endl;
        outfile << "# Lines of data: " << Targets->TotalValues() << endl;
        outfile << "# Fea." << "\t" << "Weight" << endl;
        InitWeights( );
--- 1475,1481 ----
        if ( verbosity )
  	Info( "Saving Weights in %s", FileName );
        outfile << "# DB Entropy: " << DBEntropy << endl;
!       outfile << "# Classes: " << Targets->ArraySize() << endl;
        outfile << "# Lines of data: " << Targets->TotalValues() << endl;
        outfile << "# Fea." << "\t" << "Weight" << endl;
        InitWeights( );
***************
*** 1839,1848 ****
      double Entropy = 0.0, Ratio;
      // first get the Database Entropy
      int i;
!     for ( i=0; i < Targets->NumOfValues(); i++ ) {
        Ratio = Targets->ValuesArray[i]->ValFreq() / 
  	(double)Targets->TotalValues();
!       if ( Ratio )
  	Entropy += Ratio * Log2(Ratio);
      }
      DBEntropy = fabs(-Entropy);
--- 1844,1853 ----
      double Entropy = 0.0, Ratio;
      // first get the Database Entropy
      int i;
!     for ( i=0; i < Targets->ArraySize(); i++ ) {
        Ratio = Targets->ValuesArray[i]->ValFreq() / 
  	(double)Targets->TotalValues();
!       if ( Ratio > 0 )
  	Entropy += Ratio * Log2(Ratio);
      }
      DBEntropy = fabs(-Entropy);
***************
*** 1962,1971 ****
        // Print the possible classes.
        //
        int t;
!       for ( t=0; t < Targets->NumOfValues()-1; t++ ) {
  	namesfile << tv[t] << ",";
        } 
!       namesfile << tv[Targets->NumOfValues()-1] << "." << endl << endl;
        
        // Loop over the Features.
        //
--- 1967,1976 ----
        // Print the possible classes.
        //
        int t;
!       for ( t=0; t < Targets->ArraySize()-1; t++ ) {
  	namesfile << tv[t] << ",";
        } 
!       namesfile << tv[Targets->ArraySize()-1] << "." << endl << endl;
        
        // Loop over the Features.
        //
***************
*** 1991,2000 ****
  	    //
  	    vf = (FeatureValue **)Features[f]->ValuesArray;
  	    int i;
! 	    for ( i=0; i< Features[f]->NumOfValues()-1; i++ ){
  	      namesfile << vf[i] << ",";
  	    }
! 	    namesfile << vf[Features[f]->NumOfValues()-1]
  		      << "." << endl;
  	  }
  	}
--- 1996,2005 ----
  	    //
  	    vf = (FeatureValue **)Features[f]->ValuesArray;
  	    int i;
! 	    for ( i=0; i< Features[f]->ArraySize()-1; i++ ){
  	      namesfile << vf[i] << ",";
  	    }
! 	    namesfile << vf[Features[f]->ArraySize()-1]
  		      << "." << endl;
  	  }
  	}
***************
*** 2450,2470 ****
    InstanceBase->RemoveInstance( Inst );
    int i;
    for ( i=0; i < EffectiveFeatures && result; i++ ){
!     if ( !Inst->FV[i] ){
        FatalError( "Unable to Hide an Instance!" );
        result = false;
      }
-     else { 
-       Inst->FV[i]->decr_val_freq();
-       PermFeatures[i]->delete_vd_matrix();
-       PermFeatures[i]->Scraped = 1;
-     }
    }
    if ( result ){
!     Inst->TV->decr_val_freq();
!     Targets->Scraped = 1;
!     MBLInit = false;
!     result = prepare_MBL_test();
    }
    return result;
  }
--- 2455,2470 ----
    InstanceBase->RemoveInstance( Inst );
    int i;
    for ( i=0; i < EffectiveFeatures && result; i++ ){
!     if ( PermFeatures[i]->decrement_value( Inst->FV[i], Inst->TV ) ){
!       PermFeatures[i]->delete_vd_matrix();
!     }
!     else {
        FatalError( "Unable to Hide an Instance!" );
        result = false;
      }
    }
    if ( result ){
!     Targets->decrement_value( Inst->TV );
    }
    return result;
  }
***************
*** 2474,2484 ****
    InstanceBase->AddInstance( Inst );
    int i;
    for ( i=0; i < EffectiveFeatures; i++ ){    
!     Inst->FV[i]->incr_val_freq();
!     Features[i]->Scraped = 0;
    }
!   Inst->TV->incr_val_freq();
!   Targets->Scraped = 0;
  }
  
  ValueDistribution *LOOClass::LocalClassify( int &status,
--- 2474,2482 ----
    InstanceBase->AddInstance( Inst );
    int i;
    for ( i=0; i < EffectiveFeatures; i++ ){    
!     PermFeatures[i]->increment_value( Inst->FV[i], Inst->TV );
    }
!   Targets->increment_value( Inst->TV );
  }
  
  ValueDistribution *LOOClass::LocalClassify( int &status,
***************
*** 2487,2493 ****
    status = -1;
    ValueDistribution *ResultDist = NULL;
    strings_to_instance( TestWords );
!   if ( HideInstance( CurrInst ) ){
      if ( do_exact_match )
        ResultDist = InstanceBase->ExactMatch( CurrInst );
      if ( ResultDist ){
--- 2485,2492 ----
    status = -1;
    ValueDistribution *ResultDist = NULL;
    strings_to_instance( TestWords );
!   MBLInit = false;
!   if ( HideInstance( CurrInst ) && prepare_MBL_test() ){
      if ( do_exact_match )
        ResultDist = InstanceBase->ExactMatch( CurrInst );
      if ( ResultDist ){
***************
*** 2500,2508 ****
        ResultDist = test_instance_full( CurrInst, Distance );
      }
      UnHideInstance( CurrInst );
    }
    else {
!     Warning( " Hiding failed!\n" );
    }
    return ResultDist;
  }
--- 2499,2508 ----
        ResultDist = test_instance_full( CurrInst, Distance );
      }
      UnHideInstance( CurrInst );
+     MBLInit = false;
    }
    else {
!     FatalError( " Hiding failed!\n" );
    }
    return ResultDist;
  }
diff -c ./v0/Makefile ./v2/Makefile
*** ./v0/Makefile	Tue Sep  5 11:22:37 2000
--- ./v2/Makefile	Tue Sep  5 11:29:48 2000
***************
*** 9,14 ****
--- 9,21 ----
  OBJS	= $(SRCS:.cxx=.o)
  EXES	= $(MSRCS:.cxx=)
  
+ #INSTALL_DIR = /usr/local/bin
+ #LIB_INSTALL_DIR = /usr/local/lib
+ INSTALL_DIR = ./SPARC
+ LIB_INSTALL_DIR = ./SPARC
+ #INSTALL_DIR = ./X86
+ #LIB_INSTALL_DIR = ./X86
+ 
  all:
  	-@if [ $(OSTYPE) = linux ] ||\
  	 [ $(OSTYPE) = Linux ] || \
***************
*** 44,48 ****
  	-rm *.tmp
  
  install:
! 	cp $(EXES) /usr/local/bin
! 	cp libTimbl.a /usr/local/lib
--- 51,55 ----
  	-rm *.tmp
  
  install:
! 	cp $(EXES) $(INSTALL_DIR)
! 	cp libTimbl.a $(LIB_INSTALL_DIR)
Only in ./v0: SPARC
diff -c ./v0/Timbl.cxx ./v2/Timbl.cxx
*** ./v0/Timbl.cxx	Tue Sep  5 11:22:38 2000
--- ./v2/Timbl.cxx	Tue Sep  5 11:29:49 2000
***************
*** 47,53 ****
    string TheTestFile, PercFile;
    // Start.
    //
!   cerr << "TiMBL " << Version << "." << Revision
         << " (c) ILK 1998, 1999, 2000.\n" 
         << "Tilburg Memory Based Learner\n"
         << "Induction of Linguistic Knowledge Research Group\n"
--- 47,53 ----
    string TheTestFile, PercFile;
    // Start.
    //
!   cerr << "TiMBL " << Version << "." << Revision << RevComment
         << " (c) ILK 1998, 1999, 2000.\n" 
         << "Tilburg Memory Based Learner\n"
         << "Induction of Linguistic Knowledge Research Group\n"
Only in ./v0: X86
Only in ./v2: patch301-302

