gofakeit icon indicating copy to clipboard operation
gofakeit copied to clipboard

Comments

Open brianvoe opened this issue 2 years ago • 6 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

brianvoe avatar Dec 26 '22 05:12 brianvoe

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
}

se-omar avatar Jan 19 '24 02:01 se-omar

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.

se-omar avatar Jan 19 '24 02:01 se-omar

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.

brianvoe avatar Jan 19 '24 15:01 brianvoe

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.

brianvoe avatar Jan 19 '24 15:01 brianvoe

Okk, I'll look at it later after this release.

se-omar avatar Jan 19 '24 18:01 se-omar

ok released! lets see if you can come up with something better. :)

brianvoe avatar Jan 20 '24 01:01 brianvoe