feat: read data from arff files #1
@ -81,6 +81,31 @@ namespace ARFF {
|
|||||||
TestIntegrity();
|
TestIntegrity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Arff::Print(void) {
|
||||||
|
std::cout << attributeList.size() << " attributes\n";
|
||||||
|
std::cout << database.size() << " examples\n";
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
std::cout << "Attribute (#): values\n";
|
||||||
|
for (AttributeType type : attributeList) {
|
||||||
|
std::cout << type.attribute << " (" << type.values.size() << "):";
|
||||||
|
for (std::string value : type.values) {
|
||||||
|
std::cout << " " << value;
|
||||||
|
}
|
||||||
|
std::cout << '\n';
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
std::cout << relation << '\n';
|
||||||
|
for (Instance instance: database) {
|
||||||
|
for (std::string value : instance.values) {
|
||||||
|
std::cout << '\t' << value;
|
||||||
|
}
|
||||||
|
std::cout << '\n';
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Add the attribute to the list
|
// Add the attribute to the list
|
||||||
void Arff::AddAttribute(std::string line) {
|
void Arff::AddAttribute(std::string line) {
|
||||||
std::stringstream parser(line);
|
std::stringstream parser(line);
|
||||||
|
@ -29,6 +29,7 @@ namespace ARFF {
|
|||||||
public:
|
public:
|
||||||
Arff() = default;
|
Arff() = default;
|
||||||
void Read(std::string filename);
|
void Read(std::string filename);
|
||||||
|
void Print(void);
|
||||||
private:
|
private:
|
||||||
std::string relation;
|
std::string relation;
|
||||||
std::vector<AttributeType> attributeList;
|
std::vector<AttributeType> attributeList;
|
||||||
|
@ -9,4 +9,5 @@ int main(int argc, char* argv[]) {
|
|||||||
ARFF::ParseArguments(argc, argv);
|
ARFF::ParseArguments(argc, argv);
|
||||||
ARFF::Arff data;
|
ARFF::Arff data;
|
||||||
data.Read(ARFF::GetDataFilename());
|
data.Read(ARFF::GetDataFilename());
|
||||||
|
data.Print();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user