Ignore:
Timestamp:
Oct 8, 2007, 4:06:53 PM (14 years ago)
Author:
Markus Ringnér
Message:

Adding support and checks for intended lookups in classifiers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/NBC.cc

    r865 r948  
    6363  NBC::make_classifier(const DataLookup2D& data, const Target& target) const
    6464  {     
    65     NBC* ncc=0;
    66     if(data.weighted()) {
    67       ncc=new NBC(dynamic_cast<const MatrixLookupWeighted&>(data),target);
     65    NBC* nbc=0;
     66    try {
     67      if(data.weighted()) {
     68        nbc=new NBC(dynamic_cast<const MatrixLookupWeighted&>(data),target);
     69      }
     70      else {
     71        nbc=new NBC(dynamic_cast<const MatrixLookup&>(data),target);
     72      }     
    6873    }
    69     else {
    70       ncc=new NBC(dynamic_cast<const MatrixLookup&>(data),target);
     74    catch (std::bad_cast) {
     75      std::string str = "Error in NBC::make_classifier: DataLookup2D of unexpected class.";
     76      throw std::runtime_error(str);
    7177    }
    72     return ncc;
     78    return nbc;
    7379  }
    7480
Note: See TracChangeset for help on using the changeset viewer.