markov: undo string cleanup changes
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
fac04ea3dc
commit
84e0f661c8
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue