Script to Find Repeating Words

Get help with using AutoHotkey and its commands and hotkeys
jballi
Posts: 487
Joined: 29 Sep 2013, 17:34

Script to Find Repeating Words

19 Jun 2018, 15:46

Not the best forum for this request but the other forums didn't seem to right either so here goes...

I'm looking for script that will find repeating words in text. I've seen word processors that that do do it but I did a quick search and I didn't find any scripts out there that do it. I may be using the wrong search terms.

Anyone know of have a script to do this? If not, I will be forced to write my own.

Thanks.
User avatar
TheDewd
Posts: 959
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Script to Find Repeating Words

19 Jun 2018, 16:13

You mean like this?

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

#SingleInstance, Force

SampleText := "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit."

StrReplace(SampleText, "Lorem", "Lorem", Occurrence)

MsgBox, % """Lorem"" occurs exactly " Occurrence " times in this sample text."
jballi
Posts: 487
Joined: 29 Sep 2013, 17:34

Re: Script to Find Repeating Words

19 Jun 2018, 17:04

Thank you for your interest.

No. I'm sorry, I realize that I wasn't very specific. When I say repeating words I mean words that are repeated next to each other. "The the" is a common problem that occurs in many of the documents that I write. Connectives like "with" are also common. Although there are common words, any word can be inadvertently (and incorrectly) repeated and I need to find them.
User avatar
Xtra
Posts: 1138
Joined: 02 Oct 2015, 12:15

Re: Script to Find Repeating Words

19 Jun 2018, 17:30

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
jeeswg
Posts: 4580
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Script to Find Repeating Words

19 Jun 2018, 17:33

- Here's an attempt. It's essentially just a parsing loop using space as the delimiter. You then have to consider how to deal with any non-letters. I have considered commas and full stops in the example below.
- If you want to know the exact position of where the repeated match occurs, you could use my script, and then use RegExMatch on the original text to find the positions.
- RegExReplace could be used to replace secondary occurrences of words, but some are valid.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

jballi
Posts: 487
Joined: 29 Sep 2013, 17:34

Re: Script to Find Repeating Words

19 Jun 2018, 17:58

I was hoping that that there was some some ready-to-go script out there but this is a good start. Thanks everybody! :thumbup:
jballi
Posts: 487
Joined: 29 Sep 2013, 17:34

Re: Script to Find Repeating Words

19 Jun 2018, 19:26

From the "just in case you care" department...

I found a good RegEx pattern to help with this requirement from this this web site. It is far (far) from being done but this is what I have so far.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Guest

Re: Script to Find Repeating Words

20 Jun 2018, 06:07

jballi wrote:this this
we see what you did there... :D
swagfag
Posts: 842
Joined: 11 Jan 2017, 17:59

Re: Script to Find Repeating Words

20 Jun 2018, 07:12

not the whole shebang but might give u a starting point

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

jballi
Posts: 487
Joined: 29 Sep 2013, 17:34

Re: Script to Find Repeating Words

20 Jun 2018, 14:41

swagfag: Definitely not what I was looking for but your script provides information about a document that might be useful in the future. Thanks for sharing. :)

Return to “Ask For Help”

Who is online

Users browsing this forum: Renets and 54 guests