More style changes

This commit is contained in:
heisenbuug
2021-10-26 12:58:47 +05:30
parent 73d37db0a0
commit cc918557ec
5 changed files with 26 additions and 26 deletions
+1 -1
View File
@@ -211,7 +211,7 @@ FileType AutoDetect(std::fstream& stream, const std::string& filename)
const std::streampos pos = stream.tellg();
std::string line;
std::getline(stream, line, '\n');
trim(line);
Trim(line);
// Reset stream position.
stream.seekg(pos);
+6 -6
View File
@@ -46,7 +46,7 @@ void LoadARFF(const std::string& filename,
{
// Read the next line, then strip whitespace from either side.
std::getline(ifs, line, '\n');
trim(line);
Trim(line);
++headerLines;
// Is the first character a comment, or is the line empty?
@@ -102,7 +102,7 @@ void LoadARFF(const std::string& filename,
// `origDimType` string here instead (which has not had ::tolower used
// on it).
types.push_back(true);
trim_if(origDimType,
TrimIf(origDimType,
[](char c)
{
return c == '{' || c == '}' || c == ' ' || c == '\t';
@@ -116,7 +116,7 @@ void LoadARFF(const std::string& filename,
while (it != dimTok.end())
{
std::string category = (*it);
trim(category);
Trim(category);
categories.push_back(category);
++it;
@@ -198,7 +198,7 @@ void LoadARFF(const std::string& filename,
while (ifs.good())
{
std::getline(ifs, line, '\n');
trim(line);
Trim(line);
// Each line of the @data section must be a CSV (except sparse data, which
// we will handle later). So now we can tokenize the
// CSV and parse it. The '?' representing a missing value is not allowed,
@@ -232,7 +232,7 @@ void LoadARFF(const std::string& filename,
{
// Strip spaces before mapping.
std::string token = *it;
trim(token);
Trim(token);
const size_t currentNumMappings = info.NumMappings(col);
const eT result = info.template MapString<eT>(token, col);
@@ -272,7 +272,7 @@ void LoadARFF(const std::string& filename,
// error, otherwise we issue a general error.
std::stringstream error;
std::string tokenStr = token.str();
trim(tokenStr);
Trim(tokenStr);
if (tokenStr == "?")
error << "Missing values ('?') not supported, ";
else
@@ -88,7 +88,7 @@ void LoadCSV::InitializeTransposeMapper(size_t& rows, size_t& cols,
std::getline(inFile, line);
// Remove whitespaces from either side
trim(line);
Trim(line);
// If it's an empty line decrease cols and break
if (line.size() == 0)
@@ -112,7 +112,7 @@ void LoadCSV::InitializeTransposeMapper(size_t& rows, size_t& cols,
{
std::getline(lineStream, token, delim);
// Remove whitespace from either side
trim(token);
Trim(token);
if (token[0] == '"' && token[token.size() - 1] != '"')
{
@@ -173,7 +173,7 @@ void LoadCSV::InitializeMapper(size_t& rows, size_t& cols, DatasetMapper<MapPoli
{
++rows;
// Remove whitespaces from either side
trim(line);
Trim(line);
if (rows == 1)
{
// Extract the number of columns.
@@ -196,7 +196,7 @@ void LoadCSV::InitializeMapper(size_t& rows, size_t& cols, DatasetMapper<MapPoli
{
std::getline(lineStream, token, delim);
// Remove whitespace from either side
trim(token);
Trim(token);
if (token[0] == '"' && token[token.size() - 1] != '"')
{
@@ -235,7 +235,7 @@ void LoadCSV::TransposeParse(arma::Mat<T>& inout, DatasetMapper<PolicyType>& inf
while (std::getline(inFile, line))
{
// Remove whitespaces from either side
trim(line);
Trim(line);
// Reset the row we are looking at. (Remember this is transposed.)
row = 0;
std::stringstream lineStream;
@@ -247,7 +247,7 @@ void LoadCSV::TransposeParse(arma::Mat<T>& inout, DatasetMapper<PolicyType>& inf
{
std::getline(lineStream, token, delim);
// Remove whitespaces from either side
trim(token);
Trim(token);
if (token[0] == '"' && token[token.size() - 1] != '"')
{
@@ -299,7 +299,7 @@ void LoadCSV::NonTransposeParse(arma::Mat<T>& inout,
while (std::getline(inFile, line))
{
// Remove whitespaces from either side
trim(line);
Trim(line);
std::stringstream lineStream;
std::string token;
@@ -314,7 +314,7 @@ void LoadCSV::NonTransposeParse(arma::Mat<T>& inout,
std::getline(lineStream, token, delim);
// Remove whitespace from either side
trim(token);
Trim(token);
if (token[0] == '"' && token[token.size() - 1] != '"')
{
+10 -10
View File
@@ -77,9 +77,9 @@ class LoadCSV
* @param file path of the dataset.
*/
LoadCSV(const std::string& file) :
extension(Extension(file)),
filename(file),
inFile(file)
extension(Extension(file)),
filename(file),
inFile(file)
{
if (extension == "csv")
{
@@ -208,7 +208,7 @@ class LoadCSV
inline std::pair<size_t, size_t> GetMatrixSize(std::fstream& f,
const char delim = ',')
{
bool load_okay = f.good();
bool loadOkay = f.good();
f.clear();
const std::fstream::pos_type pos1 = f.tellg();
@@ -219,7 +219,7 @@ class LoadCSV
std::stringstream lineStream;
std::string token;
while (f.good() && load_okay)
while (f.good() && loadOkay)
{
// Get a row of data.
std::getline(f, lineString);
@@ -228,20 +228,20 @@ class LoadCSV
lineStream.clear();
lineStream.str(lineString);
size_t line_n_cols = 0;
size_t lineNCols = 0;
// Get number of columns based on the type of data.
if (isNumeric)
NumericMatSize(lineStream, line_n_cols, delim);
NumericMatSize(lineStream, lineNCols, delim);
else
CategoricalMatSize(lineStream, line_n_cols, delim);
CategoricalMatSize(lineStream, lineNCols, delim);
// If there are different number of columns in each
// row, then the highest number of cols will be
// considered as the size of the matrix. Missing
// elements will be filled as 0.
if (fnCols < line_n_cols)
fnCols = line_n_cols;
if (fnCols < lineNCols)
fnCols = lineNCols;
++fnRows;
}
+1 -1
View File
@@ -39,7 +39,7 @@ std::vector<std::string> ToTokens(Tokenizer& lineTok)
[&tokens](std::string const &str)
{
std::string trimmedToken(str);
trim(trimmedToken);
Trim(trimmedToken);
return std::move(trimmedToken);
});