From a7645346293ed6a912c26d0c50b6f7943f1f3072 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 28 Jan 2017 12:59:42 -0500 Subject: Restructured verb frame schema to be more queryable Groups are much less significant now, and they no longer have a database table, nor are they considered a top level object anymore. Instead of containing their own role data, that data is folded into the frames so that it's easier to query; as a result, each group has its own copy of the frames that it contains. Additionally, parts are considered top level objects now, and you can query for frames based on attributes of their indexed parts. Synrestrs are also contained in their own table now, so that parts can be filtered against their synrestrs; they are however not considered top level objects. Created a new type of field, the "join where" or "condition join" field, which is a normal join field that has a built in condition on a specified field. This is used to allow creating multiple distinct join fields from one object to another. This is required for the lemma::form and frame::part joins, because filters for forms of separate inflections should not be coalesced; similarly, filters on differently indexed frame parts should not be coalesced. Queries can now be ordered, ascending or descending, by a field, in addition to randomly as before. This is necessary for accessing the parts of a verb frame in the correct order, but may be useful to an end user as well. Fixed a bug with statement generation in that condition groups were not being surrounded in parentheses, which made mixing OR groups and AND groups generate inaccurate statements. This has been fixed; additionally, parentheses are not placed around the top level condition, and nested condition groups with the same logic type are coalesced, to make query strings as easy to read as possible. Also simplified the form::lemma field; it no longer conditions on the inflection of the form like the lemma::form field does. Also added a debug flag to statement::getQueryString that makes it return a query string with all of the bindings filled in, for debug use only. --- generator/part.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'generator/part.cpp') diff --git a/generator/part.cpp b/generator/part.cpp index 8a75ed4..07618a8 100644 --- a/generator/part.cpp +++ b/generator/part.cpp @@ -4,6 +4,8 @@ namespace verbly { namespace generator { + int part::nextId_ = 0; + part part::createNounPhrase(std::string role, selrestr selrestrs, std::set synrestrs) { part p(type::noun_phrase); @@ -49,9 +51,52 @@ namespace verbly { return p; } + part part::duplicate(const part& other) + { + part result(other.type_); + + switch (result.type_) + { + case type::noun_phrase: + { + new(&result.noun_phrase_.role) std::string(other.noun_phrase_.role); + new(&result.noun_phrase_.selrestrs) selrestr(other.noun_phrase_.selrestrs); + new(&result.noun_phrase_.synrestrs) std::set(other.noun_phrase_.synrestrs); + + break; + } + + case type::preposition: + { + new(&result.preposition_.choices) std::set(other.preposition_.choices); + result.preposition_.literal = other.preposition_.literal; + + break; + } + + case type::literal: + { + new(&result.literal_) std::string(other.literal_); + + break; + } + + case type::verb: + case type::adjective: + case type::adverb: + case type::invalid: + { + break; + } + } + + return result; + } + part::part(const part& other) { type_ = other.type_; + id_ = other.id_; switch (type_) { @@ -106,6 +151,7 @@ namespace verbly { using type = part::type; type tempType = first.type_; + int tempId = first.id_; std::string tempRole; selrestr tempSelrestrs; std::set tempSynrestrs; @@ -151,6 +197,7 @@ namespace verbly { first.~part(); first.type_ = second.type_; + first.id_ = second.id_; switch (first.type_) { @@ -190,6 +237,7 @@ namespace verbly { second.~part(); second.type_ = tempType; + second.id_ = tempId; switch (second.type_) { -- cgit 1.4.1