forked from an/flokati
markov: undo string cleanup changes
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)
|
text = strings.Replace(text, "&", "&", -1)
|
||||||
text = strings.Replace(text, ",", " ", -1)
|
text = strings.Replace(text, ",", " ", -1)
|
||||||
reg := regexp.MustCompile("[^a-zA-Z0-9 ]+")
|
//reg := regexp.MustCompile("[^a-zA-Z0-9 ]+")
|
||||||
delText := reg.ReplaceAllString(text, "")
|
//delText := reg.ReplaceAllString(text, "")
|
||||||
return strings.ToLower(delText)
|
return strings.ToLower(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefix is a Markov chain prefix of one or more words.
|
// 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))]
|
next := choices[rand.Intn(len(choices))]
|
||||||
words = append(words, next)
|
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 rand.Intn(100) < n {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
p.Shift(next)
|
||||||
}
|
}
|
||||||
if len(words) > 0 {
|
if len(words) > 0 {
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue