Note that there are some explanatory texts on larger screens.

plurals
  1. POC# check given word to answer word
    primarykey
    data
    text
    <p>I'm making a simple spell checker for C#, I want to try and compare a given answer to the randomly chosen word.</p> <p>I want to compare the first letter to all the letters given in the answer so I can tell if it's correct, it's there was a swap of letters, a deletion or an added letter. I would ultimately like to be able to tell if only one letter was wrong to see a substitution was used.</p> <p>For example, correct answer hello:</p> <pre><code> checking first letter ~H h e l l o 1 0 0 0 0 h h e l l o 1 1 0 0 0 0 e l l o 0 0 0 0 </code></pre> <p>Then go through it for the second letter.</p> <p>I've absolutely no idea when it comes to C#.</p> <p>I've tried </p> <pre><code>int CheckErrors(string Answer, string Guess) { if (Answer == Guess) { return 1; } if (Answer == null || Guess == null) { return -1; } for (int i = 0; i &lt;= Answer.Length; i++) { if (Guess[i] != Answer[i]) { count++; //substitution = -4 //deletion = -5 //transposition = -6 //insertion = -7 } return count; } return -9; } </code></pre> <p>but I just can't get any further.</p> <p>UPDATE:</p> <p>with further research I guess what I was trying to do is something like:</p> <pre><code>STRING answer = answer_given STRING input = correct_answer int check = 0; FOR (int i = 0; i &lt; input.Length; i++) { FOR (int ii = 0; ii &lt; answer.Length; ii++) { if (input[i] == answer[i]) { int check++; } } } </code></pre> <p>Obviously I know this would keep adding check up, but I can't guess what how else to do it.</p> <p>ANOTHER UPDATE!</p> <p>I can use this-</p> <pre><code>int CheckErrors(string Answer, string Guess) { int[,] d = new int[Answer.Length + 1, Guess.Length + 1]; for (int i = 0; i &lt;= Answer.Length; i++) d[i, 0] = i; for (int j = 0; j &lt;= Guess.Length; j++) d[0, j] = j; for (int j = 1; j &lt;= Guess.Length; j++) for (int i = 1; i &lt;= Answer.Length; i++) if (Answer[i - 1] == Guess[j - 1]) d[i, j] = d[i - 1, j - 1]; //no operation else d[i, j] = Math.Min(Math.Min( d[i - 1, j] + 1, //a deletion d[i, j - 1] + 1), //an insertion d[i - 1, j - 1] + 1 //a substitution ); return d[Answer.Length, Guess.Length]; } </code></pre> <p>But I need a way to do a count for the amount of times each error is used?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload