-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpadeArguments.cc
72 lines (63 loc) · 2.02 KB
/
SpadeArguments.cc
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
//
// Created by Yukio Fukuzawa on 8/12/18.
//
#include "SpadeArguments.h"
void SpadeArguments::parse_args(int argc, char **argv) {
string name;
auto cmdl = argh::parser(argc, argv, argh::parser::PREFER_PARAM_FOR_UNREG_OPTION);
cmdl("i") >> name;
if (name.empty() || !cmdl("s")) {
cerr << "usage: usage: spade [OPTION]... -i<infile> -s<support>\n";
throw runtime_error("spade needs valid value of -i and -s");
}
cmdl("s") >> min_support_per_class;
cmdl("a") >> use_ascending;
cmdl("c") >> use_class;
if (cmdl("e")) {
ext_l2_pass = 1;
cmdl("e") >> num_partitions;
}
if (cmdl["h"]) use_hash = 1;
if (cmdl["o"]) outputfreq = 1;
if (cmdl["r"]) recursive = 1;
cmdl("l") >> min_gap;
if (cmdl("u")) {
use_maxgap = 1;
use_hash = 0;
cmdl("u") >> max_gap;
}
cmdl("t") >> pruning_type;
cmdl("v") >> min_support;
if (cmdl("w") || cmdl["w"]) {
if (!cmdl("u")) {
cerr << "-u is required when -w is enabled" << endl;
throw runtime_error("-u is required when -w is enabled");
}
use_window = 1;
}
cmdl("y") >> print_tidlist;
cmdl("z") >> max_seq_len;
cmdl("Z") >> max_iset_len;
dataf = name + ".tpose";
idxf = name + ".idx";
conf = name + ".conf";
it2f = name + ".2it";
seqf = name + ".2seq";
classf = name + ".class";
ifstream conff(conf, ios::binary);
if (!conff.is_open()) {
throw runtime_error("File " + string(conf) + " doesn\'t exist.");
}
conff.read((char *) &total_trans_count, INT_SIZE);
if (min_support == -1)
min_support = (int) ceil(min_support_per_class * total_trans_count);
//ensure that support is at least 2
if (min_support < 1) {
min_support = 1;
}
conff.read((char *) &dbase_max_item, INT_SIZE);
conff.read((char *) &avg_cust_size, FLOAT_SIZE);
conff.read((char *) &avg_trans_count, FLOAT_SIZE);
conff.read((char *) &dbase_total_trans, INT_SIZE);
conff.close();
}