-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcli.rs
113 lines (97 loc) · 2.63 KB
/
cli.rs
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use std::path::PathBuf;
use clap::StructOpt;
use crate::split::{ProportionSplit, RowSplit};
#[derive(Debug, StructOpt)]
#[clap(
name = "ttv",
about = "Flexibly create test, train and validation sets"
)]
pub struct Opt {
#[clap(
parse(from_occurrences),
short = 'v',
help = "Set the level of verbosity"
)]
pub verbose: u64,
#[clap(subcommand)]
pub cmd: Command,
}
#[derive(Debug, StructOpt)]
pub enum Command {
#[clap(
name = "split",
about = "Split dataset into two or more files for test/train/validation sets"
)]
Split(Split),
}
#[derive(Debug, StructOpt)]
pub struct Split {
#[clap(
short = 'r',
long = "rows",
required_unless_present = "prop",
conflicts_with = "prop",
help = "Specify splits by number of rows",
use_value_delimiter = true
)]
pub rows: Vec<RowSplit>,
#[clap(
short = 'p',
long = "prop",
required_unless_present = "rows",
conflicts_with = "rows",
help = "Specify splits by proportion of rows",
use_value_delimiter = true
)]
pub prop: Vec<ProportionSplit>,
#[clap(
short = 'n',
long = "no-header",
help = "Don't treat the first row as a header"
)]
pub no_header: bool,
#[clap(
short = 'c',
long = "chunk-size",
help = "Maximum number of rows per output chunk"
)]
pub chunk_size: Option<u64>,
#[clap(
short = 't',
long = "total-rows",
help = "Number of rows in input file. Used for progress when using proportion splits"
)]
pub total_rows: Option<u64>,
#[clap(short = 's', long = "seed", help = "RNG seed, for reproducibility")]
pub seed: Option<u64>,
#[clap(
long = "csv",
help = "Parse input as CSV. Only needed if rows contain embedded newlines - will impact performance."
)]
pub csv: bool,
#[clap(
parse(from_os_str),
help = "Data to split, optionally gzip compressed. If '-', read from stdin"
)]
pub input: PathBuf,
#[clap(
short = 'o',
long = "output-prefix",
parse(from_os_str),
required_if_eq("input", "-"),
help = "Output filename prefix. Only used if reading from stdin"
)]
pub output_prefix: Option<PathBuf>,
#[clap(
short = 'd',
long = "decompress-input",
help = "Decompress input from gzip format"
)]
pub decompress_input: bool,
#[clap(
short = 'C',
long = "compressed-output",
help = "Compress output files using gzip"
)]
pub compress_output: bool,
}