Simple but flexible and powerful utility for generating random names and identifiers - with configurable number of components, separators, length and structure, usable in a single line of code.
Get it from NuGet: https://www.nuget.org/packages/RandomFriendlyNameGenerator
Try it out:
https://namegenerator.azurewebsites.net/api/GetName
https://namegenerator.azurewebsites.net/api/GetNames/10 (if you want to get 10 names)
or with more params
https://namegenerator.azurewebsites.net/api/GetNames/10?template=BobTheBuilder&orderStyle=BobTheBuilderStyle&separator=-
*This is not guaranteed service, i.e. this AzureFunction might get disabled without notice
In all methods you can specify the separator, the length restriction and whether generated words should all start with a single character (i.e. alliteration).
Also, each method has an overload which returns an IEnumerable instead of a single string.
Get a simple random human-like name:
string name = NameGenerator.PersonNames.Get();
returns a single random name & surname, similar to below:
- Jeana Chalow
- Jaine Bobson
- Godfrey Manning
For any method you can specify additional settings and parameters related to the name format, e.g:
IEnumerable<string> names = NameGenerator.PersonNames.Get(5, NameGender.Male, NameComponents.FirstNameMiddleNameLastName);
returns:
- Byron Lorenzo Haan
- Timmy Evan Swimm
- Darin Demetris Kurshuk
or
var names = NameGenerator.PersonNames.Get(5, NameGender.Female, NameComponents.LastNameFirstName, separator: ", ");
which returns:
- Bloss, Suzanna
- Parkinson, Carline
- Boegel, Jacklin
Get a simple random identifier:
string name = NameGenerator.Identifiers.Get();
returns a single random adjective & noun, similar to below:
- Adrenalized Soup
- Informed Confusion (yup, that got generated)
- Unpromising Graduation
For any method you can specify additional settings and parameters, to control the output e.g:
var names = NameGenerator.Identifiers.Get(5, IdentifierComponents.FirstName | IdentifierComponents.Animal);
returns:
- SavannaBaboon Zollie
- Mastodon Rubi
- Rooster Hewet
or take more components and set the name to be first (a.k.a Bob The Builder style)
NameGenerator.Identifiers.Get(15, IdentifierComponents.FirstName | IdentifierComponents.Adjective | IdentifierComponents.Animal, NameOrderingStyle.BobTheBuilderStyle);
which returns:
- Morton The Unfriendly Crocodile
- Ki The Skilled Cuckoo
- Dacey The Illicit Labradoodle
or do something similar to Docker containers names, but with a very short strings
NameGenerator.Identifiers.Get(15, IdentifierComponents.Adjective | IdentifierComponents.Noun, separator: "_", lengthRestriction: 10);
which returns:
- Spare_Host
- Human_Vase
- Mad_Clue
- Cocky_Bait
or you can go wild with picking any two random components and force them all to be alliterated
NameGenerator.Identifiers.Get(15,IdentifierTemplate.AnyTwoComponents, separator: "", forceSingleLetter: true);
which returns:
- BelgianBen
- KitchenKorella
- FinancialFerret
- CameroonianChane
- FilipinoFinisher
- NonexclusiveNoodle
- FleetingFrank
- ElectricityEwan
- InscrutableInstructor
or use one of the predefined templates, e.g.
NameGenerator.Identifiers.Get(5, IdentifierTemplate.BobTheBuilder);
NameGenerator.Identifiers.Get(5, IdentifierTemplate.SilentBob);
NameGenerator.Identifiers.Get(5, IdentifierTemplate.GitHub);
etc.
(The latest values for the info below are available in the 'Showcase' class in the tests project)
At the moment the lists of words contain the following numbers:
- Adjectives: 4841
- Nationalities: 186
- FemaleFirstNames: 5047
- MaleFirstNames: 3025
- LastNames: 88799
- Animals: 1160
- Nouns: 5916
- Professions: 411 Total of 109385 words. Unique words: 104049
(The latest values for the info below are available in the 'UniquenessTests' class in the tests project)
Code below, executed in loops of 100 000 and 1 000 000 times yields following results (they include overhead of adding strings to list)
NameGenerator.Identifiers.Get(IdentifierTemplate.AnyThreeComponents, NameOrderingStyle.BobTheBuilderStyle)
Generated 100 000. Duplicates: 1. Duplicates percentage: 0.00100. Elapsed: 329ms
Generated 100 000. Duplicates: 0. Duplicates percentage: 0. Elapsed: 408ms
Generated 100 000. Duplicates: 1. Duplicates percentage: 0.00100. Elapsed: 374ms
Generated 1 000 000. Duplicates: 51. Duplicates percentage: 0.005100. Elapsed: 3440ms
Generated 1 000 000. Duplicates: 49. Duplicates percentage: 0.004900. Elapsed: 3138ms
Generated 1 000 000. Duplicates: 33. Duplicates percentage: 0.003300. Elapsed: 3362ms
All very welcome, I am happy to accept pull requests with clean and tested code :):)