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/lemma.h | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 lib/lemma.h (limited to 'lib/lemma.h') diff --git a/lib/lemma.h b/lib/lemma.h new file mode 100644 index 0000000..9a07f16 --- /dev/null +++ b/lib/lemma.h @@ -0,0 +1,120 @@ +#ifndef LEMMA_H_0A180D30 +#define LEMMA_H_0A180D30 + +#include +#include +#include +#include +#include "field.h" +#include "enums.h" +#include "filter.h" + +struct sqlite3_stmt; + +namespace verbly { + + class form; + class database; + + class lemma { + public: + + // Default constructor + + lemma() = default; + + // Construct from database + + lemma(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 lemma"); + } + + return id_; + } + + const form& getBaseForm() const; + + bool hasInflection(inflection category) const; + + const std::vector
& getInflections(inflection category) const; + + // Type info + + static const object objectType; + + static const std::list select; + + // Query fields + + static const field id; + + operator filter() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized lemma"); + } + + return (id == id_); + } + + // Relationships to other objects + + static const field word; + + class inflection_field { + public: + + inflection_field(inflection category) : category_(category) + { + } + + const inflection getCategory() const + { + return category_; + } + + private: + + const inflection category_; + }; + + static const inflection_field form(inflection category) + { + return inflection_field(category); + } + + friend filter operator%=(lemma::inflection_field check, filter joinCondition); + + private: + + void initializeForm(inflection category) const; + + bool valid_ = false; + + int id_; + + mutable std::map> forms_; + + const database* db_; + + static const field formJoin; + static const field inflectionCategory; + + }; + +}; + +#endif /* end of include guard: LEMMA_H_0A180D30 */ -- cgit 1.4.1