Changeset 860
- Timestamp:
- Sep 7, 2007, 9:39:30 PM (16 years ago)
- Location:
- trunk/yat/classifier
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/classifier/Target.cc
r831 r860 4 4 Copyright (C) 2005 Peter Johansson 5 5 Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson 6 Copyright (C) 2007 Peter Johansson 6 7 7 8 This file is part of the yat library, http://lev.thep.lu.se/trac/yat … … 46 47 } 47 48 48 Target::Target(const Target& t, 49 const std::vector<size_t>& index) 49 50 Target::Target(const std::vector<std::string>& label, 51 const Target& t) 50 52 : class_map_(t.class_map_) 51 53 { 52 54 binary_=t.binary_; 53 classes_.resize(index.size());54 for (size_t i=0; i<index.size(); i++) {55 assert(index[i]<t.size());56 classes_[i]=t.classes_[index[i]];57 }58 55 labels_ = t.labels_; 56 classes_.reserve(label.size()); 57 for (std::vector<std::string>::const_iterator lab=label.begin(); 58 lab!=label.end(); ++lab) { 59 std::map<std::string,size_t>::iterator i=class_map_.lower_bound(*lab); 60 if (i->first==*lab) // label exists 61 classes_.push_back(i->second); 62 else { 63 binary_.push_back(0); 64 classes_.push_back(labels_.size()); 65 class_map_.insert(i, std::make_pair(*lab, labels_.size())); 66 labels_.push_back(*lab); 67 } 68 } 59 69 } 60 70 … … 85 95 } 86 96 97 98 Target::Target(const Target& t, 99 const std::vector<size_t>& index) 100 : class_map_(t.class_map_) 101 { 102 binary_=t.binary_; 103 classes_.resize(index.size()); 104 for (size_t i=0; i<index.size(); i++) { 105 assert(index[i]<t.size()); 106 classes_[i]=t.classes_[index[i]]; 107 } 108 labels_ = t.labels_; 109 } 110 111 87 112 Target::~Target(void) 88 113 { -
trunk/yat/classifier/Target.h
r831 r860 52 52 explicit Target(const std::vector<std::string>& labels); 53 53 54 /** 55 @brief Constructor 56 */ 57 Target(const std::vector<std::string>& labels, const Target&); 58 54 59 /// 55 60 /// @brief istream constructor. … … 57 62 Target(std::istream&, char sep='\0') 58 63 throw (utility::IO_error,std::exception); 59 60 ///61 /// @brief Copy Constructor62 ///63 //Target(const Target& other)64 // : classes_(other.classes_), class_map_(other.class_map_),65 // labels_(other.labels_) {}66 64 67 65 /// … … 84 82 const std::map<std::string,size_t>& classes(void) const; 85 83 86 /// 87 /// This function is equivalent to Target::classes().size() 88 /// 89 /// @return number of classes 90 /// 84 /** 85 This function is equivalent to Target::classes().size() 86 87 \return number of classes 88 89 \note there might be empty classes, i.e., classes with zero 90 samples. This may happen when using 91 Target(const std::vector<std::string>& labels, const Target&) or 92 Target(const Target& org, const std::vector<size_t>& vec). 93 */ 91 94 const size_t nof_classes(void) const; 92 95 … … 157 160 158 161 private: 162 /// @brief Copy Constructor 163 // using compiler generated constructor 164 //Target(const Target& other); 165 159 166 // binary target for class i 160 167 std::vector<char> binary_; // avoid using vector<bool>
Note: See TracChangeset
for help on using the changeset viewer.