Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:23:01+00:00 2026-05-27T16:23:01+00:00

I’m working on a program that does OCR on a US business card and

  • 0

I’m working on a program that does OCR on a US business card and tries to return information like first name, last name, etc. The challenge is how to do that.

So far I’ve built the following data files:

first_names.txt  (Contains 23k+ first names)
last_names.txt (Contains 86k+ last names)
job_title.txt (Contains 500+ job titles)
us_cities.txt (Contains 10k+ us cities)
states_full.txt (Contains full names of all US states)
states_abv.txt  (Contains all US state abbreviations)

The goal was for me to tokenize the OCR data by spaces and try to award “weight” to each string based on the likeliness of it being a certain type of data.

For example, a string earlier in the text blob is more likely to be the name, company, or title. Likewise, if a string is found in first_names.txt or last_names.txt, then it will have more weight towards first/last name.

This approach sounds ok in theory, but I’m wondering about the best way to approach it from a programming perspective. (PHP, not that language matters) The tricky part is that some token’s weight are relative to other tokens. For example:

  • If a token seems likely to be a first name, then it is likely that the next token is a last name.
  • Some tokens are related to each other, but if things are exploded by spaces, I’m not sure how to relate them. Example, “Anne Marie, FL” would be considered three tokens – “Anne”, “Marie”, and “FL”. Worse yet, “Anne” and “Marie” would gain weight towards being a first name. Now, if weight is also awarded based on position, a previous string with first name weight could win, freeing these strings up to be detected as city.

I know there’s a lot of smart people out there, so maybe someone has an idea on this one!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:23:02+00:00Added an answer on May 27, 2026 at 4:23 pm

    It’s helpful to know the exceptions (e.g. a town named Mary Sue), but end users should be pleased if your software can handle the most likely cases. Names can be sorted by relative frequency of occurrence in each category: personal name, company name, city name. For companies, the number of employees can be used to calculate relative likelihood. For cities, population.

    Do you already have rules to check the relative position of the line containing each token?

    There are certainly quite a few business card formats, but if you have several hundred sample business cards you should be able to identify some common format rules. Having just a few rules could help immensely. One rule might be “80% of all cards have the address beneath the personal name and company name,” Although your sample of business cards may not be truly representative of all possible business cards, all languages, etc., etc., it’s a start. Even a few 50% and 80% rules could simplify your task.

    You can probably think up several rules using a ridiculous example.

    John Smith
    Chief Operating Officer
    Acme Inc.
    123 Main Street
    Somewhere, XZ 01010
    

    is more likely than

    Somewhere, XZ
    01010
    John Smith
    Acme Inc.
    Chief Operating Officer
    123 Main Street
    

    That suggests we can consider the relative Y-position of personal and company names relative to postal codes. Although personal name, job title, and company name may follow in any of several orders, postal codes are likely to be located below company names. Postal codes will be closer to city names, etc.

    Although a word like “Samantha” could be part of a personal name, a street name, or a company name, it’s most likely a person name. You should be able to find databases that list the relative frequency of birth names, the population of towns with the name “Samantha”, and the number of registered corporations with the name “Samantha.” Even partial databases would be helpful to establish some reasonable guesstimates of likelihood.

    Other possible rules:

    • A mix of letters and numbers 5 – 7 digits at the end of a line (for left-to-right text) or on its own line is likely to be a postal code.
    • “Inc,” “Ltd”, “Corp” and other abbreviations should increase the likelihood that a line is identified as a company name
    • A personal name is likely to be located above a title. (Maybe 85% – 95% of the time?)
    • Phone numbers follow a somewhat limited number of patterns, and tend to include characters not found in postal codes: “(” “)” “.”
    • Websites follow common patterns. Even if there’s someone whose legal name is “CarolGreen.com”, she probably wouldn’t be surprised if her name was recognized as a website.
    • The “@” symbol is almost certainly part of an email address. An email address is likely located on some line beneath the person name, assuming the email address appears at all.
    • Some information may be absent. The card may not list a website. There may be a phone number, but not a street address. The person may not have a title. A personal business card may not have a company name. It’s most likely that at least one line will be a personal name.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.