aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2019-07-20 13:02:26 -0400
committerGitHub <noreply@github.com>2019-07-20 13:02:26 -0400
commit5ccf8c6f7bbe2aa3afc5d9dc6c2f37029a4093c5 (patch)
tree1b79dacdc06674665c698619fdc87374e04fa82a
parent071192f159f22b7d2cbd318f78456593835420db (diff)
parent0c8f8653bba0fa63ceda5dfc0f5f5ba917e472e1 (diff)
downloadjdtalk-5ccf8c6f7bbe2aa3afc5d9dc6c2f37029a4093c5.tar.gz
Merge pull request #8 from jhunkeler/word-salad
Implement "salad" mode
-rw-r--r--lib/jdtalk/core.d9
-rw-r--r--source/app.d11
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/jdtalk/core.d b/lib/jdtalk/core.d
index f3023b2..c0fc376 100644
--- a/lib/jdtalk/core.d
+++ b/lib/jdtalk/core.d
@@ -177,3 +177,12 @@ string talk(ref dict_t dict) {
" ");
return output;
}
+
+string talkSalad(ref dict_t dict, int words) {
+ string[] salad;
+ for (int i = 0; i < words; i++) {
+ string[] wordList = [dict.noun, dict.verb, dict.adverb, dict.adjective].choice;
+ salad ~= word(wordList);
+ }
+ return salad.join(" ");
+}
diff --git a/source/app.d b/source/app.d
index 387d19d..a094fcd 100644
--- a/source/app.d
+++ b/source/app.d
@@ -20,6 +20,7 @@ int main(string[] args)
import std.getopt;
long i = 0,
limit = 0;
+ int salad = 0;
bool exactMatch = false;
bool rCase = false;
bool hCase = false;
@@ -36,6 +37,7 @@ int main(string[] args)
"limit|c", format("(default: %d)", limit), &limit,
"pattern|p", "Limit output to a root word", &pattern,
"exact|e", format("Exact matches only (default: %s)", exactMatch ? "true" : "false"), &exactMatch,
+ "salad|s", "Produce N random words", &salad,
"rcase", format("Randomize case (default: %s)", rCase ? "true" : "false"), &rCase,
"hcase", format("Change every other case (default: %s)", hCase ? "true" : "false"), &hCase,
"leet", format("1337ify output (default: %s)", haxor ? "true" : "false"), &haxor,
@@ -61,7 +63,14 @@ int main(string[] args)
}
while(true) {
- string output = talk(dict);
+ string output;
+
+ if (salad) {
+ output = talkSalad(dict, salad);
+ }
+ else {
+ output = talk(dict);
+ }
if (pattern !is null) {
if (exactMatch && !hasWord(pattern, output)) {