Greetings fellow developers!
BACKGROUND
I have implemented a spelling assistance algorithm that corrects user inputs to an edit distance of 1, using a dictionary file. I primarily use maps in C++ for the implementation i.e. to store the dictionary word & it's corresponding frequency and process the same.
The code is shared temporarily on this link: https://codeshare.io/2pVr6a
My question is as follows:
The code tests in this particular test case. I know this is really long, but it's the only one that fails:
dictionary.txt
ACCD 100
AACD 100
ABCD 100
ACC 100
AAC 100
ABB 100
ABC 100
AAA 100
ABA 100
ABCDE 101
A 100
AB 101
THIS 10
E 100
CD 100
AC 100
QQQ 1
input
ABC AAC AAAA QABC OWAA ACBD WIDLS ACC WW KQQQ AACB QQQQ AACCD ACDD ACCD ACDDD AACD ABAB ACABA BUCASC LKA AAAAA AAAA A AC CCA CA ABCD ACD QIE E CDE AC C QQ QA BBB CCC ACD CDAA THI THIS THISI TTA AT ABBB
desired output
ABC 100
AAC 100
AAA 100
ABC 101
-
ACCD 100
-
ACC 100
-
QQQ 1
AAC 101
QQQ 1
AACD 100
ACCD 100
ACCD 100
-
AACD 100
ABA 100
-
-
-
-
AAA 100
A 100
AC 100
-
A 101
ABCD 100
AACD 101
-
E 100
CD 100
AC 101
AC 102
QQQ 1
A 101
ABB 100
ACC 101
AC 102
-
THIS 10
THIS 10
THIS 11
-
AC 102
ABB 100
actual output
ABC 100
AAC 100
-
-
-
ACCD 100
-
ACC 100
-
-
AACD 100
KQQQ 1
-
ACCD 101
ACCD 102
-
AACD 101
-
-
-
-
-
AAAA 1
A 100
AC 100
-
CD 100
ABCD 100
ACC 101
-
E 100
-
AC 101
A 101
-
QQ 1
ABB 100
ACC 102
ACC 103
-
-
THIS 10
-
-
AC 102
ABAB 1