diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-01-16 18:02:50 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-01-16 18:02:50 -0500 |
commit | 6746da6edd7d9d50efe374eabbb79a3cac882d81 (patch) | |
tree | ff20917e08b08d36b9541c1371106596e7bec442 /generator/progress.h | |
parent | 4af7e55733098ca42f75a4ffaca1b0f6bab4dd36 (diff) | |
download | verbly-6746da6edd7d9d50efe374eabbb79a3cac882d81.tar.gz verbly-6746da6edd7d9d50efe374eabbb79a3cac882d81.tar.bz2 verbly-6746da6edd7d9d50efe374eabbb79a3cac882d81.zip |
Started structural rewrite
The new object structure was designed to build on the existing WordNet structure, while also adding in all of the data that we get from other sources. More information about this can be found on the project wiki. The generator has already been completely rewritten to generate a datafile that uses the new structure. In addition, a number of indexes are created, which does double the size of the datafile, but also allows for much faster lookups. Finally, the new generator is written modularly and is a lot more readable than the old one. The verbly interface to the new object structure has mostly been completed, but has not been tested fully. There is a completely new search API which utilizes a lot of operator overloading; documentation on how to use it should go up at some point. Token processing and verb frames are currently unimplemented. Source for these have been left in the repository for now.
Diffstat (limited to 'generator/progress.h')
-rw-r--r-- | generator/progress.h | 78 |
1 files changed, 42 insertions, 36 deletions
diff --git a/generator/progress.h b/generator/progress.h index 81f07a3..fcb680d 100644 --- a/generator/progress.h +++ b/generator/progress.h | |||
@@ -3,48 +3,54 @@ | |||
3 | 3 | ||
4 | #include <string> | 4 | #include <string> |
5 | 5 | ||
6 | class progress { | 6 | namespace verbly { |
7 | private: | 7 | namespace generator { |
8 | std::string message; | ||
9 | int total; | ||
10 | int cur = 0; | ||
11 | int lprint = 0; | ||
12 | 8 | ||
13 | public: | 9 | class progress { |
14 | progress(std::string message, int total) : message(message), total(total) | 10 | private: |
15 | { | 11 | std::string message; |
16 | std::cout << message << " 0%" << std::flush; | 12 | int total; |
17 | } | 13 | int cur = 0; |
14 | int lprint = 0; | ||
18 | 15 | ||
19 | void update(int val) | 16 | public: |
20 | { | 17 | progress(std::string message, int total) : message(message), total(total) |
21 | if (val <= total) | 18 | { |
22 | { | 19 | std::cout << message << " 0%" << std::flush; |
23 | cur = val; | 20 | } |
24 | } else { | 21 | |
25 | cur = total; | 22 | void update(int val) |
26 | } | 23 | { |
24 | if (val <= total) | ||
25 | { | ||
26 | cur = val; | ||
27 | } else { | ||
28 | cur = total; | ||
29 | } | ||
27 | 30 | ||
28 | int pp = cur * 100 / total; | 31 | int pp = cur * 100 / total; |
29 | if (pp != lprint) | 32 | if (pp != lprint) |
30 | { | 33 | { |
31 | lprint = pp; | 34 | lprint = pp; |
32 | 35 | ||
33 | std::cout << "\b\b\b\b" << std::right; | 36 | std::cout << "\b\b\b\b" << std::right; |
34 | std::cout.width(3); | 37 | std::cout.width(3); |
35 | std::cout << pp << "%" << std::flush; | 38 | std::cout << pp << "%" << std::flush; |
36 | } | 39 | } |
37 | } | 40 | } |
41 | |||
42 | void update() | ||
43 | { | ||
44 | update(cur+1); | ||
45 | } | ||
38 | 46 | ||
39 | void update() | 47 | ~progress() |
40 | { | 48 | { |
41 | update(cur+1); | 49 | std::cout << "\b\b\b\b100%" << std::endl; |
42 | } | 50 | } |
51 | }; | ||
43 | 52 | ||
44 | ~progress() | 53 | }; |
45 | { | ||
46 | std::cout << "\b\b\b\b100%" << std::endl; | ||
47 | } | ||
48 | }; | 54 | }; |
49 | 55 | ||
50 | #endif /* end of include guard: PROGRESS_H_A34EF856 */ | 56 | #endif /* end of include guard: PROGRESS_H_A34EF856 */ |