1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! A data source used by BigML.
use std::collections::HashMap;
use super::Resource;
use super::id::*;
use super::status::*;
resource! {
api_name "source";
/// A data source used by BigML.
///
/// TODO: Still lots of missing fields.
#[derive(Debug, Deserialize, Clone)]
pub struct Source {
/// The status of this source.
pub status: GenericStatus,
/// The name of the file uploaded.
pub file_name: String,
/// An MD5 hash of the uploaded file.
pub md5: String,
/// The number of bytes of the source.
pub size: u64,
/// The fields in this source, keyed by BigML internal ID.
pub fields: Option<HashMap<String, Field>>,
}
}
/// Information about a field in a data source.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Field {
/// The name of this field.
pub name: String,
/// The type of data stored in this field.
pub optype: Optype,
// The locale of this field.
//pub locale: Option<String>,
// (This is not well-documented in the BigML API.)
//pub missing_tokens: Option<Vec<String>>,
}
/// The type of a data field.
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub enum Optype {
/// Treat this as a numeric value.
#[serde(rename="numeric")]
Numeric,
/// Threat this as a category with multiple possible values, but not
/// arbitrary strings.
#[serde(rename="categorical")]
Categorical,
/// Treat this as text. This uses different machine learning
/// algorithms than `Categorical`.
#[serde(rename="text")]
Text,
/// Treat this as a list of muliple items separated by an auto-detected
/// separator.
#[serde(rename="items")]
Items,
}