forked from an/flokati
markov
This commit is contained in:
parent
a517f0d638
commit
75b18d7107
|
@ -115,8 +115,9 @@ func markovParseText(text string) string {
|
|||
text = strings.Replace(text, ">", ">", -1)
|
||||
text = strings.Replace(text, "&", "&", -1)
|
||||
text = strings.Replace(text, ",", " ", -1)
|
||||
|
||||
return strings.ToLower(text)
|
||||
reg := regexp.MustCompile("[^a-zA-Z0-9 ]+")
|
||||
delText := reg.ReplaceAllString(text, "")
|
||||
return strings.ToLower(delText)
|
||||
}
|
||||
|
||||
// Prefix is a Markov chain prefix of one or more words.
|
||||
|
@ -212,9 +213,9 @@ 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, "?") {
|
||||
/*if strings.HasSuffix(next, ".") || strings.HasSuffix(next, "!") || strings.HasSuffix(next, "?") {
|
||||
break
|
||||
}
|
||||
}*/
|
||||
p.Shift(next)
|
||||
}
|
||||
if len(words) > 0 {
|
||||
|
|
Loading…
Reference in New Issue