From 4ab4a5127f2a022df328f8721d940642b876689d Mon Sep 17 00:00:00 2001 From: brianvoe Date: Fri, 19 Jan 2024 09:10:08 -0600 Subject: [PATCH] strings - added comment, added a couple of new word types --- data/word.go | 4 +++ generate_test.go | 28 ++++++++--------- lookup.go | 2 ++ product_test.go | 24 +++++++------- template_test.go | 56 ++++++++++++++++----------------- word_comment.go | 73 +++++++++++++++++++++++++++++++++++++++++++ word_comment_test.go | 33 +++++++++++++++++++ word_general_test.go | 4 +-- word_misc.go | 24 ++++++++++++++ word_misc_test.go | 26 +++++++++++++++ word_noun.go | 19 +++++++++++ word_noun_test.go | 29 +++++++++++++++++ word_sentence_test.go | 16 +++++----- 13 files changed, 274 insertions(+), 64 deletions(-) create mode 100644 word_comment.go create mode 100644 word_comment_test.go create mode 100644 word_misc.go create mode 100644 word_misc_test.go diff --git a/data/word.go b/data/word.go index 38ba2547..87b48dc8 100644 --- a/data/word.go +++ b/data/word.go @@ -27,6 +27,7 @@ var Word = map[string][]string{ "noun_collective_thing": {"wad", "pair", "album", "string", "anthology", "reel", "outfit", "fleet", "comb", "archipelago", "quiver", "bale", "packet", "hedge", "basket", "orchard", "batch", "library", "battery", "set", "harvest", "block", "forest", "book", "group", "bouquet", "collection", "bowl", "stack", "bunch", "hand", "bundle", "catalog", "shower", "ream", "chest", "heap", "range", "cluster", "pack", "hail", "cloud", "galaxy", "sheaf", "clump"}, "noun_countable": {"camp", "hospital", "shirt", "sock", "plant", "cup", "fork", "spoon", "plate", "straw", "town", "box", "bird", "father", "answer", "egg", "purse", "mirror", "mistake", "toilet", "toothbrush", "shower", "towel", "pool", "corner", "card", "lawn", "city", "egg", "yard", "burger", "kilometer", "mile", "father", "film", "actor", "issue", "machine", "liter", "room", "station", "journey", "castle", "hour", "finger", "boy", "book", "year", "second", "son", "month", "group", "hall", "cat", "week", "picture", "day", "village", "effect", "baby", "weekend", "class", "meal", "river", "grade", "bush", "desk", "stream", "method", "brother", "sister", "factory", "aunt", "bush", "program", "uncle", "ball", "cousin", "wall", "grandmother", "cup", "grandfather", "week", "school", "shirt", "child", "king", "road", "judge", "bridge", "car", "line", "book", "eye", "teacher", "foot", "party", "face", "day", "chest", "handle", "week", "hotel", "eye", "animal", "doctor", "adult", "village", "key", "bird", "bank", "program", "idea", "gun", "card", "brother", "dress", "room", "door", "mouth", "club", "game", "ring", "project", "sister", "road", "coat", "account", "group", "cigarette", "farm", "river", "college", "computer", "walk", "corner", "cat", "head", "street", "election", "country", "chair", "crowd", "cup", "plant", "farm", "handle", "model", "book", "message", "battle", "pen", "pencil", "elephant", "carrot", "onion", "garden", "country", "engine", "bill", "apple", "noun", "club", "crowd", "window", "field", "friend", "verb", "class", "flower", "seed", "lake", "plant", "animal", "ocean", "whale", "fish", "stream", "cloud", "couch", "steak", "problem", "light", "door", "room", "painting", "shop", "apartment", "candle", "adult", "building", "plan", "page", "ball", "game", "animal", "apartment", "box", "thought", "walk", "lady", "bottle", "article", "game", "kettle", "car", "house", "hoses", "orange", "phone", "app", "window", "door", "dollar", "foot", "cent", "library", "cat", "bed", "pound", "gate", "tomatoes", "gun", "holiday", "woman", "job", "shock", "salary", "tax", "coat", "scooter", "dog", "problem", "field", "answer", "ear", "camp", "case", "road", "woman", "product", "bridge", "man", "dream", "idea", "scheme", "invention", "cigarette", "mother", "friend", "chapter", "computer", "dream", "father", "child", "motor", "deskpath", "factory", "park", "newspaper", "hat", "dream", "table", "kitchen", "student", "captain", "doctor", "bus", "neck", "class", "list", "member", "chest", "valley", "product", "horse", "captain", "star", "hour", "page", "bus", "girl", "month", "child", "house", "boy", "bill", "kitchen", "chapter", "boat", "hand", "dress", "table", "wall", "chair", "train", "minute", "magazine", "bus", "party", "bird", "lake", "job", "nation", "bike", "election", "hand", "box", "beach", "address", "project", "task", "park", "face", "college", "bell", "plane", "store", "hall", "accident", "daughter", "ship", "candy", "smile", "city", "island", "case", "spot", "film", "husband", "artist", "tour", "bag", "boat", "driver", "office", "chair", "path", "dog", "bag", "finger", "apartment", "garden", "heart", "year", "engine", "girl", "day", "castle", "plane", "ring", "brother", "edge", "picture", "meeting", "tent", "dog", "hat", "head", "bottle", "hill"}, "noun_uncountable": {"accommodation", "advertising", "air", "aid", "advice", "anger", "art", "assistance", "bread", "business", "butter", "calm", "cash", "chaos", "cheese", "childhood", "clothing", "coffee", "content", "corruption", "courage", "currency", "damage", "danger", "darkness", "data", "determination", "economics", "education", "electricity", "employment", "energy", "entertainment", "enthusiasm", "equipment", "evidence", "failure", "fame", "fire", "flour", "food", "freedom", "friendship", "fuel", "furniture", "fun", "genetics", "gold", "grammar", "guilt", "hair", "happiness", "harm", "health", "heat", "help", "homework", "honesty", "hospitality", "housework", "humour", "imagination", "importance", "information", "innocence", "intelligence", "jealousy", "juice", "justice", "kindness", "knowledge", "labour", "lack", "laughter", "leisure", "literature", "litter", "logic", "love", "luck", "magic", "management", "metal", "milk", "money", "motherhood", "motivation", "music", "nature", "news", "nutrition", "obesity", "oil", "old age", "oxygen", "paper", "patience", "permission", "pollution", "poverty", "power", "pride", "production", "progress", "pronunciation", "publicity", "punctuation", "quality", "quantity", "racism", "rain", "relaxation", "research", "respect", "rice", "room (space)", "rubbish", "safety", "salt", "sand", "seafood", "shopping", "silence", "smoke", "snow", "software", "soup", "speed", "spelling", "stress", "sugar", "sunshine", "tea", "tennis", "time", "tolerance", "trade", "traffic", "transportation", "travel", "trust", "understanding", "unemployment", "usage", "violence", "vision", "warmth", "water", "wealth", "weather", "weight", "welfare", "wheat", "width", "wildlife", "wisdom", "wood", "work", "yoga", "youth"}, + "noun_determiner": {"the", "a", "an", "this", "that", "these", "those", "my", "your", "his", "her", "its", "our", "their", "some", "any", "each", "every", "certain"}, //"noun_proper": {}, // This refers to an actual person(John Doe), place(Chipotle, Tennessee) // Verbs @@ -76,4 +77,7 @@ var Word = map[string][]string{ "connective_listing": {"firstly", "secondly", "first of all", "finally", "lastly", "for one thing", "for another", "in the first place", "to begin with", "next", "in summation", "to conclude"}, "connective_casual": {"accordingly", "all the same", "an effect of", "an outcome of", "an upshot of", "as a consequence of", "as a result of", "because", "caused by", "consequently", "despite this", "even though", "hence", "however", "in that case", "moreover", "nevertheless", "otherwise", "so", "so as", "stemmed from", "still", "then", "therefore", "though", "under the circumstances", "yet"}, "connective_examplify": {"accordingly", "as a result", "as exemplified by", "consequently", "for example", "for instance", "for one thing", "including", "provided that", "since", "so", "such as", "then", "therefore", "these include", "through", "unless", "without"}, + + // Misc + "interjection": {"wow", "hey", "oops", "ouch", "yay", "aha", "eek", "huh", "hmm", "whoa", "yikes", "phew", "gee", "alas", "bravo"}, } diff --git a/generate_test.go b/generate_test.go index 2f127bc2..af3a95eb 100644 --- a/generate_test.go +++ b/generate_test.go @@ -51,12 +51,12 @@ func ExampleGenerate() { fmt.Println(Generate("{shufflestrings:[key:value,int:string,1:2,a:b]}")) // Output: Markus Moen ssn is 526643139 and lives at 599 Daleton - // Niche backwards caused. - // [1 3 2] - // -4 - // 3 - // 46 - // [a:b int:string key:value 1:2] + // Congolese choir computer. + // [3 1 2] + // 2 + // 4 + // 17 + // [int:string 1:2 a:b key:value] } func ExampleFaker_Generate() { @@ -71,12 +71,12 @@ func ExampleFaker_Generate() { fmt.Println(f.Generate("{shufflestrings:[key:value,int:string,1:2,a:b]}")) // Output: Markus Moen ssn is 526643139 and lives at 599 Daleton - // Niche backwards caused. - // [1 3 2] - // -4 - // 3 - // 46 - // [a:b int:string key:value 1:2] + // Congolese choir computer. + // [3 1 2] + // 2 + // 4 + // 17 + // [int:string 1:2 a:b key:value] } func BenchmarkGenerate(b *testing.B) { @@ -480,14 +480,14 @@ func ExampleMap() { Seed(11) fmt.Println(Map()) - // Output: map[contrast:Associate gauva:map[jump:scale] generally:8504801 him:[them whomever ours hence here his] its:8335564 table:map[did:[these delay these]] therefore:map[nearly:784141.8] thing:map[everything:[where caused why week hourly]]] + // Output: map[here:Manager herself:map[trip:[far computer was unless whom riches]] how:8504801 ouch:Keith Ullrich outstanding:1860846 that:web services] } func ExampleFaker_Map() { f := New(11) fmt.Println(f.Map()) - // Output: map[contrast:Associate gauva:map[jump:scale] generally:8504801 him:[them whomever ours hence here his] its:8335564 table:map[did:[these delay these]] therefore:map[nearly:784141.8] thing:map[everything:[where caused why week hourly]]] + // Output: map[here:Manager herself:map[trip:[far computer was unless whom riches]] how:8504801 ouch:Keith Ullrich outstanding:1860846 that:web services] } func TestMap(t *testing.T) { diff --git a/lookup.go b/lookup.go index f8020089..9bb9e9d8 100644 --- a/lookup.go +++ b/lookup.go @@ -105,6 +105,8 @@ func initLookup() { addWordPronounLookup() addWordSentenceLookup() addWordVerbLookup() + addWordCommentLookup() + addWordMiscLookup() } // internalFuncLookups is the internal map array with mapping to all available data diff --git a/product_test.go b/product_test.go index 452ec48b..0688d93a 100644 --- a/product_test.go +++ b/product_test.go @@ -18,13 +18,13 @@ func ExampleProduct() { fmt.Println(product.UPC) // Output: Olive Copper Monitor - // Backwards caused quarterly without week it hungry thing someone him regularly. Whomever this revolt hence from his timing as quantity us these yours. + // Choir computer still far unless army party riches theirs instead here. Whichever that those instance growth has ouch enough Swiss us since down he. Aha us you to upon how this this furniture way no play towel. // [clothing tools and hardware] - // 7.61 + // 41.61 // [ultra-lightweight] - // navy - // brass - // 012780949980 + // olive + // stainless + // 074937734366 } func ExampleFaker_Product() { @@ -40,13 +40,13 @@ func ExampleFaker_Product() { fmt.Println(product.UPC) // Output: Olive Copper Monitor - // Backwards caused quarterly without week it hungry thing someone him regularly. Whomever this revolt hence from his timing as quantity us these yours. + // Choir computer still far unless army party riches theirs instead here. Whichever that those instance growth has ouch enough Swiss us since down he. Aha us you to upon how this this furniture way no play towel. // [clothing tools and hardware] - // 7.61 + // 41.61 // [ultra-lightweight] - // navy - // brass - // 012780949980 + // olive + // stainless + // 074937734366 } func TestProduct(t *testing.T) { @@ -134,14 +134,14 @@ func ExampleProductDescription() { Seed(11) fmt.Println(ProductDescription()) - // Output: Generally half where everything niche backwards caused quarterly without week it hungry thing someone him. Today whomever this revolt hence from his timing as quantity us these yours. + // Output: How these keep trip Congolese choir computer still far unless army party riches theirs instead. Mine whichever that those instance. Has ouch enough Swiss us since down. } func ExampleFaker_ProductDescription() { f := New(11) fmt.Println(f.ProductDescription()) - // Output: Generally half where everything niche backwards caused quarterly without week it hungry thing someone him. Today whomever this revolt hence from his timing as quantity us these yours. + // Output: How these keep trip Congolese choir computer still far unless army party riches theirs instead. Mine whichever that those instance. Has ouch enough Swiss us since down. } func BenchmarkProductDescription(b *testing.B) { diff --git a/template_test.go b/template_test.go index fb61f49e..928e4586 100644 --- a/template_test.go +++ b/template_test.go @@ -231,7 +231,7 @@ func ExampleEmailText() { fmt.Println(string(value)) // Output: - // Subject: Greetings from Marcel! + // Subject: Greetings from Marcel! // // Dear Pagac, // @@ -239,22 +239,22 @@ func ExampleEmailText() { // // I hope you're doing great. May your week be filled with joy. // - // Virtually woman where team late quarterly without week it hungry. Thing someone him regularly today whomever this revolt hence from. His timing as quantity us these yours live these frantic. Not may another how this ours his them those whose. Them batch its Iraqi most that few abroad cheese this. + // This me far smile where was by army party riches. Theirs instead here mine whichever that those instance growth has. Ouch enough Swiss us since down he she aha us. You to upon how this this furniture way no play. Towel that us to accordingly theirs purse enough so though. // - // Whereas next how there gorgeous genetics time choir fiction therefore. Yourselves am those infrequently heap software quarterly rather punctuation yellow. Where several his orchard to frequently hence victorious boxers each. Does auspicious yourselves first soup tomorrow this that must conclude. Anyway some yearly who cough laugh himself both yet rarely. + // Election often until eek weekly yet oops until conclude his. Stay elsewhere such that galaxy clean that last each stack. Reluctantly theirs wisp aid firstly highly butter accordingly should already. Calm shake according fade neither kuban upon this he fortnightly. Occasionally bunch on who elsewhere lastly hourly right there honesty. // - // Me dolphin intensely block would leap plane us first then. Down them eager would hundred super throughout animal yet themselves. Been group flock shake part purchase up usually it her. None it hers boat what their there Turkmen moreover one. Lebanese to brace these shower in it everybody should whatever. + // We is how result out Shakespearean have whom yearly another. Packet are behind late lot finally time themselves goodness quizzical. Our therefore could fact cackle yourselves zebra for whose enormously. All bowl out wandering secondly yellow another your hourly spit. Since tomorrow hers words little think will our by Polynesian. // - // I'm curious to know what you think about it. If you have a moment, please feel free to check out the project on Bitbucket + // I'm curious to know what you think about it. If you have a moment, please feel free to check out the project on GitLab // - // I'm eager to hear what you think. Looking forward to your feedback! + // Your insights would be invaluable. Your thoughts matter to me. // - // Thank you for your consideration! Thanks in advance for your time. + // I appreciate your attention to this matter. Your feedback is greatly appreciated. // - // Kind regards - // Milford Johnston - // jamelhaag@king.org - // (507)096-3058 + // Best wishes + // Daryl Leannon + // oceaneokuneva@roberts.org + // 1-816-608-2233 } func ExampleFaker_EmailText() { @@ -268,7 +268,7 @@ func ExampleFaker_EmailText() { fmt.Println(string(value)) // Output: - // Subject: Greetings from Marcel! + // Subject: Greetings from Marcel! // // Dear Pagac, // @@ -276,22 +276,22 @@ func ExampleFaker_EmailText() { // // I hope you're doing great. May your week be filled with joy. // - // Virtually woman where team late quarterly without week it hungry. Thing someone him regularly today whomever this revolt hence from. His timing as quantity us these yours live these frantic. Not may another how this ours his them those whose. Them batch its Iraqi most that few abroad cheese this. + // This me far smile where was by army party riches. Theirs instead here mine whichever that those instance growth has. Ouch enough Swiss us since down he she aha us. You to upon how this this furniture way no play. Towel that us to accordingly theirs purse enough so though. // - // Whereas next how there gorgeous genetics time choir fiction therefore. Yourselves am those infrequently heap software quarterly rather punctuation yellow. Where several his orchard to frequently hence victorious boxers each. Does auspicious yourselves first soup tomorrow this that must conclude. Anyway some yearly who cough laugh himself both yet rarely. + // Election often until eek weekly yet oops until conclude his. Stay elsewhere such that galaxy clean that last each stack. Reluctantly theirs wisp aid firstly highly butter accordingly should already. Calm shake according fade neither kuban upon this he fortnightly. Occasionally bunch on who elsewhere lastly hourly right there honesty. // - // Me dolphin intensely block would leap plane us first then. Down them eager would hundred super throughout animal yet themselves. Been group flock shake part purchase up usually it her. None it hers boat what their there Turkmen moreover one. Lebanese to brace these shower in it everybody should whatever. + // We is how result out Shakespearean have whom yearly another. Packet are behind late lot finally time themselves goodness quizzical. Our therefore could fact cackle yourselves zebra for whose enormously. All bowl out wandering secondly yellow another your hourly spit. Since tomorrow hers words little think will our by Polynesian. // - // I'm curious to know what you think about it. If you have a moment, please feel free to check out the project on Bitbucket + // I'm curious to know what you think about it. If you have a moment, please feel free to check out the project on GitLab // - // I'm eager to hear what you think. Looking forward to your feedback! + // Your insights would be invaluable. Your thoughts matter to me. // - // Thank you for your consideration! Thanks in advance for your time. + // I appreciate your attention to this matter. Your feedback is greatly appreciated. // - // Kind regards - // Milford Johnston - // jamelhaag@king.org - // (507)096-3058 + // Best wishes + // Daryl Leannon + // oceaneokuneva@roberts.org + // 1-816-608-2233 } // TemplateMarkdown examples and tests @@ -306,13 +306,13 @@ func ExampleMarkdown() { fmt.Println(string(value)) // Output: - // # PurpleSheep5 + // # PurpleSheep5 // // *Author: Amie Feil* // - // Quarterly without week it hungry thing someone. Him regularly today whomever this revolt hence. From his timing as quantity us these. Yours live these frantic not may another. How this ours his them those whose. + // Was by army party riches theirs instead. Here mine whichever that those instance growth. Has ouch enough Swiss us since down. He she aha us you to upon. How this this furniture way no play. // - // Them batch its Iraqi most that few. Abroad cheese this whereas next how there. Gorgeous genetics time choir fiction therefore yourselves. Am those infrequently heap software quarterly rather. Punctuation yellow where several his orchard to. + // Towel that us to accordingly theirs purse. Enough so though election often until eek. Weekly yet oops until conclude his stay. Elsewhere such that galaxy clean that last. Each stack reluctantly theirs wisp aid firstly. // // ## Table of Contents // - [Installation](#installation) @@ -345,13 +345,13 @@ func ExampleFaker_Markdown() { fmt.Println(string(value)) // Output: - // # PurpleSheep5 + // # PurpleSheep5 // // *Author: Amie Feil* // - // Quarterly without week it hungry thing someone. Him regularly today whomever this revolt hence. From his timing as quantity us these. Yours live these frantic not may another. How this ours his them those whose. + // Was by army party riches theirs instead. Here mine whichever that those instance growth. Has ouch enough Swiss us since down. He she aha us you to upon. How this this furniture way no play. // - // Them batch its Iraqi most that few. Abroad cheese this whereas next how there. Gorgeous genetics time choir fiction therefore yourselves. Am those infrequently heap software quarterly rather. Punctuation yellow where several his orchard to. + // Towel that us to accordingly theirs purse. Enough so though election often until eek. Weekly yet oops until conclude his stay. Elsewhere such that galaxy clean that last. Each stack reluctantly theirs wisp aid firstly. // // ## Table of Contents // - [Installation](#installation) diff --git a/word_comment.go b/word_comment.go new file mode 100644 index 00000000..3f5d3e41 --- /dev/null +++ b/word_comment.go @@ -0,0 +1,73 @@ +package gofakeit + +import ( + "math/rand" + "strings" +) + +// Comment will generate a random statement or remark expressing an opinion, observation, or reaction +func Comment() string { return comment(globalFaker.Rand) } + +// Comment will generate a random statement or remark expressing an opinion, observation, or reaction +func (f *Faker) Comment() string { return comment(f.Rand) } + +func comment(r *rand.Rand) string { + structures := [][]string{ + {"interjection", "adjective", "noun", "verb", "adverb"}, + {"noun", "verb", "preposition", "determiner", "adjective", "noun"}, + {"noun", "verb", "adverb"}, + {"adjective", "noun", "verb"}, + {"noun", "verb", "preposition", "noun"}, + } + + // Randomly select a structure + structure := structures[number(r, 0, len(structures)-1)] + + // Build the sentence + var commentParts []string + for _, wordType := range structure { + switch wordType { + case "noun": + commentParts = append(commentParts, noun(r)) + case "verb": + commentParts = append(commentParts, verb(r)) + case "adjective": + commentParts = append(commentParts, adjective(r)) + case "adverb": + commentParts = append(commentParts, adverb(r)) + case "interjection": + commentParts = append(commentParts, interjection(r)) + case "preposition": + commentParts = append(commentParts, preposition(r)) + case "determiner": + commentParts = append(commentParts, nounDeterminer(r)) + default: + // Should never hit + panic("Invalid word type") + } + } + + // Combine the words into a sentence + sentence := strings.Join(commentParts, " ") + + // Capitalize the first letter + sentence = title(sentence) + + // Add a period to the end of the sentence + sentence = sentence + "." + + return sentence +} + +func addWordCommentLookup() { + AddFuncLookup("comment", Info{ + Display: "Comment", + Category: "word", + Description: "Statement or remark expressing an opinion, observation, or reaction", + Example: "wow", + Output: "string", + Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) { + return interjection(r), nil + }, + }) +} diff --git a/word_comment_test.go b/word_comment_test.go new file mode 100644 index 00000000..bb7780a4 --- /dev/null +++ b/word_comment_test.go @@ -0,0 +1,33 @@ +package gofakeit + +import ( + "fmt" + "testing" +) + +func ExampleComment() { + Seed(11) + fmt.Println(Comment()) + + // Output: Phew Substantial Thing Had Regularly. +} + +func ExampleFaker_Comment() { + f := New(11) + fmt.Println(f.Comment()) + + // Output: Phew Substantial Thing Had Regularly. +} + +func TestComment(t *testing.T) { + f := New(11) + for i := 0; i < 1000; i++ { + f.Comment() + } +} + +func BenchmarkComment(b *testing.B) { + for i := 0; i < b.N; i++ { + Comment() + } +} diff --git a/word_general_test.go b/word_general_test.go index 59b8d180..455468e8 100644 --- a/word_general_test.go +++ b/word_general_test.go @@ -9,14 +9,14 @@ func ExampleWord() { Seed(11) fmt.Println(Word()) - // Output: there + // Output: none } func ExampleFaker_Word() { f := New(11) fmt.Println(f.Word()) - // Output: there + // Output: none } func BenchmarkWord(b *testing.B) { diff --git a/word_misc.go b/word_misc.go new file mode 100644 index 00000000..59d47e59 --- /dev/null +++ b/word_misc.go @@ -0,0 +1,24 @@ +package gofakeit + +import "math/rand" + +// Interjection will generate a random word expressing emotion +func Interjection() string { return interjection(globalFaker.Rand) } + +// Interjection will generate a random word expressing emotion +func (f *Faker) Interjection() string { return interjection(f.Rand) } + +func interjection(r *rand.Rand) string { return getRandValue(r, []string{"word", "interjection"}) } + +func addWordMiscLookup() { + AddFuncLookup("interjection", Info{ + Display: "Interjection", + Category: "word", + Description: "Word expressing emotion", + Example: "wow", + Output: "string", + Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) { + return interjection(r), nil + }, + }) +} diff --git a/word_misc_test.go b/word_misc_test.go new file mode 100644 index 00000000..48302f25 --- /dev/null +++ b/word_misc_test.go @@ -0,0 +1,26 @@ +package gofakeit + +import ( + "fmt" + "testing" +) + +func ExampleInterjection() { + Seed(11) + fmt.Println(Interjection()) + + // Output: wow +} + +func ExampleFaker_Interjection() { + f := New(11) + fmt.Println(f.Interjection()) + + // Output: wow +} + +func BenchmarkInterjection(b *testing.B) { + for i := 0; i < b.N; i++ { + Interjection() + } +} diff --git a/word_noun.go b/word_noun.go index 03f7770d..fbf9e806 100644 --- a/word_noun.go +++ b/word_noun.go @@ -111,6 +111,14 @@ func nounProper(r *rand.Rand) string { return getRandValue(r, []string{"person", "first"}) } +// NounDeterminer will generate a random noun determiner +func NounDeterminer() string { return nounDeterminer(globalFaker.Rand) } + +// NounDeterminer will generate a random noun determiner +func (f *Faker) NounDeterminer() string { return nounDeterminer(f.Rand) } + +func nounDeterminer(r *rand.Rand) string { return getRandValue(r, []string{"word", "noun_determiner"}) } + func addWordNounLookup() { AddFuncLookup("noun", Info{ Display: "Noun", @@ -221,4 +229,15 @@ func addWordNounLookup() { return nounProper(r), nil }, }) + + AddFuncLookup("noundeterminer", Info{ + Display: "Noun Determiner", + Category: "word", + Description: "Word that introduces a noun and identifies it as a noun", + Example: "your", + Output: "string", + Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) { + return nounDeterminer(r), nil + }, + }) } diff --git a/word_noun_test.go b/word_noun_test.go index fe83be3e..29d4e69b 100644 --- a/word_noun_test.go +++ b/word_noun_test.go @@ -213,3 +213,32 @@ func BenchmarkNounProper(b *testing.B) { NounProper() } } + +func ExampleNounDeterminer() { + Seed(11) + fmt.Println(NounDeterminer()) + + // Output: an +} + +func ExampleFaker_NounDeterminer() { + f := New(11) + fmt.Println(f.NounDeterminer()) + + // Output: an +} + +func TestNounDeterminer(t *testing.T) { + f := New(11) + for i := 0; i < 100; i++ { + if f.NounDeterminer() == "" { + t.Errorf("Expected a non-empty string, got nothing") + } + } +} + +func BenchmarkNounDeterminer(b *testing.B) { + for i := 0; i < b.N; i++ { + NounDeterminer() + } +} diff --git a/word_sentence_test.go b/word_sentence_test.go index 1187b6aa..b4824f8b 100644 --- a/word_sentence_test.go +++ b/word_sentence_test.go @@ -10,14 +10,14 @@ func ExampleSentence() { Seed(11) fmt.Println(Sentence(5)) - // Output: There had result everything niche. + // Output: None how these keep trip. } func ExampleFaker_Sentence() { f := New(11) fmt.Println(f.Sentence(5)) - // Output: There had result everything niche. + // Output: None how these keep trip. } func TestSentence(t *testing.T) { @@ -45,18 +45,18 @@ func ExampleParagraph() { Seed(11) fmt.Println(Paragraph(3, 5, 12, "\n")) - // Output: There had result everything niche backwards caused quarterly without week it hungry. Thing someone him regularly today whomever this revolt hence from his timing. As quantity us these yours live these frantic not may another how. This ours his them those whose them batch its Iraqi most that. Few abroad cheese this whereas next how there gorgeous genetics time choir. - // Fiction therefore yourselves am those infrequently heap software quarterly rather punctuation yellow. Where several his orchard to frequently hence victorious boxers each does auspicious. Yourselves first soup tomorrow this that must conclude anyway some yearly who. Cough laugh himself both yet rarely me dolphin intensely block would leap. Plane us first then down them eager would hundred super throughout animal. - // Yet themselves been group flock shake part purchase up usually it her. None it hers boat what their there Turkmen moreover one Lebanese to. Brace these shower in it everybody should whatever those uninterested several nobody. Yours thankful innocent power to any from its few luxury none boy. Religion themselves it there might must near theirs mine thing tonight outside. + // Output: None how these keep trip Congolese choir computer still far unless army. Party riches theirs instead here mine whichever that those instance growth has. Ouch enough Swiss us since down he she aha us you to. Upon how this this furniture way no play towel that us to. Accordingly theirs purse enough so though election often until eek weekly yet. + // Oops until conclude his stay elsewhere such that galaxy clean that last. Each stack reluctantly theirs wisp aid firstly highly butter accordingly should already. Calm shake according fade neither kuban upon this he fortnightly occasionally bunch. On who elsewhere lastly hourly right there honesty we is how result. Out Shakespearean have whom yearly another packet are behind late lot finally. + // Time themselves goodness quizzical our therefore could fact cackle yourselves zebra for. Whose enormously all bowl out wandering secondly yellow another your hourly spit. Since tomorrow hers words little think will our by Polynesian write much. Of herself uptight these composer these any firstly stack you much terribly. Over pose place sprint it child is joyously that I whom mango. } func ExampleFaker_Paragraph() { f := New(11) fmt.Println(f.Paragraph(3, 5, 12, "\n")) - // Output: There had result everything niche backwards caused quarterly without week it hungry. Thing someone him regularly today whomever this revolt hence from his timing. As quantity us these yours live these frantic not may another how. This ours his them those whose them batch its Iraqi most that. Few abroad cheese this whereas next how there gorgeous genetics time choir. - // Fiction therefore yourselves am those infrequently heap software quarterly rather punctuation yellow. Where several his orchard to frequently hence victorious boxers each does auspicious. Yourselves first soup tomorrow this that must conclude anyway some yearly who. Cough laugh himself both yet rarely me dolphin intensely block would leap. Plane us first then down them eager would hundred super throughout animal. - // Yet themselves been group flock shake part purchase up usually it her. None it hers boat what their there Turkmen moreover one Lebanese to. Brace these shower in it everybody should whatever those uninterested several nobody. Yours thankful innocent power to any from its few luxury none boy. Religion themselves it there might must near theirs mine thing tonight outside. + // Output: None how these keep trip Congolese choir computer still far unless army. Party riches theirs instead here mine whichever that those instance growth has. Ouch enough Swiss us since down he she aha us you to. Upon how this this furniture way no play towel that us to. Accordingly theirs purse enough so though election often until eek weekly yet. + // Oops until conclude his stay elsewhere such that galaxy clean that last. Each stack reluctantly theirs wisp aid firstly highly butter accordingly should already. Calm shake according fade neither kuban upon this he fortnightly occasionally bunch. On who elsewhere lastly hourly right there honesty we is how result. Out Shakespearean have whom yearly another packet are behind late lot finally. + // Time themselves goodness quizzical our therefore could fact cackle yourselves zebra for. Whose enormously all bowl out wandering secondly yellow another your hourly spit. Since tomorrow hers words little think will our by Polynesian write much. Of herself uptight these composer these any firstly stack you much terribly. Over pose place sprint it child is joyously that I whom mango. } func TestParagraph(t *testing.T) {