title: Spelling Assistance using Levenshtein Algorithm edge case debugging
body: <p>Greetings fellow developers!</p>
  
  <hr>
  
  <p><strong>BACKGROUND</strong></p>
  
  <p>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 &amp; it's corresponding frequency and process the same. </p>
  
  <p>The code is shared temporarily on this link: <a href="https://codeshare.io/2pVr6a" rel="nofollow noreferrer">https://codeshare.io/2pVr6a</a></p>
  
  <p>My question is as follows: </p>
  
  <p>The code tests in this particular test case. I know this is really long, but it's the only one that fails:</p>
  
  <p><strong>dictionary.txt</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>input</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>desired output</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>actual output</strong></p>
  
  <pre><code>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
  </code></pre>