-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstruct_main.cpp
More file actions
85 lines (71 loc) · 2.17 KB
/
Copy pathconstruct_main.cpp
File metadata and controls
85 lines (71 loc) · 2.17 KB
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
/*
* Copyright (c) 2018 Takaaki Nishimoto
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published bytes
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <iostream>
#include <string>
#include <memory>
#include <tst_tree.hpp>
#include <tst_test.hpp>
#include <io_functions.h>
#include <bitset>
#include <cassert>
#include "cmdline.h"
#include "src/common1/my_vector.h"
//#include "qgram_tree.h"
using namespace std;
using namespace my;
int main(int argc, char *argv[])
{
cmdline::parser p;
p.add<string>("input_file", 'i', "input file name", true);
p.add<string>("output_file", 'o', "output file name", true);
p.add<int>("qgram", 'q', "qgram length", true);
p.add<int>("count", 'a', "append count vector?", false, 1);
p.parse_check(argc, argv);
string file = p.get<string>("input_file");
string output_file = p.get<string>("output_file");
int32_t qgram = p.get<int>("qgram");
int32_t count = p.get<int>("count");
//create tst
string text = "";
ifstream inputStream;
inputStream.open(file);
if (!inputStream)
{
std::cout << "No Input File!" << std::endl;
return 1;
}
ofstream os;
os.open(output_file);
my::IO::load(inputStream, text);
inputStream.close();
//tst::istring itext(text);
tst::istring itext;
my::createFromString(text, itext);
tst::TST tree;
tree.construct(itext, qgram);
if (count >= 1)
{
vector<uint64_t> vec;
tree.translatePattern(itext, vec, true);
tree.constructCountVec(vec, count == 2);
}
tree.printInfo();
tree.save(os);
os.close();
std::cout << "Finish." << std::endl;
}