AutoCorrect for v2

Post your working scripts, libraries and tools.
someguyinKC
Posts: 59
Joined: 25 Oct 2018, 11:33

Re: AutoCorrect for v2

Post by someguyinKC » 29 Mar 2024, 17:04

Another question:

when I go through the process of using the Win+h button and click "append" to append my script, thank you for this by the way, it is really great.... but can it be set up so that the word that i made the new script for gets fixed in the original document when I click append? That would be great if it worked that way!
thank you,

Someguy

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 29 Mar 2024, 19:27

someguyinKC wrote:
29 Mar 2024, 17:04
Another question: when I go through the process of using the Win+h button and click "append" to append my script, thank you for this by the way, it is really great.... but can it be set up so that the word that i made the new script for gets fixed in the original document when I click append? That would be great if it worked that way!
Yeah maybe... I used to have this functionality in an AHK v1 version of HotString Helper, but it was kludgy...

After the hotstring was appended, ^c would get sent a second time. That would allow a confirmation that the original misspelled word was still selected. If so, then the replacement would get sent, thus replacing it in the active text/edit field.

If you accidentally clicked the mouse or typed a key during the process, it would mess things up.

I will see about adding it in the future. Right now, I'm trying to learn how to use GitHub with VSCode, to manage my AHK projects. Has been slow-going.
ste(phen|ve) kunkel

someguyinKC
Posts: 59
Joined: 25 Oct 2018, 11:33

Re: AutoCorrect for v2

Post by someguyinKC » 30 Mar 2024, 05:29

kunkel321 wrote:
29 Mar 2024, 19:27
someguyinKC wrote:
29 Mar 2024, 17:04
Another question: when I go through the process of using the Win+h button and click "append" to append my script, thank you for this by the way, it is really great.... but can it be set up so that the word that i made the new script for gets fixed in the original document when I click append? That would be great if it worked that way!
Yeah maybe... I used to have this functionality in an AHK v1 version of HotString Helper, but it was kludgy...

After the hotstring was appended, ^c would get sent a second time. That would allow a confirmation that the original misspelled word was still selected. If so, then the replacement would get sent, thus replacing it in the active text/edit field.

If you accidentally clicked the mouse or typed a key during the process, it would mess things up.

I will see about adding it in the future. Right now, I'm trying to learn how to use GitHub with VSCode, to manage my AHK projects. Has been slow-going.
Okay, thank you. Again, I really appreciate what you've done!
thank you,

Someguy

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 31 Mar 2024, 15:24

Here is the latest (4-2-2024) version of AutoCorrect for v2 and HotString Helper 2.0 (hh2) No longer the latest. The version on GitHub is newer. This version also introduces the ManualCorrectLogger.
AutoCorrect2-toShare4-2-2024.7z
(1.63 MiB) Downloaded 37 times
I still have vague aspirations of making a version of hh2 for Descolada's _HS() system of hotstrings. Haven't done that yet. Also I plan to have all this stuff in GitHub... That has been slow-going too.

@someguyinKC had requested the ability to have a misspelled word fixed in your document, if/when you add a new autocorrect item via hh2. That has been added. The feature is meant for scenarios where you're typing some text, then you select a misspelled word (usually by double-clicking it) and activate hh2 via Win+H. If the selected text is multi-line, or if it gets trimmed, then the selected word doesn't get changed. But if you select a misspelled word, then make a whole-word autocorrect entry via hh2, then hh2 will attempt to put the correction into your thing that you are typing. You can disable this, by finding AutoEnterNewEntry := 1 near the top of the code, and setting it to := 0.

This version introduces the ManualCorrectionLogger. By "manual" I mean that it automatically captures and logs manual corrections you make while typing. This is in contrast to the AutoCorrectionLog, with holds the autocorrects that happen via the f() function that is in Autocorrect for v2 (ac2). So the AutoCorrectionLog doesn't need to run in the background. It gets appended, as-needed, by ac2. The ManualCorrectionLogger, on the other hand, is its own application and needs to be running in the background. You'll probably want to put the MCL and put ac2 in your Windows Startup folder. Important: I left my own log data in the logs as an example, and so you can experiment with running the log analyzers, but you'll want to remove my log data and collect your own, that is based on your own typing experiences. My idea with the MCL is that I'd see if particular typos and corrections were reoccurring. If so, I'd consider adding them to my ac2 library of items. I have gotten ideas for new ac items, but that has been from simply manually reviewing the log. I'd added maybe 10 or 15 new items that way. The current number of potential fixes from the ac2 library is just over 360k.

