markov: undo string cleanup changes
continuous-integration/drone/push Build is passing Details

This commit is contained in:
an 2019-08-24 14:54:11 +02:00
parent fac04ea3dc
commit 84e0f661c8
1 changed files with 5 additions and 8 deletions

View File

@ -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