randomperson 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest ADDED
@@ -0,0 +1,31 @@
1
+ Manifest
2
+ README
3
+ Rakefile
4
+ lib/Choice.rb
5
+ lib/Generator.rb
6
+ lib/NameFiles/AmericanLast.rb
7
+ lib/NameFiles/AmericanMaleFirst.rb
8
+ lib/NameFiles/AmericanSuffix.rb
9
+ lib/NameFiles/AnyLast.rb
10
+ lib/NameFiles/BasqueLast.rb
11
+ lib/NameFiles/EnglishFemaleFirst.rb
12
+ lib/NameFiles/EnglishLast.rb
13
+ lib/NameFiles/EnglishPrefix.rb
14
+ lib/NameFiles/SpanishFemaleFirst.rb
15
+ lib/NameFiles/SpanishLast.rb
16
+ lib/NameFiles/SpanishMaleFirst.rb
17
+ lib/NameFiles/ThaiFirst.rb
18
+ lib/NameFiles/ThaiRomanisedFemaleFirst.rb
19
+ lib/NameFiles/ThaiRomanisedLast.rb
20
+ lib/NameFiles/ThaiRomanisedMaleFirst.rb
21
+ lib/Names.rb
22
+ lib/Person.rb
23
+ lib/Ratio.rb
24
+ lib/ext/Array.rb
25
+ lib/ext/Date.rb
26
+ lib/ext/Enumerable.rb
27
+ lib/ext/Hash.rb
28
+ lib/ext/Kernel.rb
29
+ lib/ext/Set.rb
30
+ lib/randomperson.rb
31
+ t/Generator.t
data/README ADDED
@@ -0,0 +1,220 @@
1
+ =RandomPerson
2
+
3
+ A port to Ruby of Perl's Data::RandomPerson.
4
+
5
+ http://search.cpan.org/~peterhi/Data-RandomPerson-0.4/
6
+
7
+ Initially just the Names portion. In fact, probably just that. I'm not a masochist. Well, just a bit.
8
+
9
+ ==Why did I write this?
10
+
11
+ Because the Faker library and a few of the other random ones are very good, but they don't have the precision I needed. I wanted believable male names between a certain age range for a football game I was writing. Producing names like Mrs Albert Wiggins wasn't really going to cut it.
12
+
13
+ And I'm a masochist.
14
+
15
+ It also has unicode characters, so it'll give your database a real test.
16
+
17
+
18
+ ==USAGE (STOP SHOUTING!):
19
+
20
+ So, to generate 1000 random people with Spanish names, between the ages of 16 and 35 with a ratio of 3 males to every 5 females:
21
+
22
+ require 'randomperson'
23
+
24
+ choice = RandomPerson::Choice.new( {gender_ratio: [3,5] , age_lower:16, age_upper:35 } )
25
+
26
+ choice.add_Spanish
27
+
28
+ g = RandomPerson::Generator.new
29
+
30
+ g.make_generator choice
31
+
32
+ people = [ ]
33
+
34
+ 1000.times { people << g.generators[0].call }
35
+
36
+ 10.times { |i| puts "#{people[i].first} #{people[i].last} age: #{people[i].age} born: #{people[i].dob.strftime("%d-%b-%Y")}" }
37
+
38
+ Bartolomé Andrés de Elixaeberna age: 20 born: 28-Apr-1990
39
+ Fabiana Cordero Balmaceda age: 21 born: 14-Jun-1989
40
+ Jorge Alas Albarracin age: 29 born: 16-Apr-1981
41
+ Eufemia Berlanga de Sergi age: 33 born: 25-Jan-1977
42
+ David Puig Villaroel age: 19 born: 17-Apr-1991
43
+ Alba Henchoz de Hurtado age: 30 born: 14-Feb-1980
44
+ Natalia Jara de Guevara age: 33 born: 28-Jul-1977
45
+ Tito Cresaco Campo age: 20 born: 14-Feb-1990
46
+ Susana Pitillas de Vaime age: 32 born: 12-Aug-1978
47
+ Gustavo Hierro Carbajal y Plazas age: 31 born: 08-Feb-1979
48
+
49
+ Here's an example using the Thai Romanised data:
50
+
51
+ choice = RandomPerson::Choice.new
52
+ choice.add_Thai_Romanised
53
+ g = RandomPerson::Generator.new
54
+ g.make_generator choice
55
+ people = [ ]
56
+ 10.times { people << g.generators[0].call }
57
+ 10.times { |i| puts "#{people[i].first} #{people[i].last} age: #{people[i].age} born: #{people[i].dob.strftime("%d-%b-%Y")}" }
58
+
59
+ Yongchaiyuth Sripituksakul Puntasrima age: 39 born: 29-Mar-1971
60
+ Sri-Patana Wattanasin age: 77 born: 04-Feb-1933
61
+ Wattana Rojjanasukchai age: 7 born: 27-Jun-2003
62
+ Ban Sukbunsung age: 85 born: 07-Sep-1925
63
+ Daeng Prasongsanti age: 65 born: 27-Mar-1945
64
+ Proi Paowsong Sriwarunyu age: 60 born: 06-May-1950
65
+ Ban Yongjaiyut age: 4 born: 06-Nov-2006
66
+ Siam Narkhirunkanok age: 15 born: 12-Aug-1995
67
+ Tong Punyawong Kadesadayurat age: 64 born: 01-Sep-1946
68
+ Sarai Wattanapanit Maneerattana age: 44 born: 21-Dec-1966
69
+
70
+ ==CHOICE
71
+
72
+ The choice class sets the parameters that will be used to generate people.
73
+
74
+ choice = RandomPerson::Choice.new
75
+
76
+ is the same as
77
+
78
+ choice = RandomPerson::Choice.new( gender_ratio:[1,1] , age_lower: 0, age_upper: 100 )
79
+
80
+ So you'd end up with a population of roughly 50:50 male/female with ages from 0 to 100 years.
81
+
82
+ ==LOADING NAMEFILES
83
+
84
+ choice.add_Spanish_Female would just load the SpanishFemaleFirst into choice.female
85
+
86
+ choice.add_Spanish would load:
87
+ SpanishFemaleFirst into choice.female
88
+ SpanishMaleFirst into choice.male
89
+ SpanishLast into choice.last
90
+ etc etc
91
+
92
+ or you can do things the old fashioned way
93
+
94
+ require 'namefiles/spanishfemalefirst' #obviously you need to use the path from where you are or where the script will run from
95
+
96
+ choice.female = RandomPerson::SpanishFemaleFirst.new
97
+
98
+ The rule is, put_underscores_between_the_important_words
99
+
100
+ _and_
101
+
102
+ always begin with *add_*
103
+
104
+ If you want EnglishLast names loaded:
105
+
106
+ choice.add_English_Last
107
+
108
+ All English files:
109
+
110
+ choice.add_English
111
+
112
+ English males:
113
+
114
+ choice.add_English_Male
115
+
116
+
117
+ Do you see how this is working? If you need to check what's loaded, have a look in the instance variables of choice (or whatever you named your Choice instance):
118
+
119
+ choice.male
120
+ choice.female
121
+ choice.last
122
+ choice.prefix
123
+ choice.suffix
124
+
125
+ ==RATIOS VS ODDS
126
+
127
+ The default gender ratio is 1:1. The male part is the left side (or Array#first), the female is the right side (or Array#last). All ratios are given as an array i.e. [1,1] or [3,2]
128
+
129
+ A ratio of 1:1 will not necessarily give you a population with exactly half male, half female. The ratio is the odds of getting that. So a ratio of [1,3] will give a 25% chance of producing a male and a 75% chance of being a female.
130
+
131
+ If you wish to have an exact ratio within the population then create two choices each with a 0% chance of producing the other. For example:
132
+
133
+ men = RandomPerson::Choice.new( gender_ratio:[1,0] )
134
+ women = RandomPerson::Choice.new( gender_ratio:[0,1] )
135
+ ...more code here...
136
+ g.make_generator men # pushes the generator onto @generators in 0 position
137
+ g.make_generator women # pushes the generator onto @generators in 1 position
138
+ 25.times { people << g.generators[0].call }
139
+ 75.times { people << g.generators[1].call }
140
+
141
+ This would give you a population of 25 males and 75 females. Which sounds great unless you really think about it.
142
+
143
+ ==FORMATTING
144
+
145
+ Each culture has it's own conventions around names. This makes sticking some monolithic algorithm in the centre of the code to sort out how names should be displayed impossible, so each data file describes how it thinks the names should be formatted.
146
+
147
+ For example, in the EnglishLast.rb file:
148
+
149
+ @formats = {
150
+ :single => ->(n) { n.rand },
151
+ :double_barrelled_hyphenated=> ->(n) { n.rand + '-' + n.rand },
152
+ }
153
+
154
+ This tells us that there are two ways of formatting last names defined in the file. All formats are described as lambda functions in a hash, the key being a description of what it's trying to achieve.
155
+
156
+ ==BIT MORE ON RATIOS
157
+
158
+ Behind the scenes, ratios like this [1,3] are converted to an array of ranges like this [0..24, 25..99], called ratiod. Just so you know for this next bit.
159
+
160
+ In the EnglishLast.rb file:
161
+ @formats_ratiod = [ (0..96), (97..99) ]
162
+
163
+ This says that the chances of a name being single barrelled is 97%, and double barrelled is 3%. I made up those figures from my own experience, but if you disagree with either the ratios or the formatting then you can change it. Either directly in the file or while running the code. It's your choice. Just make sure the numbers are right, length of arrays should be the same ( e.g. four formatting options should have a ratio with four parts like [a,b,c,d]) or it will break.
164
+
165
+ ==PREFIXES AND SUFFIXES
166
+
167
+ Each generator starts by producing a person with a gender, an age and a date of birth. These are then passed on to the subsequent name portions so that a male always gets a male name and a male prefix (if you've specified a prefix file).
168
+
169
+ Suffix files will also (I hope) do a bit of checking at what's already been set, so you won't get Dr. Bobby Horliton PhD, as it should be either Dr. or PhD (apparently). Stuff like that should get caught.
170
+
171
+ ==ADDING YOUR OWN NAMEFILES
172
+
173
+ My suggestion is to find the type of name that is closest (if you're looking for Spanishy names then look at the Spanish files as they'll have similar formatting rules there for free...) and copy and paste it in to a new one. It's easier that way.
174
+
175
+ ==ACCURACY OF NAMES AND RATIOS
176
+
177
+ I've taken bits and pieces from wherever I could get them, so if you see something is wrong then either let me know or produce a patch. I've no idea what the process is for that on GitHub but I'm sure there's a tutorial if you look for it. I'll also add you name to this readme, and worldly fame will be yours.
178
+
179
+ ==TODO:
180
+
181
+ There's lots to do. Lot of repetition and ugly bits here and there, but it works so I'll get round to it when I can.
182
+
183
+ *Iain Barnett*
184
+
185
+ ==LICENCE:
186
+
187
+ It's an MIT Licence, I didn't take any code from the Perl one just names and a slight idea on how to structure things, so this ain't gonna be under the GPL. MIT is better anyway ;)
188
+
189
+ Copyright (c) 2010 Iain Barnett
190
+
191
+ Permission is hereby granted, free of charge, to any person obtaining a copy
192
+ of this software and associated documentation files (the "Software"), to deal
193
+ in the Software without restriction, including without limitation the rights
194
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
195
+ copies of the Software, and to permit persons to whom the Software is
196
+ furnished to do so, subject to the following conditions:
197
+
198
+ The above copyright notice and this permission notice shall be included in
199
+ all copies or substantial portions of the Software.
200
+
201
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
202
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
203
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
204
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
205
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
206
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
207
+ THE SOFTWARE.
208
+
209
+ In other words, be good.
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'rake'
2
+ require 'echoe'
3
+ # require 'rake/testtask'
4
+
5
+ Echoe.new('randomperson', '0.0.1') do |p|
6
+ p.description = "A gem for generating random persons"
7
+ p.url = "http://github.com/yb66/RandomPerson"
8
+ p.author = "Iain Barnett"
9
+ p.email = "iainspeed @nospam@ gmail.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ p.runtime_dependencies = []
13
+ p.ruby_version = ">= 1.9.1"
14
+ end
15
+
16
+ # task :default => [:test_units]
17
+ #
18
+ # desc "Run basic tests"
19
+ # Rake::TestTask.new("test_units") { |t|
20
+ # t.pattern = 't/*.t'
21
+ # t.verbose = true
22
+ # t.warning = true
23
+ # }
data/lib/Choice.rb ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ require 'set'
4
+ module RandomPerson
5
+
6
+ class Choice
7
+
8
+ attr_accessor :malefirst, :femalefirst, :last, :gender_ratio, :age_lower, :age_upper, :dob, :prefix, :suffix #,:age_ratio
9
+
10
+ def available_classes
11
+ @@available_classes
12
+ end
13
+
14
+ @@available_classes = Set.new
15
+
16
+ def initialize( h={} )
17
+ @gender_ratio = h[:gender_ratio] || [1,1] #default
18
+ @age_lower = h[:age_lower] || 0
19
+ @age_upper = h[:age_upper] || 100
20
+
21
+ load_names
22
+ end
23
+
24
+ def load_names( patterns=['*.rb'] )
25
+ # puts "patterns: #{patterns}"
26
+ # available_files = [ ]
27
+ lib_dir = File.dirname(__FILE__)
28
+
29
+ patterns.each do |pat|
30
+ full_pattern = File.join( lib_dir, 'NameFiles', pat )
31
+ puts full_pattern
32
+ Dir.glob( full_pattern ).each do |file|
33
+ # require file
34
+ @@available_classes << file
35
+ end
36
+ end
37
+ end
38
+
39
+ # tribe, gender, position
40
+ #English_males
41
+ def method_missing( name, *args )
42
+ return super( name, *args ) unless name.to_s =~ /^add/
43
+ words = name.to_s.split( "_" )
44
+ words.shift #get rid of the "add"
45
+ #TODO: check the beginning of each word has an uc letter
46
+ cs = words.map { |word| @@available_classes.classify_true(word) }.fold(:&)
47
+
48
+ cs.each do |c|
49
+ require c
50
+ fn = File.basename( c, File.extname( c ) ) #remove the extension
51
+ addklass( fn, %w{ Male First } )
52
+ addklass( fn, %w{ Female First } )
53
+ addklass( fn, %w{ Last } )
54
+ addklass( fn, %w{ Prefix } )
55
+ addklass( fn, %w{ Suffix } )
56
+ end
57
+ end
58
+
59
+
60
+ def addklass( fn, ps )
61
+ if ps.map { |p| fn =~ /#{p}/ }.all?
62
+ instance_variable_set( "@#{ps.join.downcase}", qualified_const_get(fn).new )
63
+ end
64
+ end
65
+
66
+
67
+ # while n > 0
68
+ # r = rand(rat.last.last)
69
+ # puts "n: #{n} r: #{r}"
70
+ # i = rat.index_in_range( r )
71
+ # puts "i: #{i}"
72
+ #
73
+ # person = @choices[i].call
74
+ # puts person.inspect
75
+ # @people << person
76
+ # n -= 1
77
+ # end
78
+
79
+
80
+ end
81
+
82
+ end
data/lib/Generator.rb ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ require 'date'
4
+ require 'person'
5
+
6
+ module RandomPerson
7
+
8
+ class Generator
9
+
10
+ attr_reader :generators
11
+
12
+ def initialize
13
+ @generators = [ ]
14
+ end
15
+
16
+
17
+ #build a choice generator
18
+ def make_generator( choice )
19
+ f = -> {
20
+ g = Generator.pick_gender( choice.gender_ratio )
21
+ age = Generator.pick_age( choice.age_lower, choice.age_upper)
22
+
23
+ person = Person.new(
24
+ :gender => g,
25
+ :age => age,
26
+ :dob => Generator.pick_dob( age )
27
+ )
28
+
29
+ if person.gender == 'm'
30
+ person.first = choice.malefirst.execute( person ) unless choice.malefirst.nil?
31
+ else
32
+ person.first = choice.femalefirst.execute( person ) unless choice.femalefirst.nil?
33
+ end
34
+
35
+ person.last = choice.last.execute( person ) unless choice.last.nil?#lastname,
36
+ person.prefix = choice.prefix.execute( person ) unless person.prefix.nil? #title
37
+ person.suffix = choice.suffix.execute( person ) unless person.suffix.nil?#suffix
38
+
39
+ person
40
+ }
41
+
42
+ @generators << f
43
+ end
44
+
45
+ class << self
46
+
47
+ #create a ratio that is made up of ranges
48
+ #to help hit with multiple valued ratios
49
+ def ratiod( ratio=[1,1] )
50
+ sum = ratio.reduce(:+) #sum
51
+ mult = 100.divmod( sum ).first #get a bigger spread of numbers
52
+ ratio.map! { |n| n * mult }
53
+ new_ratio = ratio.inject([0..0]) {|acc,n| acc + [acc.last.last ... (n + acc.last.last)] }
54
+ new_ratio.shift #get rid of 0..0
55
+ return new_ratio
56
+ end
57
+
58
+ def pick_gender( ratio=[1,1] ) #male first
59
+ if ratio.length == 2
60
+ return 'f' if ratio.first == 0
61
+ return 'm' if ratio.last == 0
62
+ end
63
+ rat = ratiod( ratio )
64
+ r = rand(rat.last.last)
65
+ case r
66
+ when rat[0] then 'm'
67
+ when rat[1] then 'f'
68
+ end
69
+ end
70
+
71
+ def pick_age( lower=0, upper=100 )
72
+ age = rand(upper - lower) + lower
73
+ end
74
+
75
+ def pick_dob( y=16 )
76
+ year = Time.now.year - y
77
+ month = rand(12) + 1;
78
+ day = rand( Date.days_in_month( year, month ) ) + 1
79
+ Time.local( year, month, day )
80
+ end
81
+
82
+
83
+ end #class << self
84
+
85
+
86
+
87
+
88
+
89
+ def reset
90
+ @generator = [ ]
91
+ end
92
+
93
+
94
+
95
+ end
96
+
97
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ module RandomPerson
4
+
5
+ require 'Names'
6
+
7
+ class AmericanLast
8
+ include Names
9
+
10
+ #def names() NAMES; end
11
+
12
+ FORMATS = {
13
+ :single => ->(n) { n.rand },
14
+ :double_barrelled => ->(n) { n.rand + ' ' + n.rand },
15
+ :double_barrelled_hyphenated=> ->(n) { n.rand + '-' + n.rand },
16
+ }
17
+
18
+ FORMATS_RATIOD = [ (0..95), (96..97), (98..99) ]
19
+
20
+ # TODO!!!!!!
21
+ # def execute( person, format=nil, format_ratio=nil )
22
+ # format = FORMATS[:single] if format.nil?
23
+ # # puts format.inspect
24
+ # format.( NAMES )
25
+ # end
26
+
27
+ def execute( person, format=nil )
28
+ Names.execute( NAMES )
29
+ end
30
+
31
+ NAMES = %w(adams adamson adler akers akin aleman alexander allen allison allwood anderson andreou anthony appelbaum applegate arbore arenson armold arntzen askew athanas atkinson ausman austin averitt avila badders baer baggerly bailliet baird baker ball ballentine ballew banks baptist barbee barber barchas barcio bardsley barkauskas barnes barnett barnwell barrera barreto barroso barrow bart barton bass bates bavinger baxter bazaldua becker beeghly belforte bellamy bellavance beltran belusar bennett benoit bensley berger berggren bergman berry bertelson bess beusse bickford bierner bird birdwell bixby blackmon blackwell blair blankinship blanton block blomkalns bloomfield blume boeckenhauer bolding bolt bolton book boucher boudreau bowman boyd boyes boyles braby braden bradley brady bragg brandow brantley brauner braunhardt bray bredenberg bremer breyer bricout briggs brittain brockman brockmoller broman brooks brown brubaker bruce brumfield brumley bruning buck budd buhler buhr burleson burns burton bush butterfield byers byon byrd bzostek cabrera caesar caffey caffrey calhoun call callahan campbell cano capri carey carlisle carlson carmichael carnes carr carreira carroll carson carswell carter cartwright cason cates catlett caudle cavallaro cave cazamias chabot chance chapman characklis cheatham chen chern cheville chong christensen church claibourn clark clasen claude close coakley coffey cohen cole collier conant connell conte conway cooley cooper copeland coram corbett cort cortes cousins cowsar cox coyne crain crankshaw craven crawford cressman crestani crier crocker cromwell crouse crowder crowe culpepper cummings cunningham currie cusey cutcher cyprus d'ascenzo dabak dakoulas daly dana danburg danenhauer darley darrouzet dartt daugherty davila davis dawkins day dehart demoss demuth devincentis deaton dees degenhardt deggeller deigaard delabroy delaney demir denison denney derr dettweiler deuel devitt diamond dickinson dietrich dilbeck dobson dodds dodson doherty dooley dorsey dortch doughty dove dowd dowling drescher drucker dryer dryver duckworth dunbar dunham dunn duston dyson eason eaton ebert eckhoff edelman edmonds eichhorn eisbach elders elias elijah elizabeth elliott elliston elms emerson engelberg engle eplett epp erickson estades etezadi evans ewing fair farfan fargason farhat farry fawcett faye federle felcher feldman ferguson fergusson fernandez ferrer fine fineman fisher flanagan flathmann fleming fletcher folk fortune fossati foster foulston fowler fox francis frantom franz frazer fredericks frey freymann fuentes fuller fundling furlong gainer galang galeazzi gamse gannaway garcia gardner garneau gartler garverick garza gatt gattis gayman geiger gelder george gerbino gerbode gibson gifford gillespie gillingham gilpin gilyot girgis gjertsen glantz glaze glenn glotzbach gobble gockenbach goff goffin golden goldwyn gomez gonzalez good graham gramm granlund grant gray grayson greene greenslade greenwood greer griffin grinstein grisham gross grove guthrie guyton haas hackney haddock hagelstein hagen haggard haines hale haley hall halladay hamill hamilton hammer hancock hane hansen harding harless harms harper harrigan harris harrison hart harton hartz harvey hastings hauenstein haushalter haven hawes hawkins hawley haygood haylock hazard heath heidel heins hellums hendricks henry henson herbert herman hernandez herrera hertzmann hewitt hightower hildebrand hill hindman hirasaki hirsh hochman hocker hoffman hoffmann holder holland holloman holstein holt holzer honeyman hood hooks hopper horne house houston howard howell howley huang hudgings huffman hughes humphrey hunt hunter hurley huston hutchinson hyatt irving jacobs jaramillo jaranson jarboe jarrell jenkins johnson johnston jones joy juette julicher jumper kabir kamberova kamen kamine kampe kane kang kapetanovic kargatis karlin karlsson kasbekar kasper kastensmidt katz kauffman kavanagh kaydos kearsley keleher kelly kelty kendrick key kicinski kiefer kielt kim kimmel kincaid king kinney kipp kirby kirk kirkland kirkpatrick klamczynski klein kopnicky kotsonis koutras kramer kremer krohn kuhlken kunitz lalonde lavalle laware lacy lam lamb lampkin lane langston lanier larsen lassiter latchford lawera leblanc legrand leatherbury lebron ledman lee leinenbach leslie levy lewis lichtenstein lisowski liston litvak llano lloyd lock lodge logan lomonaco long lopez lopez loren loughridge love ludtke luers lukes luxemburg macallister macleod mackey maddox magee mallinson mann manning manthos marie marrow marshall martin martinez martisek massey mathis matt maxwell mayer mazurek mcadams mcafee mcalexander mcbride mccarthy mcclure mccord mccoy mccrary mccrossin mcdonald mcelfresh mcfarland mcgarr mcghee mcgoldrick mcgrath mcguire mckinley mcmahan mcmahon mcmath mcnally mcdonald meade meador mebane medrano melton merchant merwin millam millard miller mills milstead minard miner minkoff minnotte minyard mirza mitchell money monk montgomery monton moore moren moreno morris morse moss moyer mueller mull mullet mullins munn murdock murphey murphy murray murry mutchler myers myrick nassar nathan nazzal neal nederveld nelson nguyen nichols nielsen nockton nolan noonan norbury nordlander norris norvell noyes nugent nunn o'brien o'connell o'neill o'steen ober odegard oliver ollmann olson ongley ordway ortiz ouellette overcash overfelt overley owens page paige pardue parham parker parks patterson patton paul payne peck penisson percer perez perlioni perrino peterman peters pfeiffer phelps philip philippe phillips pickett pippenger pistole platzek player poddar poirier poklepovic polk polking pond popish porter pound pounds powell powers prado preston price prichep priour prischmann pryor puckett raglin ralston rampersad ratner rawles ray read reddy reed reese reeves reichenbach reifel rein reiten reiter reitmeier reynolds rhinehart richardson rider ritchie rittenbach roberts robinson rodriguez rogers roper rosemblun rosen rosenberg rosenblatt ross roth rowatt roy royston rozendal rubble ruhlin rupert russell ruthruff ryan rye sabry sachitano sachs sammartino sands saunders savely scales schaefer schafer scheer schild schlitt schmitz schneider schoenberger schoppe scott seay segura selesnick self seligmann sewall shami shampine sharp shaw shefelbine sheldon sherrill shidle shifley shillingsburg shisler shopbell shupack sievert simpson sims sissman smayling smith snyder solomon solon soltero sommers sonneborn sorensen southworth spear speight spencer spruell spudich stacy staebel steele steinhour steinke stepp stevens stewart stickel stine stivers stobb stone stratmann stubbers stuckey stugart sullivan sultan sumrall sunley sunshine sutton swaim swales sweed swick swift swindell swint symonds syzdek szafranski takimoto talbott talwar tanner taslimi tate tatum taylor tchainikov terk thacker thomas thompson thomson thornton thurman thurow tilley tolle towns trafton tran trevas trevino triggs truchard tunison turner twedell tyler tyree unger van vanderzanden vanlandingham varanasi varela varman venier verspoor vick visinsky voltz wagner wake walcott waldron walker wallace walters walton ward wardle warnes warren washington watson watters webber weidenfeller weien weimer weiner weinger weinheimer weirich welch wells wendt west westmoreland wex whitaker white whitley wiediger wilburn williams williamson willman wilson winger wise wisur witt wong woodbury wooten workman wright wyatt yates yeamans yen york yotov younan young zeldin zettner ziegler zitterkopf zucker)
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ module RandomPerson
4
+
5
+ require 'Names'
6
+
7
+ class AmericanMaleFirst
8
+ include Names
9
+
10
+ def execute( person, format=nil )
11
+ Names.execute( NAMES )
12
+ end
13
+
14
+ # def names( ) NAMES; end
15
+
16
+ NAMES = %w{ aaron adam adrian alan alejandro alex allen andrew andy anthony art arthur barry bart ben benjamin bill bobby brad bradley brendan brett brian bruce bryan carlos chad charles chris christopher chuck clay corey craig dan daniel darren dave david dean dennis denny derek don doug duane edward eric eugene evan frank fred gary gene george gordon greg harry henry hunter ivan jack james jamie jason jay jeff jeffrey jeremy jim joe joel john jonathan joseph justin keith ken kevin larry logan marc mark matt matthew michael mike nat nathan patrick paul perry peter philip phillip randy raymond ricardo richard rick rob robert rod roger ross ruben russell ryan sam scot scott sean shaun stephen steve steven stewart stuart ted thomas tim toby todd tom troy victor wade walter wayne william }
17
+
18
+ # FORMATS = {
19
+ # :single => ->(n) { n.rand }
20
+ # }
21
+
22
+
23
+ # format = FORMATS[:single] if format.nil?
24
+ # # puts format.inspect
25
+ # # format.( @NAMES )
26
+ # NAMES.rand
27
+ # end
28
+
29
+
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby -wKU
2
+
3
+ module RandomPerson
4
+ require 'Names'
5
+ class AmericanSuffix
6
+ include Names
7
+
8
+
9
+ SUFFIX = [ 'Jr.', ''] + %w( I II III IV V Sr. )
10
+ SUFFIX_ratiod = [ 0, 1..93, 94, 95, 96, 97, 98, 99]
11
+
12
+ def execute( person, format=nil)
13
+
14
+ r = rand(99)
15
+ if person.age > 17
16
+ r += 1 #Jr can't happen
17
+ end
18
+
19
+ i = SUFFIX_ratiod.index_in_range( r )
20
+ return SUFFIX[i]
21
+ end
22
+
23
+ end
24
+ end