From d5ef6583d90407113c610cf21563f12569c776a6 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 10 May 2016 09:53:14 -0400 Subject: Changed form generation to be piecewise like chemist --- CMakeLists.txt | 3 +- forms.txt | 200 ++++++++++++++++++++++++++++++++++++++++++++++++--------- infinite.cpp | 44 ++++++++++--- 3 files changed, 206 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd0729c..1902dc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,11 @@ add_subdirectory(vendor/verbly) add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL) find_package(PkgConfig) -pkg_check_modules(sqlite3 sqlite3 REQUIRED) +pkg_check_modules(sqlite3 sqlite3>=3.8.3 REQUIRED) pkg_check_modules(GraphicsMagick GraphicsMagick++ REQUIRED) include_directories(${GraphicsMagick_INCLUDE_DIRS} ${sqlite3_INCLUDE_DIR} vendor/verbly/lib vendor/libtwittercpp/src vendor/yaml-cpp/include vendor/libtwittercpp/vendor/json/src vendor/libtwittercpp/vendor/curlcpp/include) +link_directories(${sqlite3_LIBRARY_DIRS}) add_executable(infinite infinite.cpp color.cpp fractal.cpp matrix3x3.cpp vector3d.cpp tinyxml2.cpp triangle.cpp) set_property(TARGET infinite PROPERTY CXX_STANDARD 11) set_property(TARGET infinite PROPERTY CXX_STANDARD_REQUIRED ON) diff --git a/forms.txt b/forms.txt index bd4bc02..12e1d3e 100644 --- a/forms.txt +++ b/forms.txt @@ -1,33 +1,173 @@ -And in that moment, I could swear we were {ADJECTIVE}. -In {LANGUAGE}, you don't say "I am {ADJECTIVE}", you say "{SENTENCE}" and I think that's beautiful. -Do you love the color of the {NOUN}? Which one? -You all laugh because I'm {ADJECTIVE}. I laugh because you are all {ADJECTIVE}. -Life begins at the end of your {NOUN}. -Every new {NOUN} is a new chance to change your {NOUN}. -If you {VERB} people, you have no time to {VERB} them. -In the end, we only regret the {PLURAL_NOUN} we didn't take. -I just want to be completely {ADJECTIVE} and say that I really {VERB} you. -Wanderlust: a very strong and {ADJECTIVE} impulse or desire to {VERB} the world. -Do not go where the {NOUN} may lead; go instead where there is no {NOUN} and leave a {NOUN}. +FORM +And in that moment, I could swear {CLAUSE}. +In {LANGUAGE}, {CLAUSE} and {CLAUSE}. +Do you love the color of the {UNCOUNTABLE_NOUN}? {SENTENCE} +You all laugh because I'm {ADJECTIVAL_PHRASE}. {SENTENCE} +Life begins at {SOMETHING}. +Every new {NOUN} is {SOMETHING}. +If you {TRANSITIVE_VERB} people, {CLAUSE}. +In the end, {CLAUSE}. +I just want {INFINITIVAL_PHRASE} and say that {CLAUSE}. +Wanderlust: {SOMETHING}. +Do not go where the {UNCOUNTABLE_NOUN} may lead. {SENTENCE} {Verbing} isn't easy for those who {VERB}. -You build up a world of {NOUN} because your real life is {ADJECTIVE}. -{Adjective} is just a setting on a washing machine. +You build up a world of {PLURAL_NOUN} because {CLAUSE}. +{Adjective} is just {SOMETHING}. Find a beautiful {NOUN} and get {VERBED}. -Keep your feet on the {NOUN} when your head's in the {NOUN}. -{Noun} can be found in the darkest of times if one only remembers to switch on the {NOUN}. -May the odds be ever in your {NOUN}. -Do something today that your future self will {VERB} you for. -Sometimes it's so {ADJECTIVE} to see the good {PLURAL_NOUN} passing by. -When it rains, look for {PLURAL_NOUN}. When it's dark, look for {PLURAL_NOUN}. -I'd rather {VERB} the {NOUN} than wait for it. +Keep your feet on the {UNCOUNTABLE_NOUN} when your head's in the {UNCOUNTABLE_NOUN}. +{Uncountable_noun} can be found in the {SUPERLATIVE} of times if {CLAUSE}. +May the {UNCOUNTABLE_NOUN} be ever in your {THING_YOU_HAVE}. +Do something today that your future self will {TRANSITIVE_VERB} you for. +Sometimes it's so {ADJECTIVE} {INFINITIVAL_PHRASE}. +When it rains, {CLAUSE}. {SENTENCE} +I'd rather {TRANSITIVE_VERB} the {UNCOUNTABLE_NOUN} than wait for it. There's a {NOUN} in all of us. -You were born to be {ADJECTIVE}, not to be perfect. -{Verb} me when I least deserve it because that's when I really need it. -Normal is {ADJECTIVE}. -If nobody {VERBS} you, you're doing something wrong. -Don't waste your whole {NOUN} trying to get back what was {VERBED}. -I can't explain how {ADJECTIVE} it is to wait for something that never {VERBS}. -I will follow you into the {NOUN}. -I think about {NOUN} a lot. More than I probably should. -{Noun}ophobia: (n.) the fear of {VERBING} someone you love. -We stopped looking for {PLURAL_NOUN} under our {PLURAL_NOUN} when we realized they were inside of us. \ No newline at end of file +You were born {INFINITIVAL_PHRASE}, not to be perfect. +{Transitive_verb} me when I least deserve it because {CLAUSE}. +Normal is {ADJECTIVAL_PHRASE}. +If nobody {VERBS} you, {CLAUSE}. +Don't waste your whole {THING_YOU_HAVE} trying {INFINITIVAL_PHRASE}. +I can't explain how {ADJECTIVE} it is {INFINITIVAL_PHRASE}. +I will follow you into the {UNCOUNTABLE_NOUN}. +I think about {NOUN} a lot. {SENTENCE} +{Noun}ophobia: (n.) the fear of {VERBING} {SOMETHING}. +We stopped looking for {PLURAL_NOUN} under our {PLURAL_NOUN} when we realized {CLAUSE}. +Living on Earth is {ADJECTIVE}, but {CLAUSE}. +We are all {PLURAL_NOUN} wanting {INFINITIVAL_PHRASE}. +Let's not try {INFINITIVAL_PHRASE}. +I'm going {INFINITIVAL_PHRASE} because {CLAUSE}. +A dream is {SOMETHING} your {THING_YOU_HAVE} makes. +All {PLURAL_NOUN} have {SOMETHING}. +After {SOMETHING}, my {THING_YOU_HAVE} said "{SENTENCE}" + +CLAUSE +we were {ADJECTIVAL_PHRASE} +you don't say "I am {ADJECTIVE}", you say "{VERBLY_SENTENCE}" +I think that's beautiful +you have no time {INFINITIVAL_PHRASE} +we only regret the {PLURAL_NOUN} we didn't take +I really {TRANSITIVE_VERB} you +your real life is {ADJECTIVAL_PHRASE} +you remember {INFINITIVAL_PHRASE} +you should look for {PLURAL_NOUN} +that's when I really need it +you're doing something wrong +they were inside of us +it does include {SOMETHING} +I'm crazy enough {INFINITIVAL_PHRASE} + +SENTENCE +Which one? +{CLAUSE}. +{FORM} +I laugh because you are all {ADJECTIVAL_PHRASE}. +Go instead where there is no {NOUN} and leave a {NOUN}. +When it's dark, {CLAUSE}. +More than I probably should. +Maybe life isn't for everyone. + +SOMETHING +the end of your {THING_YOU_HAVE} +a new chance {INFINITIVAL_PHRASE} +a very strong and {ADJECTIVE} impulse or desire {INFINITIVAL_PHRASE} +a setting on a washing machine +someone you love +a free trip around the sun +everything +a wish +an end +a year in therapy + +INFINITIVAL_PHRASE +to be {ADJECTIVAL_PHRASE} +to get back what was {VERBED} +to wait for something that never {VERBS} +to be completely upfront +to see the good {PLURAL_NOUN} passing by +to {TRANSITIVE_VERB} them +to switch on the {UNCOUNTABLE_NOUN} +to change your {THING_YOU_HAVE} +to {TRANSITIVE_VERB} the {UNCOUNTABLE_NOUN} +to be completely out of touch with reality +to figure out {SOMETHING} at once +to succeed +to think I can + +ADJECTIVAL_PHRASE +{ADJECTIVE} +{ADJECTIVE} +{ADJECTIVE} +{ADJECTIVE} +{ADJECTIVE} +the same +getting fucked +getting {VERBED} + +ADJECTIVE +infinite +different +irresistable +sexual +unhappy +stupid +gay +high +expensive +beautiful +opulent +salacious +destined +surreal +indecent + +UNCOUNTABLE_NOUN +sky +road +ground +clouds +light +happiness +serenity +desirability +misfortune +wealth +{ADJECTIVE} inadequacy +odds + +THING_YOU_HAVE +fears +life +favor +heart +therapist +hopes +love +Amazon Prime subscription + +PLURAL_NOUN +risks +lies +mistakes +dreamers +stories +hopes +queers +lives +needs +experiences +freedoms + +TRANSITIVE_VERB +destroy +kill +hate +love +fight +report +represent +revile +exhume +inter +disgrace +eat +butter \ No newline at end of file diff --git a/infinite.cpp b/infinite.cpp index 22de917..f79d201 100644 --- a/infinite.cpp +++ b/infinite.cpp @@ -433,6 +433,8 @@ class fill_blanks { int main(int argc, char** argv) { srand(time(NULL)); + rand(); rand(); rand(); rand(); + Magick::InitializeMagick(nullptr); int delay = 60 * 60; @@ -450,15 +452,17 @@ int main(int argc, char** argv) { std::cout << "Generating text..." << std::endl; - std::vector forms; + std::map> groups; std::ifstream datafile("forms.txt"); if (!datafile.is_open()) { std::cout << "Could not find forms.txt" << std::endl; return 1; } - + + bool newgroup = true; std::string line; + std::string curgroup; while (getline(datafile, line)) { if (line.back() == '\r') @@ -466,13 +470,24 @@ int main(int argc, char** argv) line.pop_back(); } - forms.push_back(line); + if (newgroup) + { + curgroup = line; + newgroup = false; + } else { + if (line.empty()) + { + newgroup = true; + } else { + groups[curgroup].push_back(line); + } + } } datafile.close(); verbly::data database {"data.sqlite3"}; - std::string action = forms[rand() % forms.size()]; + std::string action = "{FORM}"; int tknloc; while ((tknloc = action.find("{")) != std::string::npos) { @@ -487,12 +502,15 @@ int main(int argc, char** argv) if (canontkn == "NOUN") { result = database.nouns().is_not_proper().random().limit(1).with_complexity(1).run().front().singular_form(); - } else if (canontkn == "PLURAL_NOUN") - { - result = database.nouns().is_not_proper().requires_plural_form().random().limit(1).with_complexity(1).run().front().plural_form(); - } else if (canontkn == "ADJECTIVE") +// } else if (canontkn == "PLURAL_NOUN") +// { +// result = database.nouns().is_not_proper().requires_plural_form().random().limit(1).with_complexity(1).run().front().plural_form(); +// } else if (canontkn == "ADJECTIVE") + // { + // result = database.adjectives().with_complexity(1).random().limit(1).run().front().base_form(); + } else if (canontkn == "SUPERLATIVE") { - result = database.adjectives().with_complexity(1).random().limit(1).run().front().base_form(); + result = database.adjectives().requires_superlative_form().random().limit(1).run().front().superlative_form(); } else if (canontkn == "VERB") { result = database.verbs().random().limit(1).run().front().infinitive_form(); @@ -520,7 +538,7 @@ int main(int argc, char** argv) } else if (canontkn == "ADVERB") { result = database.adverbs().with_complexity(1).random().limit(1).run().front().base_form(); - } else if (canontkn == "SENTENCE") + } else if (canontkn == "VERBLY_SENTENCE") { fill_blanks yeah {database}; verbly::token action{ @@ -532,6 +550,10 @@ int main(int argc, char** argv) yeah.visit(action); } result = action.compile(); + } else { + auto group = groups[canontkn]; + result = group[rand() % group.size()]; + std::cout << canontkn << ": " << group.size() << std::endl; } std::string finalresult; @@ -555,6 +577,8 @@ int main(int argc, char** argv) action.replace(tknloc, action.find("}")-tknloc+1, finalresult); } + + std::cout << action << std::endl; double zoom = 2.0; double target_w = 1280; -- cgit 1.4.1