As before, the included exe files are not compiled versions of the scripts. They are copies of AutoHotkey64.exe that have been renamed to match the corresponding .ahk files. The matching ahk and exe files must have the same name, and be in the same folder.

If anyone hasn't downloaded the 2-22-2024 version that is here:
viewtopic.php?f=83&t=120220&start=20#p559328
I recommend doing so, so as to get the PDF manual. The manual needs to be updated, but it covers how to use the "Exam Pane" which is an instrumental part of the hh2 and ac2 package.

Bonus tip: Right-click on the Exam button for links to the other tools. :geek:

Also... Bug fix:
-The 2-22-2024 version was making wrongly-formatted hotstrings, when the item was a multi-line item AND the [] Make Function checkbox was checked. That has been fixed.

EDIT: If VSCode doesn't open...
Spoiler
Last edited by kunkel321 on 15 Apr 2024, 07:55, edited 3 times in total.
ste(phen|ve) kunkel

someguyinKC
Posts: 59
Joined: 25 Oct 2018, 11:33

Re: AutoCorrect for v2

Post by someguyinKC » 02 Apr 2024, 09:36

I'm having trouble setting my editor. I tried this and it didn't work. I continue to get the dialog box to pop up.
Attachments
image.png
image.png (71 KiB) Viewed 506 times
thank you,

Someguy

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 02 Apr 2024, 10:41

Hmm... My bad. The code (erroneously) assumes that your editor is in the AddData folder. That's why I used a subStr of A_Temp. Just get rid of that, and have it like this:

Code: Select all

MyAhkEditorPath := "C:\Users\steve\AppData\Local\Programs\Microsoft VS Code\Code.exe" 
but pointing to your path for SciTE. ...basically just get rid of the subStr(A_Temp, 1, -4).

Be advised also... Just above the ValidationFunction() is this function:

Code: Select all

; Find the text that is selected in the GUI. 
findInScript(*)
{	SoundBeep
	if (GetKeyState("LButton", "P"))
		KeyWait "LButton", "U"
	A_Clipboard := ""
	SendInput "^c"
	If !ClipWait( 1, 0)
		Return	
	;msgbox A_Clipboard
	if WinExist(NameOfThisFile)
		WinActivate NameOfThisFile
	else 
	{	Run MyAhkEditorPath " " NameOfThisFile
		While !WinExist(NameOfThisFile)
			Sleep 50
		WinActivate NameOfThisFile
	}
	If RegExMatch(A_Clipboard, "^\d{2,}") ; two or more digits? 
		SendInput "^g" A_Clipboard
	else 
	{	SendInput "^f"
		sleep 200
		SendInput "^v"
	}
	mbTitle.Focus() ; Focus title again so text doesn't stay selected. 
}
This function gets called if/when the big validation message box is shown
Spoiler
If you select the digits, then the script assumes you selected the line number, and will use the VSCode keyboard shortcut for "go to line number" which is Ctrl+G. But if you select some text, the script will assume you selected the hotstring, and so it will attempt to find it via Crtl+F, then Ctrl+V to paste it in the find box. I think the hotkeys are the same in SciTE, but I'm not 100% sure.

EDIT: Note that the go to / find action is instant. You don't need to press Ctrl+C. Just select the line number or hotstring and as soon as you release the mouse, the look up is triggered. If this is annoying, you can disable the "instant lookup" by searching for this line of code.

Code: Select all

	trigEdtBox.OnEvent('Focus', findInScript) 
which is in the BiggerMessageBox() function just above it. Comment-out or remove the line of code. You'll still be able to select text from the validation report message box, but the instant look up will be disabled.
ste(phen|ve) kunkel

someguyinKC
Posts: 59
Joined: 25 Oct 2018, 11:33

Re: AutoCorrect for v2

Post by someguyinKC » 02 Apr 2024, 12:12

