1

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
J. Doe
  • 17
  • 4
  • This is my final attempt to comply to Stack Overflow rules & keep my question highly specific. In case this question does not meet the requirements, PLEASE atleast notify me of the reason for the same. Best regards and thank you for your help! – J. Doe Dec 08 '16 at 07:01
  • 1
    Please paste code – Jonas Dec 08 '16 at 07:05
  • 1
    Have you tried debugging your code with that specific input? Just posting your code and asking people to debug it for you is not the purpose of this site. – o_weisman Dec 08 '16 at 07:35
  • Indeed, I've tried debugging it. I suspect that there might be an issue in either the deletion ops, or processing the I/O's in the STL maps. However, beyond this, I am unable to pinpoint the exact issue since I get no error feedback from the compiler or valgrind – J. Doe Dec 08 '16 at 08:23
  • @Jonas The code is 173 lines long since it involves a lot of algorithmic and I/O operations. Do you still want me to post it? I used the code-share link for the sake of viewing convenience. – J. Doe Dec 08 '16 at 08:25
  • If I was debugging this, I would reduce the input to the bare minimum while still falling and then go though the code step by step. But I simply do not have the time to debug it for you. – Jonas Dec 08 '16 at 08:33
  • No problem, I appreciate the help. – J. Doe Dec 08 '16 at 08:51

0 Answers0