Example #1
0
std::shared_ptr<dataset> generic_sample_factory::create_sample(const std::string & path_sample) {
    std::shared_ptr<dataset> sample_data(new dataset);
    size_t sample_dimension = 0;

    std::ifstream file_sample(path_sample);
    if (file_sample.is_open()) {
        std::string file_line;

        while(std::getline(file_sample, file_line)) {
            if (file_line.empty())
                continue;

            double value = 0.0;
            point sample_point;

            std::istringstream stream_value(file_line);

            while(stream_value >> value) {
                sample_point.push_back(value);
            }

            if (sample_dimension == 0) {
                sample_dimension = sample_point.size();
            }
            else {
                if (sample_dimension != sample_point.size()) {
                    throw std::runtime_error("Points from input data set should have the same dimension.");
                }
            }

            sample_data->push_back(sample_point);
        }
    }
Example #2
0
long nnet::XmlFile::ReadLong( xmlNodePtr node, std::string name ) {
	long value;
	std::string value_string = GetString( node, name );
	std::istringstream stream_value( value_string );
	stream_value >> value;
	return value;
}