Git Product home page Git Product logo

namey's Introduction

Namey

Namey is a ruby gem for auto-generating names. It uses the US Census Bureau database of first and last names to generate random names. Since the database itself specifies the frequency of each name, you can get specify whether you want a common name, rare name, etc.

Build Status

Usage

Using namey is pretty straightforward.

require 'namey'
@generator = Namey::Generator.new

@generator.name
 => "Maria Fisher" 

Or, to get a particular frequency level, try one of these:

@generator.name(:common)
 => "Michael Thomas" 

@generator.name(:rare)
 => "Deangelo Jotblad" 

@generator.name(:all)
 => "Emanuel Boddorf" 

You can also specify male or female to stick to one gender:

@generator.male
 => "David Gonzales" 
@generator.female
 => "Sharon Richardson" 

@generator.male(:rare)
=> "Son Plude" 

@generator.female(:rare)
=> "Blossom VanWie" 

NOTE: All these methods default to returning common names unless you specify a different level.

Finally, you can specify true/false as the second parameter to any call to specify if you want a surname:

@generator.male(:common, false)
 => "Michael" 
@generator.male(:common, false)
 => "William" 

Finally, you can access the generate method directly and specify min_freq and max_freq to get a range of names:

# a somewhat rare name
@generator.generate(:type => :male, :with_surname => true, :min_freq => 80, :max_freq => 100)
 => "Salvatore Billard" 

# a more rare name
@generator.generate(:type => :male, :with_surname => true, :min_freq => 90, :max_freq => 100)
=> "Broderick Burhanuddin" 

# a common name
@generator.generate(:type => :male, :with_surname => true, :min_freq => 0, :max_freq => 5)
=> "James Davis" 

# another common name
@generator.generate(:type => :female, :with_surname => true, :min_freq => 0, :max_freq => 5)
=> "Linda Williams"

Data

Namey comes with a pre-loaded SQLite database. However, you can specify a different datasource when initializing the gem:

@generator = Namey::Generator.new("mysql://username:passwrd@host/database")

Namey uses Sequel to access data, and is tested with both MySQL and SQLite. It might need some tweaking to work with other engines.

If you want to fiddle around with the data, you can check out Namey::Importer, or the namey-load-data script included with the gem, which will generate the database from the original source files.

Capitalization

The data from the Census Bureau is in all caps, it looks a lot like this:

SMITH          1.006  1.006      1
JOHNSON        0.810  1.816      2
WILLIAMS       0.699  2.515      3
JONES          0.621  3.136      4
BROWN          0.621  3.757      5

That's fine with basic names, but names with more than one capital in them are challenging. The data is also stripped of apostrophes, so O'Brien is actually OBRIEN. The namey parser attempts to correct some of this, but it probably misses some. If you find any glaring examples, just let me know.

namey's People

Contributors

chewi avatar muffinista avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

namey's Issues

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

  spec.license = 'MIT'
  # or
  spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Sequel::DatabaseConnectionError: SQLite3::CantOpenException: unable to open database file

Just gem install namey'd a minute ago and tried it out, but this is what happened:

[1] pry(main)> require 'namey'
=> true
[2] pry(main)> @g=Namey::Generator.new
=> #<Namey::Generator:0x39c0d08
 @db=
  #<Sequel::SQLite::Database: "sqlite://C:/Ruby193/lib/ruby/gems/1.9.1/gems/namey-0.0.8/lib/../data/names.db">>
[3] pry(main)> @g.name
Sequel::DatabaseConnectionError: SQLite3::CantOpenException: unable to open database file
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sequel-4.0.0/lib/sequel/adapters/sqlite.rb:101:in `initialize'

Is what I'm doing wrong obvious from something in there, or...?

cross domain access violatin

when using the javascript api you're hosting it started giving cross domain access violation errors recently.

No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.