Last active
April 26, 2021 15:37
-
-
Save JoeGlines/77c2914f13fb53f995a0a0eeba5e01f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;******************************************************* | |
; Want a clear path for learning AutoHotkey; Take a look at our AutoHotkey Udemy courses. They're structured in a way to make learning AHK EASY | |
; Right now you can get a coupon code here: https://the-Automator.com/Learn | |
;******************************************************* | |
FileRead, rawMentors, data\mentors.txt | |
FileRead, rawMentees, data\mentees.txt | |
if FileExist("match.txt") | |
FileDelete, match.txt | |
if FileExist("notMatched.txt") | |
FileDelete, notMatched.txt | |
FileAppend, % "Mentor`tMentee`n", match.txt | |
FileAppend, % "ID`tMentor`tMentee`n", notMatched.txt | |
OutputDebug, % rawMentors | |
; object for mentors | |
mentors := {} | |
loop, Parse, rawMentors, `n, `r | |
{ | |
if (!A_LoopField) | |
break | |
if (a_index == 1) | |
headers := a_loopfield | |
else | |
{ | |
data := StrSplit(a_loopfield, a_tab) | |
mentors[data[1]] := {} | |
loop, Parse, headers, `t | |
mentors[data[1]][A_LoopField] := data[a_index] | |
} | |
} | |
; object for mentees | |
mentees := {} | |
loop, Parse, rawMentees, `n, `r | |
{ | |
if (!A_LoopField) | |
break | |
if (a_index == 1) | |
headers := a_loopfield | |
else | |
{ | |
data := StrSplit(a_loopfield, a_tab) | |
mentees[data[1]] := {} | |
loop, Parse, headers, `t | |
mentees[data[1]][A_LoopField] := data[a_index] | |
} | |
} | |
; object for matchup | |
match := [] | |
; take one mentor compare with each mentee | |
for imentor,mentor in mentors | |
{ | |
highestMatch := 0 | |
for imentee,mentee in mentees | |
{ | |
if (mentor["id"] == mentee["id"]) | |
continue | |
matchCount:=0 | |
Loop, parse, headers, `t | |
if ((mentor[a_loopfield] == mentee[a_loopfield]) && mentor[a_loopfield] && mentee[a_loopfield]) | |
{ | |
matchCount +=1 | |
OutputDebug, % "matched on " a_loopfield " for " mentor["id"] " and " mentee["id"] | |
} | |
; select best match up (the most common topics) | |
if (matchCount > highestMatch) | |
{ | |
highestMatch := matchCount | |
; add them to matchup object | |
match[mentor["id"]] := mentee["id"] | |
} | |
} | |
; log match up to file | |
FileAppend, % mentor["id"] a_tab match[mentor["id"]] "`n", match.txt | |
; remove mentee from mentee object | |
mentees.Delete(match[mentor["id"]]) | |
} | |
; save remaining mentees to a file | |
for i,mentee in mentees | |
FileAppend, % mentee["id"] "`t`t" true "`n", notMatched.txt | |
for i,mentor in mentors | |
if (!match[mentor["id"]]) | |
FileAppend, % mentor["id"] a_tab true "`t`n", notMatched.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment