forked from ebhomengo/niki
1
0
Fork 0
niki/vendor/github.com/brianvoe/gofakeit/v6/word_grammar.go

54 lines
974 B
Go
Raw Normal View History

2024-04-26 19:30:35 +00:00
package gofakeit
import (
"math/rand"
"unicode"
)
// SentenceSimple will generate a random simple sentence
2024-04-26 19:30:35 +00:00
func SentenceSimple() string { return sentenceSimple(globalFaker.Rand) }
// SentenceSimple will generate a random simple sentence
2024-04-26 19:30:35 +00:00
func (f *Faker) SentenceSimple() string { return sentenceSimple(f.Rand) }
func sentenceSimple(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
// simple sentence consists of a noun phrase and a verb phrase
2024-04-26 19:30:35 +00:00
str := phraseNoun(r) + " " + phraseVerb(r) + "."
// capitalize the first letter
2024-04-26 19:30:35 +00:00
strR := []rune(str)
2024-04-26 19:30:35 +00:00
strR[0] = unicode.ToUpper(strR[0])
2024-04-26 19:30:35 +00:00
return string(strR)
2024-04-26 19:30:35 +00:00
}
func addWordGrammerLookup() {
2024-04-26 19:30:35 +00:00
AddFuncLookup("sentencesimple", Info{
Display: "Simple Sentence",
Category: "word",
2024-04-26 19:30:35 +00:00
Description: "Group of words that expresses a complete thought",
Example: "A tribe fly the lemony kitchen.",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return sentenceSimple(r), nil
2024-04-26 19:30:35 +00:00
},
})
2024-04-26 19:30:35 +00:00
}