DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: AutoHotKey text replacement question  (Read 9,512 times)

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
AutoHotKey text replacement question
« on: June 27, 2015, 09:05 PM »
I belong to a forum where a lot of amateur writers gather. They're wanting a script that will catch misspellings as they type. I'm developing a simple script that replaces the wrong wording with the correct wording. For example:

::good advise::good advice

The above works flawlessly: as soon as a user types "good advise" it gets changed by the script to "good advice" and the user just keeps on typing.

I want the script to detect anytime the writer types the article 'a' and the next word begins with a vowel. In that case, I want the script to change 'a' to 'an'. So, below shows what the author types and then after the arrow I show the correction made by the script:

a otter -> an otter

a icycle -> an icycle

Any help would be appreciated.
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: AutoHotKey text replacement question
« Reply #1 on: June 28, 2015, 05:53 AM »
@kyrathaba: If you're using Autohotkey to develop the auto-correct script, you can look up Hotstrings.


for starters, you can use something like this below though it is not accurate due to examples such as "an umbrella" vs. "a university".

Code: (autohotkey)
:*:a a::an a
:*:a e::an e
:*:a i::an i
:*:a o::an o
:*:a u::an u

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
Re: AutoHotKey text replacement question
« Reply #2 on: June 28, 2015, 01:49 PM »
Thanks, Lanux!
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: AutoHotKey text replacement question
« Reply #3 on: June 28, 2015, 02:05 PM »
@kyrathaba: If you're using Autohotkey to develop the auto-correct script, you can look up Hotstrings.


for starters, you can use something like this below though it is not accurate due to examples such as "an umbrella" vs. "a university".

Also "a hour"

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
Re: AutoHotKey text replacement question
« Reply #4 on: June 28, 2015, 02:06 PM »
Thanks, MilesAhead. Good catch! I'll add that in my script.
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

kunkel321

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 626
    • Participated in NANY Challenge Once
Re: AutoHotKey text replacement question
« Reply #5 on: June 29, 2015, 03:15 PM »
Man I gotta learn to do ahk programming....  I don't think that computer programmers appreciate just how confusing this stuff is to us lehhfolks.
Anyway.  I remember a few years ago, finding a script that someone had already written that does autocorrects.  Here I just now found this article about it.
http://www.howtogeek.com/howto/45068/how-to-get-spelling-autocorrect-across-all-applications-on-your-system/
I think it's been updated a few times, so google it and get the latest version.  If my memory is correct, they integrated some wikipedia list of "most common English typos" or some kind of thing.... 

Also, the a/an situation is difficult.  There are lots of exceptions. 

I also googled that.   
https://www.google.com/webhp?sourceid=chrome-instant&rlz=1C1CHFX_enUS475US475&ion=1&espv=2&ie=UTF-8#safe=off&q=an+vs+a+grammar+exceptions

From here: https://owl.english.purdue.edu/owl/resource/591/01/

Exceptions
Use "an" before unsounded "h." Because the "h" hasn't any phonetic representation and has no audible sound, the sound that follows the article is a vowel; consequently, "an" is used.

an honorable peace
an honest error
When "u" makes the same sound as the "y" in "you," or "o" makes the same sound as "w" in "won," then a is used. The word-initial "y" sound ("unicorn") is actually a glide [j] phonetically, which has consonantal properties; consequently, it is treated as a consonant, requiring "a."

a union
a united front
a unicorn
a used napkin
a U.S. ship
a one-legged man

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: AutoHotKey text replacement question
« Reply #6 on: June 29, 2015, 05:42 PM »
Anyway.  I remember a few years ago, finding a script that someone had already written that does autocorrects.

The other tough thing is a free grammar checker that doesn't crash the editor you are using it in. I tried Ginger and a couple of others.  Nothing really amazed me.  It seemed the better the program handled the grammar the more unstable it was.  Trying to brush up with online lessons is discouraging.  So many exceptions and bizarre rules.  I don't remember it being that complex when I was in grammar school.  :)

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
Re: AutoHotKey text replacement question
« Reply #7 on: June 29, 2015, 07:22 PM »
Thanks, kunkel. Added those exceptions.
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

Original address: https://www.donationcoder.com/forum/index.php?topic=41177.0