forked from an/flokati
		
	markov: undo string cleanup changes
This commit is contained in:
		
							parent
							
								
									fac04ea3dc
								
							
						
					
					
						commit
						84e0f661c8
					
				
					 1 changed files with 5 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue