shorten dataset name to maximum length
This commit is contained in:
@@ -413,7 +413,7 @@ namespace platform {
|
|||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if (output_type == OutputType::DATASETS) {
|
if (output_type == OutputType::DATASETS) {
|
||||||
list_datasets(STATUS_OK, STATUS_COLOR);
|
list(STATUS_OK, STATUS_COLOR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (indexList) {
|
if (indexList) {
|
||||||
|
@@ -5,14 +5,14 @@
|
|||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
const int DatasetsConsole::BALANCE_LENGTH = 75;
|
const int DatasetsConsole::BALANCE_LENGTH = 75;
|
||||||
void DatasetsConsole::split_lines(std::string line, const std::string& balance)
|
void DatasetsConsole::split_lines(int name_len, std::string line, const std::string& balance)
|
||||||
{
|
{
|
||||||
auto temp = std::string(balance);
|
auto temp = std::string(balance);
|
||||||
while (temp.size() > DatasetsConsole::BALANCE_LENGTH - 1) {
|
while (temp.size() > DatasetsConsole::BALANCE_LENGTH - 1) {
|
||||||
auto part = temp.substr(0, DatasetsConsole::BALANCE_LENGTH);
|
auto part = temp.substr(0, DatasetsConsole::BALANCE_LENGTH);
|
||||||
line += part + "\n";
|
line += part + "\n";
|
||||||
body.push_back(line);
|
body.push_back(line);
|
||||||
line = string(52, ' ');
|
line = string(name_len + 22, ' ');
|
||||||
temp = temp.substr(DatasetsConsole::BALANCE_LENGTH);
|
temp = temp.substr(DatasetsConsole::BALANCE_LENGTH);
|
||||||
}
|
}
|
||||||
line += temp + "\n";
|
line += temp + "\n";
|
||||||
@@ -36,10 +36,12 @@ namespace platform {
|
|||||||
header.clear();
|
header.clear();
|
||||||
body.clear();
|
body.clear();
|
||||||
auto datasets = platform::Datasets(false, platform::Paths::datasets());
|
auto datasets = platform::Datasets(false, platform::Paths::datasets());
|
||||||
auto loc = std::locale("es_ES");
|
auto loc = std::locale("es_ES.UTF-8");
|
||||||
std::stringstream sheader;
|
std::stringstream sheader;
|
||||||
|
auto datasets_names = datasets.getNames();
|
||||||
|
int maxName = std::max(size_t(7), (*max_element(datasets_names.begin(), datasets_names.end(), [](const std::string& a, const std::string& b) { return a.size() < b.size(); })).size());
|
||||||
std::vector<std::string> header_labels = { " #", "Dataset", "Sampl.", "Feat.", "Cls", "Balance" };
|
std::vector<std::string> header_labels = { " #", "Dataset", "Sampl.", "Feat.", "Cls", "Balance" };
|
||||||
std::vector<int> header_lengths = { 3, 30, 6, 5, 3, DatasetsConsole::BALANCE_LENGTH };
|
std::vector<int> header_lengths = { 3, maxName, 6, 5, 3, DatasetsConsole::BALANCE_LENGTH };
|
||||||
sheader << Colors::GREEN();
|
sheader << Colors::GREEN();
|
||||||
for (int i = 0; i < header_labels.size(); i++) {
|
for (int i = 0; i < header_labels.size(); i++) {
|
||||||
sheader << setw(header_lengths[i]) << left << header_labels[i] << " ";
|
sheader << setw(header_lengths[i]) << left << header_labels[i] << " ";
|
||||||
@@ -58,7 +60,7 @@ namespace platform {
|
|||||||
line.imbue(loc);
|
line.imbue(loc);
|
||||||
auto color = num % 2 ? Colors::CYAN() : Colors::BLUE();
|
auto color = num % 2 ? Colors::CYAN() : Colors::BLUE();
|
||||||
line << color << setw(3) << right << num++ << " ";
|
line << color << setw(3) << right << num++ << " ";
|
||||||
line << setw(30) << left << dataset << " ";
|
line << setw(maxName) << left << dataset << " ";
|
||||||
datasets.loadDataset(dataset);
|
datasets.loadDataset(dataset);
|
||||||
auto nSamples = datasets.getNSamples(dataset);
|
auto nSamples = datasets.getNSamples(dataset);
|
||||||
line << setw(6) << right << nSamples << " ";
|
line << setw(6) << right << nSamples << " ";
|
||||||
@@ -71,7 +73,7 @@ namespace platform {
|
|||||||
oss << sep << std::setprecision(2) << fixed << (float)number / nSamples * 100.0 << "% (" << number << ")";
|
oss << sep << std::setprecision(2) << fixed << (float)number / nSamples * 100.0 << "% (" << number << ")";
|
||||||
sep = " / ";
|
sep = " / ";
|
||||||
}
|
}
|
||||||
split_lines(line.str(), oss.str());
|
split_lines(maxName, line.str(), oss.str());
|
||||||
// Store data for Excel report
|
// Store data for Excel report
|
||||||
data[dataset] = json::object();
|
data[dataset] = json::object();
|
||||||
data[dataset]["samples"] = nSamples;
|
data[dataset]["samples"] = nSamples;
|
||||||
|
@@ -20,7 +20,7 @@ namespace platform {
|
|||||||
json& getData() { return data; }
|
json& getData() { return data; }
|
||||||
void report();
|
void report();
|
||||||
private:
|
private:
|
||||||
void split_lines(std::string line, const std::string& balance);
|
void split_lines(int name_len, std::string line, const std::string& balance);
|
||||||
std::vector<std::string> header, body;
|
std::vector<std::string> header, body;
|
||||||
json data;
|
json data;
|
||||||
};
|
};
|
||||||
|
@@ -91,7 +91,7 @@ namespace platform {
|
|||||||
totalScore += r["score"].get<double>();
|
totalScore += r["score"].get<double>();
|
||||||
}
|
}
|
||||||
if (data["results"].size() == 1 || selectedIndex != -1) {
|
if (data["results"].size() == 1 || selectedIndex != -1) {
|
||||||
sbody << std::string(MAXL, '*') << std::endl;
|
sbody << Colors::MAGENTA() << std::string(MAXL, '*') << std::endl;
|
||||||
if (lastResult.find("notes") != lastResult.end()) {
|
if (lastResult.find("notes") != lastResult.end()) {
|
||||||
if (lastResult["notes"].size() > 0) {
|
if (lastResult["notes"].size() > 0) {
|
||||||
sbody << headerLine("Notes: ");
|
sbody << headerLine("Notes: ");
|
||||||
|
Reference in New Issue
Block a user