From 92e3a5aeb083d51c9bc6c1eb5781c6f82ae7bb4a Mon Sep 17 00:00:00 2001 From: Zorchenhimer Date: Sun, 21 Feb 2021 20:07:42 -0500 Subject: [PATCH] Randomize all the options if omitted If an option for a pronoun, verb, noun, or noun_phrase is omitted it will be randomized. --- english.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/english.go b/english.go index ce91f0f..7f850c9 100644 --- a/english.go +++ b/english.go @@ -272,9 +272,11 @@ func (g *english) consumeWord(fmtString string, idx int, output *strings.Builder switch wordtype { case "pronoun": - var plural bool + var plural bool = rand.Int() % 2 == 0 if sliceContains(opts, "plural") { plural = true + } else if sliceContains(opts, "singular") + plural = false } word, err = g.randomPronoun(plural) @@ -300,25 +302,33 @@ func (g *english) consumeWord(fmtString string, idx int, output *strings.Builder } case "noun_phrase": - var definite bool = true - var hasAdj bool = true - var plural bool = false - var compound bool = false + var definite bool = rand.Int() % 2 == 0 + var hasAdj bool = rand.Int() % 2 == 0 + var plural bool = rand.Int() % 2 == 0 + var compound bool = rand.Int() % 2 == 0 if sliceContains(opts, "indefinite") { definite = false + } else if sliceContains(opts, "definite") { + definite = true } if sliceContains(opts, "noadj") { hasAdj = false + } else if sliceContains(opts, "adj") { + hasAdj = true } if sliceContains(opts, "plural") { plural = true + } else if sliceContains(opts, "singular") { + plural = false } if sliceContains(opts, "compound") { compound = true + } else if sliceContains(opts, "simple") { + compound = false } word, err = g.nounPhrase(definite, hasAdj, plural, compound)