From c0232ec87d669ef859f08b76e4b3bcaf881611f1 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 13 Feb 2017 11:02:16 -0500 Subject: Fixed verb query returning words with no valid verbs Also updated verbly for query time improvements. --- blessed.cpp | 26 ++++++++++++++++---------- vendor/verbly | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/blessed.cpp b/blessed.cpp index 8bb8d3f..02f4273 100644 --- a/blessed.cpp +++ b/blessed.cpp @@ -57,24 +57,30 @@ int main(int argc, char** argv) std::uniform_int_distribution emojidist(0, emojis.size()-1); std::bernoulli_distribution continuedist(1.0/2.0); - verbly::query verbQuery = database.forms( + verbly::filter nounFilter = + (verbly::notion::partOfSpeech == verbly::part_of_speech::noun) + && (verbly::form::proper == false) + // Blacklist ethnic slurs + && !(verbly::word::usageDomains %= (verbly::notion::wnid == 106718862)); + + verbly::query verbQuery = database.words( (verbly::notion::partOfSpeech == verbly::part_of_speech::verb) - && (verbly::pronunciation::rhymes)); + && (verbly::pronunciation::rhymes %= nounFilter)); for (;;) { std::cout << "Generating tweet..." << std::endl; - verbly::form verb = verbQuery.first(); + verbly::word verb = verbQuery.first(); + + verbly::word noun = database.words( + (verbly::pronunciation::rhymes %= verb) + && nounFilter).first(); - verbly::form noun = database.forms( - (verbly::notion::partOfSpeech == verbly::part_of_speech::noun) - && (verbly::pronunciation::rhymes %= verb) - && (verbly::form::proper == false) - && (verbly::form::id != verb.getId()) - && !(verbly::word::usageDomains %= (verbly::notion::wnid == 106718862))).first(); + verbly::token utter; + utter << "god" << verb << "this" << noun; - std::string exclamation = "god " + verb.getText() + " this " + noun.getText(); + std::string exclamation = utter.compile(); std::string emojibef; std::string emojiaft; diff --git a/vendor/verbly b/vendor/verbly index f1f67e6..a354b1f 160000 --- a/vendor/verbly +++ b/vendor/verbly @@ -1 +1 @@ -Subproject commit f1f67e62cebb4144f0599196263cd93b41fa972e +Subproject commit a354b1f864523e9def80aa1b3a561bce6bdb05ab -- cgit 1.4.1