@kunkel321 okay! that worked so that I can now click the "Reload script" and it works.

but I'm still having trouble with "Edit this Script". when I click that from the tray icon, it opens up SCITE4AutoHotkey (which is what I want) but it opens it up to a blank page that is titled "AutoHotkey64.ahk".

how could I fix that?
thank you,

Someguy

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 02 Apr 2024, 12:59

someguyinKC wrote:
02 Apr 2024, 12:12
...but I'm still having trouble with "Edit this Script". when I click that from the tray icon, it opens up SCITE4AutoHotkey (which is what I want) but it opens it up to a blank page that is titled "AutoHotkey64.ahk".
how could I fix that?
Strange... I'm not sure what would cause that... Are the ahk and exe files still named correctly in your folder, like this?
Image

The Shift+Ctrl+E hotkey and the systray menu item both point to this function:

Code: Select all

; Open this script in VSCode.
^+e::
EditThisScript(*)
{	thisScript := StrReplace(A_AhkPath, ".exe", ".ahk")
	Try
		Run MyAhkEditorPath " " thisScript 
	Catch
		msgbox 'cannot run ' thisScript
}
It reads from the currently running exe, then swaps the file extension to ahk, and opens that...

I suppose that if you were to open the AutoCorrectv2.ahk in SciTE, then run the code from the SciTE toolbar, then it might run the script directly from AutoHotkey64.exe, rather than the AutoCorrectv2.exe.

Try exiting the script, then launch it be doubleclicking the AutoCorrectv2.exe file that is in the folder...

EDIT: Also note the comment I just added about VSCode in the above post. I suppose this could also affect SciTE(?)
Spoiler
ste(phen|ve) kunkel

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 02 Apr 2024, 13:31

Also...
It occurs to me that the variable assignement: NameOfThisFile := "AutoCorrectv2.ahk" is at the top of the code... It makes sense to use that for the EditThisScript() function, like this:

Code: Select all

; below is specific to Steve's setup.  Open this script in VSCode.
^+e::
EditThisScript(*)
{	Try
		Run MyAhkEditorPath " " NameOfThisFile
	Catch
		msgbox 'cannot run ' NameOfThisFile
}
Ironically, the reason I have that variable assignment is for the #HotIf thing that saves then reloads the script if you are editing it. The reason it's ironic, is that I didn't include it in the version of the script that I shared... The hotkey assignment is here, if you want to use it.

Code: Select all

#HotIf WinActive(NameOfThisFile,) ; Can't use A_Var here.
^s:: ; When you press Ctrl+s, this scriptlet will save the file, then reload it to RAM.
{
	Send("^s") ; Save me.
	MsgBox("Reloading...", "", "T0.3")
	Sleep(250)
	Reload() ; Reload me too.
	MsgBox("I'm reloaded.") ; Pops up then disappears super-quickly because of the reload.
}
#HotIf
ste(phen|ve) kunkel

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 02 Apr 2024, 13:52

Actually... (building on the last two replies) I'll just make the changes for you...
EDIT: There was a zip posted here, but I removed it because it was a duplicate of the one that is posted 6 replies back.
Last edited by kunkel321 on 06 Apr 2024, 09:01, edited 1 time in total.
ste(phen|ve) kunkel

someguyinKC
Posts: 59
Joined: 25 Oct 2018, 11:33

Re: AutoCorrect for v2

Post by someguyinKC » 03 Apr 2024, 07:19

@kunkel321 Thank you again! I'm running a top script at this point! You are much appreciated!
thank you,

Someguy

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 03 Apr 2024, 08:53

someguyinKC wrote:
03 Apr 2024, 07:19
@kunkel321 Thank you again! I'm running a top script at this point! You are much appreciated!
Awesome. You're welcome. :thumbup:
ste(phen|ve) kunkel

User avatar
GollyJer
Posts: 70
Joined: 19 Sep 2015, 19:33
Contact:

Re: AutoCorrect for v2

Post by GollyJer » 03 Apr 2024, 23:36

Just wanted to pop in and say thanks for the awesome work!

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 04 Apr 2024, 09:06

