#include <iostream> #include <vector> #include <cstddef> #include <string> #include <sstream> #include <fstream> #include <algorithm> #include <cmath> #include <set> #include <limits> #include <functional> #include <numeric> template <class DataType> void ReadMatFromFile(std::string &filename, std::vector<std::vector<DataType> > &lines_feat) { std::ifstream vm_info(filename.c_str()); std::string lines; DataType var; std::vector<DataType> row; lines_feat.clear(); while(!vm_info.eof()) { getline(vm_info, lines); if(lines.empty()) break; std::stringstream stringin(lines); row.clear(); while(stringin >> var) { row.push_back(var); } lines_feat.push_back(row); } } void ReadStringFromFile(std::string &filename, std::vector<std::string> &in_string) { std::ifstream vm_info(filename.c_str()); std::string lines, var; while(!vm_info.eof()) { getline(vm_info, lines); if(lines.empty()) break; std::stringstream stringin(lines); while(stringin >> var) { in_string.push_back(var); } } } std::string lowerCase(const std::string& s) { std::string lower(s); for(size_t i=0;i<s.length();++i) { lower[i]=tolower(lower[i]); } return lower; } std::string letters(const std::string& s) { std::string letter; for(size_t i=0;i<s.length();++i) { char ch=s.at(i); bool flag=false; if((ch>=65 && ch<=90)) { ch=ch+32; flag=true; } else if((ch>=97 && ch<=122) || (ch>=48 && ch<=57)) { flag=true; } else { ; } if(flag) { letter.push_back(ch); } } letter.push_back('