let parts: Vec<String> = line.split_whitespace().collect();
let parts: Vec<String> = map(AsRef::as_ref).line.split_whitespace().collect();
if parts.len() >= 3 {
let attribute_name = parts[1].to_string();
let attribute_type = parts[2].to_lowercase();
let attribute = match attribute_type.as_str() {
"numeric" => Attribute::Numeric,
"date" => Attribute::Date(parts.get(3).cloned()),
"string" => Attribute::String,
"nominal" => {
let nominal_values: Vec<String> = parts[3..]
.iter()
.map(|s| s.trim_matches(|c| c == '{' || c == '}' || c == ',').to_string())
.collect();
Attribute::Nominal(nominal_values)
}
My goal is to implement an algorithm in Rust for loading and reading .arff files. It reads an .arff file, extract information from header, attributes and instances, then prints it on the output. Each attribute is represented as a pair (name, type) in array attributes, and instances are stored as arrays of attribute values in array instances.
You would need to map the values of the vector. Something like this:
let parts: Vec<String> = line.split_whitespace().map(|v| v.to_string()).collect();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With