From 84e0f661c8f6a0be66c46cd9d9fdc3f967b5556c Mon Sep 17 00:00:00 2001 From: an Date: Sat, 24 Aug 2019 14:54:11 +0200 Subject: [PATCH] markov: undo string cleanup changes --- modules/markov.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/markov.go b/modules/markov.go index 5e778d5..64f4f9a 100644 --- a/modules/markov.go +++ b/modules/markov.go @@ -115,9 +115,9 @@ func markovParseText(text string) string { text = strings.Replace(text, ">", ">", -1) text = strings.Replace(text, "&", "&", -1) text = strings.Replace(text, ",", " ", -1) - reg := regexp.MustCompile("[^a-zA-Z0-9 ]+") - delText := reg.ReplaceAllString(text, "") - return strings.ToLower(delText) + //reg := regexp.MustCompile("[^a-zA-Z0-9 ]+") + //delText := reg.ReplaceAllString(text, "") + return strings.ToLower(text) } // Prefix is a Markov chain prefix of one or more words. @@ -213,13 +213,10 @@ func (c *MarkovChain) Generate(n int, in string) string { } next := choices[rand.Intn(len(choices))] words = append(words, next) - /*if strings.HasSuffix(next, ".") || strings.HasSuffix(next, "!") || strings.HasSuffix(next, "?") { - break - }*/ - p.Shift(next) - if rand.Intn(100) < n { + if strings.HasSuffix(next, ".") || strings.HasSuffix(next, "!") || strings.HasSuffix(next, "?") { break } + p.Shift(next) } if len(words) > 0 { break