From 6746da6edd7d9d50efe374eabbb79a3cac882d81 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 16 Jan 2017 18:02:50 -0500 Subject: 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. --- lib/preposition.cpp | 107 ---------------------------------------------------- 1 file changed, 107 deletions(-) delete mode 100644 lib/preposition.cpp (limited to 'lib/preposition.cpp') diff --git a/lib/preposition.cpp b/lib/preposition.cpp deleted file mode 100644 index cea9165..0000000 --- a/lib/preposition.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "verbly.h" - -namespace verbly { - - std::string preposition::get_form() const - { - return form; - } - - preposition_query::preposition_query(const data& _data) : _data(_data) - { - - } - - preposition_query& preposition_query::limit(int _limit) - { - this->_limit = _limit; - - return *this; - } - - preposition_query& preposition_query::random() - { - _random = true; - - return *this; - } - - preposition_query& preposition_query::in_group(std::string _arg) - { - _in_group.push_back(_arg); - - return *this; - } - - std::list preposition_query::run() const - { - std::stringstream construct; - construct << "SELECT form FROM prepositions"; - std::list bindings; - - if (!_in_group.empty()) - { - std::list clauses(_in_group.size(), "groupname = ?"); - construct << " WHERE preposition_id IN (SELECT preposition_id FROM preposition_groups WHERE "; - construct << verbly::implode(std::begin(clauses), std::end(clauses), " OR "); - construct << ")"; - - for (auto g : _in_group) - { - bindings.emplace_back(g); - } - } - - if (_random) - { - construct << " ORDER BY RANDOM()"; - } - - if (_limit != unlimited) - { - construct << " LIMIT " << _limit; - } - - sqlite3_stmt* ppstmt; - std::string query = construct.str(); - if (sqlite3_prepare_v2(_data.ppdb, query.c_str(), query.length(), &ppstmt, NULL) != SQLITE_OK) - { - throw std::runtime_error(sqlite3_errmsg(_data.ppdb)); - } - - int i = 1; - for (auto& binding : bindings) - { - switch (binding.get_type()) - { - case binding::type::integer: - { - sqlite3_bind_int(ppstmt, i, binding.get_integer()); - - break; - } - - case binding::type::string: - { - sqlite3_bind_text(ppstmt, i, binding.get_string().c_str(), binding.get_string().length(), SQLITE_TRANSIENT); - - break; - } - } - - i++; - } - - std::list output; - while (sqlite3_step(ppstmt) == SQLITE_ROW) - { - preposition pp; - pp.form = std::string(reinterpret_cast(sqlite3_column_text(ppstmt, 0))); - - output.push_back(pp); - } - - return output; - } - -}; -- cgit 1.4.1