From f1f67e62cebb4144f0599196263cd93b41fa972e Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 6 Feb 2017 20:58:37 -0500 Subject: Made pronunciation::rhymes join dynamic This involved adding a new type of filter; one that compares (currently only equality and inequality) a field with another field located in an enclosing join context. In the process, it was discovered that simplifying the lemma::forms join field earlier actually made some queries return inaccurate results because the inflection of the form was being ignored and anything in the lemma would be used because of the inner join. Because the existing condition join did not allow for the condition field to be on the from side of the join, two things were done: a condition version of joinThrough was made, and lemma was finally eliminated as a top-level object, replaced instead with a condition join between word and form through lemmas_forms. Queries are also now grouped by the first select field (assumed to be the primary ID) of the top table, in order to eliminate duplicates created by inner joins, so that there is a uniform distribution between results for random queries. Created a database index on pronunciations(rhyme) which decreases query time for rhyming filters. The new database version is backwards-compatible because no data or structure changed. --- lib/lemma.h | 97 ------------------------------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 lib/lemma.h (limited to 'lib/lemma.h') diff --git a/lib/lemma.h b/lib/lemma.h deleted file mode 100644 index bba5572..0000000 --- a/lib/lemma.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef LEMMA_H_0A180D30 -#define LEMMA_H_0A180D30 - -#include -#include -#include -#include -#include "field.h" -#include "form.h" -#include "enums.h" -#include "filter.h" - -struct sqlite3_stmt; - -namespace verbly { - - 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 words; - - static field forms(inflection category); - - private: - - void initializeForm(inflection category) const; - - bool valid_ = false; - - int id_; - - mutable std::map> forms_; - - const database* db_; - - static const field inflectionCategory; - - }; - -}; - -#endif /* end of include guard: LEMMA_H_0A180D30 */ -- cgit 1.4.1