I have a form with 2 rich-text-boxes (one on top of the other) and 2 buttons. The top box is the master text (string) and the bottom box is the entry text (string). Every contestant is sending a text to an email account, from the email we copy and paste the text into the Entry RTB and compare to the Master RTB. For each single word and single space counts as a thing to check. And for every error add 1 sec. to their time.
Examples:
- Hello there! <= 3 checks (2 words and 1 space)
- Helothere! <= 2 errors (Helo and space)
- Hello there!! <= 1 error (extra ! at end of there!)
- Hello there! How are you? <= 9 checks (5 words and 4 spaces)
- Helothere!! How a re you? <= still 9 checks, 4 errors(helo, no space, extra !, and a space in are)
- Hello there!@ Ho are yu?? <= 3 errors (@ at end of there!, no w, no o and extra ? (all errors are still under the 1 word)
I've created 6 arrays (3 for master, 3 for entry) and they are
- Char array of all chars
- String array delimited with " " and also counting the " "
- Int array with length of the string in each string array
I hope I have made myself clear enough as to what I need help with. If anyone could give some code examples or something to shoot me in the right path would be very helpful.
Suthish NairPosted Mar 21, 2011, 12:49 PM
KaktusJackPosted Mar 21, 2011, 11:43 AM
VulpesPosted Mar 21, 2011, 6:09 AM
It's been an interesting exercise to try and come up with something though because, as Sam said, questions like this are rarely asked on C# forums.
KaktusJackPosted Mar 20, 2011, 11:43 PM
I thank you all for trying to help! Especially you Vulpes. After countless hours and a weeks worth of work I decided to accept defeat and just use the Levenshtein Distance Algorithm and just change the error management. I went through so many ideas and trials that none was what I was looking for (although Vulpes's last code was the closest by far). I even tried to treat the situation as I was entering the entry text one character at a time and it worked great for a bit....I was so close, real close but oh well.
Again thanks to all who tried to help.
KaktusJack
My other post:
http://stackoverflow.com/questions/5335244/how-to-compare-2-strings-with-int-out-of-errors
KaktusJackPosted Mar 20, 2011, 9:48 PM
I'm going to implement a cap check with your code and see if that helps.
I do have one question about the code you posted tho.
if(words.Length == 1) return 1; // we know they're not the same so 1 error
I'm not sure as what this was supposed to do. I commented it out and it still worked and as far as logic I would think that but it doesn't check anything to know they're not the same. So that was kind of my question.
{KJ}
VulpesPosted Mar 20, 2011, 4:48 AM
KaktusJackPosted Mar 19, 2011, 11:15 PM
Sam HobbsPosted Mar 18, 2011, 4:59 PM
VulpesPosted Mar 18, 2011, 3:15 PM
KaktusJackPosted Mar 18, 2011, 12:55 PM
VulpesPosted Mar 18, 2011, 8:16 AM
I'm sure there will be some other cases we haven't considered which it won't cope with either but FWIW here it is:
using System;
KaktusJackPosted Mar 17, 2011, 11:54 PM
thanks for replying.
Sam HobbsPosted Mar 17, 2011, 11:22 PM
KaktusJackPosted Mar 17, 2011, 10:30 PM
In my head:
first check if strings match if they do then its done. if not then check StringArray if they compare. If they do, for loop and continue until they don't. If they don't then manage somehow to check the CharPerString.Length to see if the lengths are the same. If not then 1 error. Problem starts here if the space is missing and the second word is part of first word. Then I think that maybe we check if next mStringArray index is space, if so continue to next mStringArray. If the substring is found in first word then we have to do something to get it to count 1 for word1 and 1 for space then check for word two and start from there again to continue. Or check the two words on each side of the first space then compare to the first 3 entry ones. If words or substrings are found and blabla then we have to check to see if the spaces are right......
Wow! Look at me go. Ok.
Maybe this will help someone with a greater knowledge of the C# language to do more with that train of thought.
VulpesPosted Mar 17, 2011, 8:40 PM
KaktusJackPosted Mar 17, 2011, 1:49 PM
VulpesPosted Mar 17, 2011, 1:18 PM
However, this isn't a very sophisticated way of doing things and, when I have a bit more time, I'll have another think about it.
KaktusJackPosted Mar 17, 2011, 1:03 PM
Suthish NairPosted Mar 17, 2011, 12:13 PM
string[] master = ("Hello there!").Split(' ');
VulpesPosted Mar 17, 2011, 10:13 AM
KaktusJackPosted Mar 17, 2011, 3:31 AM
Krishna GaradPosted Mar 17, 2011, 3:16 AM