Business Card OCR Challenge - defined here

Overview

This gem allows you to take a new line delimited String, and pull out names, email addresses, and phone numbers. The String input can come from a file, STDIN, the output of another program, etc.

This concept has been specifically applied to business cards, but can easily be used more generically.

Installation

gem install ocr_challenge

or in your Gemfile

gem 'ocr_challenge'

Usage

1.) Create a contact with your input String

require 'ocr_challenge'
include OcrChallenge

text = """
    Alexander Vanadio\n
    [email protected]\n
    (123)-456-7890\n
"""

contact = IBusinessCardParser.get_contact_info(text)

2.) Get the information through your contact instance

contact.get_name            # =>  "Name: Alexander Vanadio"
contact.get_email_address   # => "Email: [email protected]"
contact.get_phone_number    # => "Phone: 123-456-7890"

contact.to_s # => "Name: Alexander Vanadio\nEmail: [email protected]\nPhone: 123-456-7890"

Advanced Usage

Let's use a more complicated String input. The IBusinessCard parser will attempt to find all email addresses and phone numbers, but not fax numbers. Once it does, you can get them directly from your IContactInfo instance.

require 'ocr_challenge'
include OcrChallenge

text = """
    Alexander Vanadio\n
    Software Engineer
    My Company Name
    [email protected]\n
    [email protected]\n
    Phone: 1-(123)-456-7890\n
    Cell: 123.444.7890\n
    Fax: 892-234-5467
"""

contact = IBusinessCardParser.get_contact_info(text)

contact.to_s # => "Name: Alexander Vanadio\nEmail: [email protected]\nEmail: [email protected]\nPhone Number: 123-444-7890\nPhone Number: 123-456-7890\n"

# you can also access the names, email_addresses, and phone_numbers directly
contact.names
contact.email_addresses
contact.phone_numbers

Running Tests and Code Coverage

cd orc_challenge
rspec
firefox coverage/index.html