gofakeit
gofakeit copied to clipboard
Comments
Add ability to generate a comment. Look at variations of types of comments and see if we can replicate them as best as possible
I'm looking into this.
first thought I have is to have types of comments (product reviews, facebook comments, etc?) and then create basic templates for each of them to follow, then fill the template with a list of chosen words for each type.
so this example for product review explains it:
func generateRandomReview() string {
templates := []string{
"I really %s this %s, especially its %s. However, %s.",
"As a long-time user of %s, I think it's %s.",
}
likeDislike := []string{"like", "love", "dislike", "hate"}
products := []string{"smartphone", "headphones", "laptop"}
features := []string{"battery life", "sound quality", "durability"}
additionalComments := []string{"I would definitely recommend it!", "It could be better."}
qualityDescriptors := []string{"amazing", "decent", "superb", "disappointing"}
rand.Seed(time.Now().UnixNano())
template := templates[rand.Intn(len(templates))]
comment := fmt.Sprintf(template,
likeDislike[rand.Intn(len(likeDislike))],
products[rand.Intn(len(products))],
features[rand.Intn(len(features))],
additionalComments[rand.Intn(len(additionalComments))])
return comment
}
I also came across something called article spinning, we can use this to generate our comment. I found this package gospin that does exactly that.
I already put something together last night. but i havent merged it into master yet so open to suggestions if you have something better.
I agree with having a variation of different comment types. With somewhat more defined sentences like your example. Cause what i have now is basically more gibberish.
https://github.com/brianvoe/gofakeit/commit/4ab4a5127f2a022df328f8721d940642b876689d
Dont worry about making changes if you come up with something better. its just a string return so no worries if we completely change it later.
Okk, I'll look at it later after this release.
ok released! lets see if you can come up with something better. :)