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 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'blessed.cpp') 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; -- cgit 1.4.1