diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-11-08 23:31:48 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-11-08 23:31:48 -0500 |
commit | 12db0bdd8118903bb03ff3f1058d73ceabcbf3d8 (patch) | |
tree | 1de9425a9ae21fde376aba67f2da915b644046a2 | |
parent | abfaab5c778e2131108740a615481c5a9b58bfc1 (diff) | |
download | support-12db0bdd8118903bb03ff3f1058d73ceabcbf3d8.tar.gz support-12db0bdd8118903bb03ff3f1058d73ceabcbf3d8.tar.bz2 support-12db0bdd8118903bb03ff3f1058d73ceabcbf3d8.zip |
Updated verbly (datafile versioning)
-rw-r--r-- | sentence.cpp | 36 | ||||
-rw-r--r-- | support.cpp | 12 | ||||
m--------- | vendor/verbly | 0 |
3 files changed, 18 insertions, 30 deletions
diff --git a/sentence.cpp b/sentence.cpp index d06ba10..be24a46 100644 --- a/sentence.cpp +++ b/sentence.cpp | |||
@@ -226,8 +226,7 @@ verbly::token sentence::generateStandardNounPhrase( | |||
226 | bool definite) const | 226 | bool definite) const |
227 | { | 227 | { |
228 | verbly::token utter; | 228 | verbly::token utter; |
229 | verbly::word sounder = noun; | 229 | bool indefiniteArticle = false; |
230 | verbly::word descript; | ||
231 | 230 | ||
232 | /*if (std::bernoulli_distribution(1.0/8.0)(rng_)) | 231 | /*if (std::bernoulli_distribution(1.0/8.0)(rng_)) |
233 | { | 232 | { |
@@ -252,20 +251,10 @@ verbly::token sentence::generateStandardNounPhrase( | |||
252 | { | 251 | { |
253 | utter << "your"; | 252 | utter << "your"; |
254 | } else if (!plural) { | 253 | } else if (!plural) { |
255 | if (sounder.getBaseForm().startsWithVowelSound()) | 254 | indefiniteArticle = true; |
256 | { | ||
257 | utter << "an"; | ||
258 | } else { | ||
259 | utter << "a"; | ||
260 | } | ||
261 | } | 255 | } |
262 | } | 256 | } |
263 | 257 | ||
264 | if (descript.isValid()) | ||
265 | { | ||
266 | utter << descript; | ||
267 | } | ||
268 | |||
269 | if (plural && noun.hasInflection(verbly::inflection::plural)) | 258 | if (plural && noun.hasInflection(verbly::inflection::plural)) |
270 | { | 259 | { |
271 | utter << verbly::token(noun, verbly::inflection::plural); | 260 | utter << verbly::token(noun, verbly::inflection::plural); |
@@ -273,7 +262,12 @@ verbly::token sentence::generateStandardNounPhrase( | |||
273 | utter << noun; | 262 | utter << noun; |
274 | } | 263 | } |
275 | 264 | ||
276 | return utter; | 265 | if (indefiniteArticle) |
266 | { | ||
267 | return verbly::token::indefiniteArticle(utter); | ||
268 | } else { | ||
269 | return utter; | ||
270 | } | ||
277 | } | 271 | } |
278 | 272 | ||
279 | verbly::token sentence::generateClause( | 273 | verbly::token sentence::generateClause( |
@@ -446,20 +440,15 @@ verbly::token sentence::generateClause( | |||
446 | utter << generateClause(sentence); | 440 | utter << generateClause(sentence); |
447 | } else if (part.nounHasSynrestr("quotation")) | 441 | } else if (part.nounHasSynrestr("quotation")) |
448 | { | 442 | { |
449 | verbly::token sentence(std::set<std::string>({"participle_phrase"})); | 443 | utter << verbly::token::quote("\"", "\"", |
450 | while (!sentence.isComplete()) | 444 | verbly::token(std::set<std::string>({"participle_phrase"}))); |
451 | { | ||
452 | visit(sentence); | ||
453 | } | ||
454 | |||
455 | utter << ("\"" + sentence.compile() + "\""); | ||
456 | } else { | 445 | } else { |
457 | if (part.nounHasSynrestr("genitive")) | 446 | if (part.nounHasSynrestr("genitive")) |
458 | { | 447 | { |
459 | verbly::word noun = generateStandardNoun("Passive", {"animate"}); | 448 | verbly::word noun = generateStandardNoun("Passive", {"animate"}); |
460 | verbly::token owner = generateStandardNounPhrase(noun, "Passive", false, true); | 449 | verbly::token owner = generateStandardNounPhrase(noun, "Passive", false, true); |
461 | std::string ownerStr = owner.compile() + "'s"; | 450 | |
462 | utter << ownerStr; | 451 | utter << verbly::token::punctuation("'s", owner); |
463 | } | 452 | } |
464 | 453 | ||
465 | verbly::word noun = generateStandardNoun(part.getNounRole(), part.getNounSelrestrs()); | 454 | verbly::word noun = generateStandardNoun(part.getNounRole(), part.getNounSelrestrs()); |
@@ -665,4 +654,3 @@ void sentence::visit(verbly::token& it) const | |||
665 | } | 654 | } |
666 | } | 655 | } |
667 | } | 656 | } |
668 | |||
diff --git a/support.cpp b/support.cpp index 8dc6c4e..3594eb6 100644 --- a/support.cpp +++ b/support.cpp | |||
@@ -18,6 +18,12 @@ int main(int argc, char** argv) | |||
18 | std::string configfile(argv[1]); | 18 | std::string configfile(argv[1]); |
19 | YAML::Node config = YAML::LoadFile(configfile); | 19 | YAML::Node config = YAML::LoadFile(configfile); |
20 | 20 | ||
21 | std::random_device randomDevice; | ||
22 | std::mt19937 rng{randomDevice()}; | ||
23 | |||
24 | verbly::database database(config["verbly_datafile"].as<std::string>()); | ||
25 | sentence generator(database, rng); | ||
26 | |||
21 | twitter::auth auth; | 27 | twitter::auth auth; |
22 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); | 28 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); |
23 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); | 29 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); |
@@ -26,12 +32,6 @@ int main(int argc, char** argv) | |||
26 | 32 | ||
27 | twitter::client client(auth); | 33 | twitter::client client(auth); |
28 | 34 | ||
29 | std::random_device randomDevice; | ||
30 | std::mt19937 rng{randomDevice()}; | ||
31 | |||
32 | verbly::database database(config["verbly_datafile"].as<std::string>()); | ||
33 | sentence generator(database, rng); | ||
34 | |||
35 | for (;;) | 35 | for (;;) |
36 | { | 36 | { |
37 | verbly::word adjective = database.words( | 37 | verbly::word adjective = database.words( |
diff --git a/vendor/verbly b/vendor/verbly | |||
Subproject 59eab842de02b2b2ba8bf53e2214b558457e635 | Subproject 350bfdb5ea9b4f7e50746c50a46d8032cbc5a10 | ||