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 /lib/util.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 'lib/util.h')
-rw-r--r-- | lib/util.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/util.h b/lib/util.h index fb5fe67..b74b050 100644 --- a/lib/util.h +++ b/lib/util.h | |||
@@ -1,6 +1,10 @@ | |||
1 | #ifndef UTIL_H_15DDCA2D | 1 | #ifndef UTIL_H_15DDCA2D |
2 | #define UTIL_H_15DDCA2D | 2 | #define UTIL_H_15DDCA2D |
3 | 3 | ||
4 | #include <string> | ||
5 | #include <sstream> | ||
6 | #include <iterator> | ||
7 | |||
4 | namespace verbly { | 8 | namespace verbly { |
5 | 9 | ||
6 | template <class InputIterator> | 10 | template <class InputIterator> |
@@ -21,25 +25,33 @@ namespace verbly { | |||
21 | return result.str(); | 25 | return result.str(); |
22 | } | 26 | } |
23 | 27 | ||
24 | template <class Container> | 28 | template <class OutputIterator> |
25 | Container split(std::string input, std::string delimiter) | 29 | void split(std::string input, std::string delimiter, OutputIterator out) |
26 | { | 30 | { |
27 | Container result; | ||
28 | |||
29 | while (!input.empty()) | 31 | while (!input.empty()) |
30 | { | 32 | { |
31 | int divider = input.find(delimiter); | 33 | int divider = input.find(delimiter); |
32 | if (divider == std::string::npos) | 34 | if (divider == std::string::npos) |
33 | { | 35 | { |
34 | result.push_back(input); | 36 | *out = input; |
37 | out++; | ||
35 | 38 | ||
36 | input = ""; | 39 | input = ""; |
37 | } else { | 40 | } else { |
38 | result.push_back(input.substr(0, divider)); | 41 | *out = input.substr(0, divider); |
42 | out++; | ||
39 | 43 | ||
40 | input = input.substr(divider+delimiter.length()); | 44 | input = input.substr(divider+delimiter.length()); |
41 | } | 45 | } |
42 | } | 46 | } |
47 | } | ||
48 | |||
49 | template <class Container> | ||
50 | Container split(std::string input, std::string delimiter) | ||
51 | { | ||
52 | Container result; | ||
53 | |||
54 | split(input, delimiter, std::back_inserter(result)); | ||
43 | 55 | ||
44 | return result; | 56 | return result; |
45 | } | 57 | } |