0.0
No commit activity in last 3 years
No release in over 3 years
This gem allows you to parse text blobs to find names, email addresses, and phone numbers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.4
~> 2.99
~> 0.9
 Project Readme

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
    execdd17@gmail.com\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: execdd17@gmail.com"
contact.get_phone_number    # => "Phone: 123-456-7890"

contact.to_s # => "Name: Alexander Vanadio\nEmail: execdd17@gmail.com\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
    execdd17@gmail.com\n
    anotherEmail@gmail.com\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: anotherEmail@gmail.com\nEmail: execdd17@gmail.com\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               # => ["Alexander Vanadio"]
contact.email_addresses     # => ["anotherEmail@gmail.com", "execdd17@gmail.com"]
contact.phone_numbers       # => ["123-444-7890", "123-456-7890"]

Running Tests and Code Coverage

cd ocr_challenge
rspec
firefox coverage/index.html