GollyJer wrote:
03 Apr 2024, 23:36
Just wanted to pop in and say thanks for the awesome work!
You're welcome! :D
ste(phen|ve) kunkel

willwade
Posts: 9
Joined: 21 Feb 2017, 08:52
Contact:

Re: AutoCorrect for v2

Post by willwade » 06 Apr 2024, 05:07

Any chance you can move this to like GitHub or something so I can track changes and the like? Might make your docs easier too.. (I'll happily help you with automations for a release too :) )

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 06 Apr 2024, 08:59

willwade wrote:
06 Apr 2024, 05:07
Any chance you can move this to like GitHub or something so I can track changes and the like? Might make your docs easier too.. (I'll happily help you with automations for a release too :) )
You're not the first person to suggest this... And I do plan too. I'm not a programmer by trade, just a hobbyist. I use VSCode and I do have a GitHub account. Integrating VSCode and GitHub has been a bit intimidating though... What do you mean when you say, "automations for a release?"
ste(phen|ve) kunkel

willwade
Posts: 9
Joined: 21 Feb 2017, 08:52
Contact:

Re: AutoCorrect for v2

Post by willwade » 06 Apr 2024, 11:31

I mean the building of any executables , zipping up etc. it can all be done in a GitHub action. For free! Just make a GitHub user. And a repo. Upload your code then boom! 💥 that’s the first step. Automating things (if you want to !) can come in time :-)

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 06 Apr 2024, 12:13

willwade wrote:
06 Apr 2024, 11:31
I mean the building of any executables , zipping up etc. it can all be done in a GitHub action. For free! Just make a GitHub user. And a repo. Upload your code then boom! 💥 that’s the first step. Automating things (if you want to !) can come in time :-)
Cool. I've noticed that if I download someones complete repository, GitHub puts it in a zip, so that's cool.

As it turns out, you wouldn't want to compile AutoCorrect.ahk, or either of the log ahk files... (As far as I understand) it would prevent the scripts from being able to do the Append() commands...
ste(phen|ve) kunkel

User avatar
kunkel321
Posts: 1062
Joined: 30 Nov 2015, 21:19

Re: AutoCorrect for v2

Post by kunkel321 » 06 Apr 2024, 12:34

This is not an update of the AutoCorrect for v2 (ac2) "package" but rather a couple of related tools.

