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 6726121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:53:21+00:00 2026-05-26T09:53:21+00:00

I want to solve a common but very specific problem: due to OCR errors,

  • 0

I want to solve a common but very specific problem: due to OCR errors, a lot of subtitle files contain the character “I” (upper case i) instead of “l” (lower case L).

My plan of attack is:

  1. Process the file word by word
  2. Pass each word to the hunspell spellchecker (“echo the-word | hunspell -l” produces no response at all if it is valid, and a response if it is bad)
  3. If it is a bad word, AND it has uppercase Is in it, then replace these with lowercase l and try again. If it is now a valid word, replace the original word.

I could certainly tokenize and reconstruct the entire file in a script, but before I go down that path I was wondering if it is possible to use awk and/or sed for these kinds of conditional operations at the word-level?

Any other suggested approaches would also be very welcome!

  • 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-26T09:53:21+00:00Added an answer on May 26, 2026 at 9:53 am

    You don’t really need more than bash for this:

    while read line; do
      words=( $line )
      for ((i=0; i<${#words[@]}; i++)); do
        word=${words[$i]}
        if [[ $(hunspell -l <<< $word) ]]; then
          # hunspell had some output
          tmp=${word//I/l}
          if [[ $tmp != $word ]] && [[ -z $(hunspell -l <<< $tmp) ]]; then
            # no output for new word, therefore it's a dictionary word
            words[$i]=$tmp
          fi
        fi
      done
      # print the new line
      echo "${words[@]}"
    done < filename > filename.new
    

    It does seem to make more sense to pass the whole file to hunspell, and parse the output of that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I have what must be a very common problem to solve and
In basic Java, if I write code to solve a common problem and want
Theres is a little problem I want to solve with Haskell: let substitute a
I have a simple, real life problem I want to solve using an OO
I want to build my own custom log4j (network) adapter to solve my problem
I'm trying to solve pretty easy problem. I want to establish connection to 2
I have a very tough problem for me to solve, and I thought and
I am trying to solve a problem in Objective-C, but I don't think the
I think this is a very common situation, but I can't find how everybody
So, I essentially have what I want already, very simple, but there are some

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.