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

  • Home
  • SEARCH
  • 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 8041929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:23:40+00:00 2026-06-05T04:23:40+00:00

I need to do some OCR on a large chunk of text and check

  • 0

I need to do some OCR on a large chunk of text and check if it contains a certain string but due to the inaccuracy of the OCR I need it to check if it contains something like a ~85% match for the string.

For example I may OCR a chunk of text to make sure it doesn’t contain no information available but the OCR might see n0 inf0rmation available or misinterpret an number of characters.

Is there an easy way to do this in Python?

  • 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-06-05T04:23:42+00:00Added an answer on June 5, 2026 at 4:23 am

    As posted by gauden, SequenceMatcher in difflib is an easy way to go. Using ratio(), returns a value between 0 and 1 corresponding to the similarity between the two strings, from the docs:

    Where T is the total number of elements in both sequences, and M is
    the number of matches, this is 2.0*M / T. Note that this is 1.0 if the
    sequences are identical, and 0.0 if they have nothing in common.

    example:

    >>> import difflib
    >>> difflib.SequenceMatcher(None,'no information available','n0 inf0rmation available').ratio()
    0.91666666666666663
    

    There is also get_close_matches, which might be useful to you, you can specify a distance cutoff and it’ll return all matches within that distance from a list:

    >>> difflib.get_close_matches('unicorn', ['unicycle', 'uncorn', 'corny', 
                                  'house'], cutoff=0.8)
    ['uncorn']
    >>> difflib.get_close_matches('unicorn', ['unicycle'  'uncorn', 'corny',
                                  'house'], cutoff=0.5)
    ['uncorn', 'corny', 'unicycle']
    

    Update: to find a partial sub-sequence match

    To find close matches to a three word sequence, I would split the text into words, then group them into three word sequences, then apply difflib.get_close_matches, like this:

    import difflib
    text = "Here is the text we are trying to match across to find the three word
            sequence n0 inf0rmation available I wonder if we will find it?"    
    words = text.split()
    three = [' '.join([i,j,k]) for i,j,k in zip(words, words[1:], words[2:])]
    print difflib.get_close_matches('no information available', three, cutoff=0.9)
    #Oyutput:
    ['n0 inf0rmation available']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some regex help in Java. I have a string, which contains text and
I am doing something like extracting the pdf text in a string format so
I'm working in C# doing some OCR work and have extracted the text I
Need some help. I have a table with some columns..like name , phone etc...
Need some help for creating a File and String search engine. The program needs
Need some help with extracting 2 pieces of information from the following string: viewed
need some enlightment here, and this is my first post here. I would like
Need some php help in figuring out how use this array I created, but
Need some quick advice I am trying to access a object array but I
Need some help, please. I have a line of horizontal thumbnails loaded as ONE

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.