It occurred to me that if people are using older versions of ac2, they might have added lots of cool new custom autocorrect entries via the HotString Helper tool. If those new custom hotstrings are still at the bottom of your ac2 file, then no problem... Copy-n-paste the new items over to the newer versions of ac2 as they are released... However... Some folks might like to alpha-sort their hotstrings. (At least that's what I do--LOL) If that is the case, how can you "bring over" your new custom items to the latest release of the ac2 script?

That's what this first script is for...
IMPORTANT:
- I left the file path to my own ac2 file (which I call "MasterScript") as an example, but delete that, and use your own scripts and related directory/paths.
- Remember to scan the .ahk files, not the same-named .exe files.
- If you kept the name "AutoCorrect for v2.ahk", then you might rename that to something like, "AutoCorrect for v2_OLD.ahk"
- Put the newer version and the older version in the same folder as this script, so that the folder contains the files:
Unique string finder.ahk
AutoCorrect for v2.ahk
AutoCorrect for v2_OLD.ahk
- If they are all in the same folder, you can probably just at the file names in the code, and not the whole directory path.
- If the Unique String Finder works correctly, It will create a text file with a list of the unique items, then it will open that text file and beep twice.
- Please note that this will not identify any unique Hotkeys or code that you added... Only hotstrings.

Code: Select all

#SingleInstance
#Requires AutoHotkey v2+
; A script to find duplicate hotstrings that are in one file but not another. 
; Intended for updating AutoHotkey scripts.  kunkel321 2-28-2024.
; Please ensure that is it pointing to two valid files. 
; The "mainFile" is the file that you plan to use--it is your new AutoCorrect file.
; The "extraFile" is a different version of your file, that might have new custom hotstrings
; added, that are not in the new mainFile. 

mainFile := "D:\AutoHotkey\MasterScript\MasterScript.ahk"  ; <--- Your AutoCorrect.ahk file path here.
extraFile := "D:\AutoHotkey\MasterScript\MasterScriptPartialTemp.ahk" 

^Esc::ExitApp ; <----- Emergency kill switch is Ctrl+Esc. 

Try fullList := Fileread(mainFile) ; Make sure file exists and save contents for variable. 
Catch {
	MsgBox '====ERROR====`n`nThe file (' mainFile ')`nwas not found.`n`nRemember to set the three variables`nat the top of the script. Now exiting.'
	ExitApp
}

Try extraList := Fileread(extraFile) ; Make sure file exists and save contents for variable. 
Catch {
	MsgBox '====ERROR====`n`nThe file (' extraFile ')`nwas not found.`n`nRemember to set the three variables`nat the top of the script. Now exiting.'
	ExitApp
}

StartTime := A_TickCount 
Opts:= "", Trig := ""
DupReport := "", Count := 0

TotalLines := StrSplit(fullList, "`n").Length ; Determines number of lines for Prog Bar range.
rep := Gui()
rep.Opt("-MinimizeBox +alwaysOnTop +Owner")
MyProgress := rep.Add("Progress", "w400 h30 cGreen Range0-" . TotalLines, "0")
rep.Title := MyProgress.Value
rep.Title := "Lines of file remaining: "
rep.Show()

; Loop through Main File contents, then remove any matching lines from the Extra File contents. 
loop parse fullList, "`n" { 
	MyProgress.Value += 1
	rep.Title := "Lines of file remaining: " (TotalLines - MyProgress.Value) "... Press Ctrl+Esc to Cancel" ; For progress bar.
	extraList := strReplace(extraList, A_LoopField, "`nxxxxxx",,,1) ; Remove the item because it exists in both files. 
}

; Loop through the Extra Files, and extract anything that wasn't replaced with "xxxxxx."
loop parse extraList, "`n" {
	If  (SubStr(trim(A_LoopField, " `t"), 1,1) = ":") ; Only include lines starting with ":"
	{	DupReport .= A_LoopField "`n"
		Count++
	}
}

ElapsedTime := (A_TickCount - StartTime) / 1000 ; Calculate and format time taken. 
ElapsedTime := "Found " Count " unique items in " Round(ElapsedTime / 60) "-min " Round(mod(ElapsedTime, 60)) "-sec."

rep.Destroy() ; Remove progress bar.

FullReport := DupReport
If FullReport = ""
	FullReport := "No unique hotstrings found in " extraFile "."
FullReport := ElapsedTime "`n=================================`n" FullReport
Location := A_ScriptDir "\Uniques_Report" FormatTime(A_Now, "_MMM_dd_hh_mm") ".txt"
FileAppend FullReport, Location ; Save to text file, then open the file. 
sleep 250
Run Location

SoundBeep 1800, 700
SoundBeep 1200, 200
ExitApp
The above script is pretty fast, but the below one is way more thorough and takes longer...
IMPORTANT: The above script compares TWO files, but the below one only looks in a single file. Again, change the name of the file to your own AutoCorrect.ahk (not exe) file. Also note, this script also appeared on this thread, a couple of pages back...

Code: Select all

#SingleInstance
#Requires AutoHotkey v2+
; A script to find duplicate and conflicting beg/mid/end hotstring triggers. By kunkel321 2-28-2024. 
; It should work with hotstrings that are formatted with f(), _HS(), or plain AHK hotstrings. 
; Note: When correcting/culling your autocorrect library, remember that sometimes conflicting
; autocorrect items can peacefully coexist... Read more in manual, attached here
; https://www.autohotkey.com/boards/viewtopic.php?f=83&t=120220&p=559727#p559328
; Warning: Sloooww script....  Takes about 6 minutes for 5k lines of autocorrect items. 

; !!! IMPORTANT !!! Set first three variables.

ACitemsStartAt := 2025 ; <--- "AutoCorrect Items Start At this line number."  Skip this many 
; lines at top of code.  Recommend not scanning 'nullifier' items, 'don't sort' items, 
; nor '#HotIf' items.  (Hopefully those are all at the top, above your main list.) 
ACitemsEndAt := 6790 ; <--- stop comparing after this line number. No point scanning the non-English accented words. 
targetFile := "D:\AutoHotkey\MasterScript\MasterScript.ahk"  ; <--- Your AutoCorrect.ahk file path here.

^Esc::ExitApp ; <----- Emergency kill switch is Ctrl+Esc. 

If !ACitemsStartAt
	ACitemsStartAt := 0
If !ACitemsEndAt
	ACitemsEndAt := 99999
Try fullList := Fileread(targetFile)
Catch {
	MsgBox '====ERROR====`n`nThe file (' targetFile ')`nwas not found.`n`nRemember to set the three variables`nat the top of the script. Now exiting.'
	ExitApp
}

StartTime := A_TickCount 
Opts:= "", Trig := ""
DupReport := "", BegReport := "", MidReport := "", EndReport := "", Count := 0
Separator := "`n---------------------------------------`n"
hsRegex := "i):(?P<Opts>[^:]+)*:(?P<Trig>[^:]+)" ; part of andymbody's regex

TotalLines := StrSplit(fullList, "`n").Length ; Determines number of lines for Prog Bar range.
rep := Gui()
rep.Opt("-MinimizeBox +alwaysOnTop +Owner")
MyProgress := rep.Add("Progress", "w400 h30 cGreen Range0-" . TotalLines, "0")
rep.Title := MyProgress.Value
rep.Title := "Lines of file remaining: "
rep.Show()

loop parse fullList, "`n" {
	MyProgress.Value += 1
	rep.Title := "Lines of file remaining: " (TotalLines - MyProgress.Value) "... Press Ctrl+Esc to Cancel" ; For progress bar.
	fullList := strReplace(fullList, A_LoopField, "xxxxxx",,,1) ; Redact the oLoop item we just checked, so we don't compare it again in a future inner loop.
	If (A_Index < ACitemsStartAt) or (A_Index > ACitemsEndAt) or (SubStr(trim(A_LoopField, " `t"), 1,1) != ":") 
		Continue ; Skip if line number is too high/low, or line doesn't start with ":".  Ignore leading whitespace. 
	oLoop :=  A_LoopField ; "o" for "outter"
	oIdx := A_Index
	if regexMatch(oLoop, hsRegex, &o) {
		loop parse fullList, "`n" {
			If (A_Index < ACitemsStartAt) or (A_Index > ACitemsEndAt) or (SubStr(trim(A_LoopField, " `t"), 1,1) != ":") 
				Continue ; Skip if line number is too high/low, or line doesn't start with ":".  Ignore leading whitespace. 
			iLoop :=  A_LoopField ; "i" for "inner"
			iIdx := A_Index
			If regexMatch(iLoop, hsRegex, &i) {
			;msgBox o.Opts " " o.Trig "`n---------`n" i.Opts " " i.Trig 
				If (o.Trig = i.Trig) and (o.Opts = i.Opts) { ; Duplicates
					DupReport .= Separator
					DupReport .= "Line: " oIdx "`t`t" o.Trig (strLen(o.Trig)<8?"`t`t":"`t") oLoop "`n"
					DupReport .= "-and: " iIdx "`t`t" i.Trig (strLen(i.Trig)<8?"`t`t":"`t") iLoop "`n"
					Count++
				}
				Else If (InStr(i.Trig, o.Trig) and inStr(o.Opts, "*") and inStr(o.Opts, "?"))
				|| (InStr(o.Trig, i.Trig) and inStr(i.Opts, "*") and inStr(i.Opts, "?")) { ; Word-Middle Matches
					MidReport .= Separator
					MidReport .= "Line: " oIdx "`t" strReplace(strReplace(o.Opts, "B0", ""),"X", "") "`t" o.Trig (strLen(o.Trig)<8?"`t`t":"`t") oLoop "`n"
					MidReport .= "-and: " iIdx "`t" strReplace(strReplace(i.Opts, "B0", ""),"X", "") "`t" i.Trig  (strLen(i.Trig)<8?"`t`t":"`t") iLoop "`n"
					Count++
				}
				Else If ((i.Trig = o.Trig) and inStr(i.Opts, "*") and inStr(o.Opts, "?"))
				|| ((o.Trig = i.Trig) and inStr(i.Opts, "?") and inStr(o.Opts, "*")) ; Rule out: Same word, but beginning and end opts
					Continue
				Else If (inStr(i.Opts, "*") and i.Trig = subStr(o.Trig, 1, strLen(i.Trig)))
				|| (inStr(o.Opts, "*") and o.Trig = subStr(i.Trig, 1, strLen(o.Trig))) { ; Word-Beginning Matches
					BegReport .= Separator
					BegReport .= "Line: " oIdx "`t" strReplace(strReplace(o.Opts, "B0", ""),"X", "") "`t" o.Trig (strLen(o.Trig)<8?"`t`t":"`t") oLoop "`n"
					BegReport .= "-and: " iIdx "`t" strReplace(strReplace(i.Opts, "B0", ""),"X", "") "`t" i.Trig  (strLen(i.Trig)<8?"`t`t":"`t") iLoop "`n"
					Count++
				}
				Else If (inStr(i.Opts, "?") and i.Trig = subStr(o.Trig, -strLen(i.Trig)))
				|| (inStr(o.Opts, "?") and o.Trig = subStr(i.Trig, -strLen(o.Trig))) { ; Word-Ending Matches
					EndReport .= Separator
					EndReport .= "Line: " oIdx "`t" strReplace(strReplace(o.Opts, "B0", ""),"X", "") "`t" o.Trig (strLen(o.Trig)<8?"`t`t":"`t") oLoop "`n"
					EndReport .= "-and: " iIdx "`t" strReplace(strReplace(i.Opts, "B0", ""),"X", "") "`t" i.Trig  (strLen(i.Trig)<8?"`t`t":"`t") iLoop "`n"
					Count++
				}
			}
			Else ; not a regex match, so go to next loop.
				continue 
		}
	} 
	;msgBox fullList
}

If (DupReport != "") ; Create headings only for needed parts. 
	DupReport := "Duplicates:" DupReport "`n"
If (BegReport != "")
	BegReport := "Beginnings:" BegReport "`n"
If (MidReport != "")
	MidReport := "Middles:" MidReport "`n"
If (EndReport != "")
	EndReport := "Endings:" EndReport "`n"

ElapsedTime := (A_TickCount - StartTime) / 1000 ; Calculate and format time taken. 
ElapsedTime := "Found " Count " item pairs in " Round(ElapsedTime / 60) "-min " Round(mod(ElapsedTime, 60)) "-sec."

rep.Destroy() ; Remove progress bar.

FullReport := DupReport BegReport MidReport EndReport 
If FullReport = ""
	FullReport := "No duplicate or conflicting hotstring pairs located."
FullReport := ElapsedTime "`nLine`tOpt`tTrigger`tFull item`n=================================`n" FullReport
Location := A_ScriptDir "\Conflict_Report" FormatTime(A_Now, "_MMM_dd_hh_mm") ".txt"
FileAppend FullReport, Location ; Save to text file, then open the file. 
sleep 1000
Run Location
; msgbox FullReport

SoundBeep 1800, 700
SoundBeep 1200, 200
ExitApp
ste(phen|ve) kunkel

willwade
Posts: 9
Joined: 21 Feb 2017, 08:52
Contact:

Re: AutoCorrect for v2

Post by willwade » 07 Apr 2024, 01:23

I’ll share something I’ve been mulling over (and why I want to tinker heavily with your code!). For a while I’ve been tinkering with a small language model for error correction. It’s designed really for people who use technology to speak so the data we have used isn’t always grammatically perfect but it’s usually typo free (eg it’s transcripts from spoken data). We also have trained it on a lot of sentencesthathavenospaces as that’s common in our work. So bear all that mind. Anyway the model we have runs on low powered windows devices (atom 1 cpu) ok and call time is between half a second and 3. Model https://huggingface.co/willwade/t5-small-spoken-typo (put a bad sentence in that inference API box and see if it works)

I think we could
- retrain a new GEC (grammar error correction) model with written grammarticly correct sentences.
- then run it in memory. We use it alongside your autocorrect ahk - like it calls it in the same way you call google (interesting idea btw)
- it would be offline and performant. Well. That’s the idea

Post Reply

Return to “Scripts and Functions (v2)”