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/form.h | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 lib/form.h (limited to 'lib/form.h') diff --git a/lib/form.h b/lib/form.h new file mode 100644 index 0000000..c6a1353 --- /dev/null +++ b/lib/form.h @@ -0,0 +1,149 @@ +#ifndef FORM_H_3A6C962C +#define FORM_H_3A6C962C + +#include +#include +#include +#include +#include "field.h" +#include "filter.h" + +struct sqlite3_stmt; + +namespace verbly { + + class pronunciation; + class database; + + class form { + public: + + // Default constructor + + form() = default; + + // Construct from database + + form(const database& db, sqlite3_stmt* row); + + // Accessors + + operator bool() const + { + return valid_; + } + + int getId() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized form"); + } + + return id_; + } + + std::string getText() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized form"); + } + + return text_; + } + + int getComplexity() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized form"); + } + + return complexity_; + } + + bool isProper() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized form"); + } + + return proper_; + } + + const std::vector& getPronunciations() const; + + // Type info + + static const object objectType; + + static const std::list select; + + // Query fields + + static const field id; + static const field text; + static const field complexity; + static const field proper; + + operator filter() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized form"); + } + + return (id == id_); + } + + // Relationships to other objects + + static const field pronunciation; + + class inflection_field { + public: + + inflection_field(inflection category) : category_(category) + { + } + + const inflection getCategory() const + { + return category_; + } + + private: + + const inflection category_; + }; + + static const inflection_field lemma(inflection category) + { + return inflection_field(category); + } + + friend filter operator%=(form::inflection_field check, filter joinCondition); + + private: + bool valid_ = false; + + int id_; + std::string text_; + int complexity_ ; + bool proper_; + + const database* db_; + + mutable bool initializedPronunciations_ = false; + mutable std::vector pronunciations_; + + static const field lemmaJoin; + static const field inflectionCategory; + + }; + +}; + +#endif /* end of include guard: FORM_H_3A6C962C */ -- cgit 1.4.1