Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

alexandergre

macrumors member
Original poster
Jul 28, 2009
58
0
my app is about learning the Swedish language.
the use taps on PLAY button. A voice will say a word. e.g: "Sweden is great".(but in swedish)
The user writes what he heard.

But when is come to comparing the users answer and the source text, Im in a big trouble.

Code:
source text= @"Sweden is great";
inputText=@"Sweden iz great";
int correctWords = 0;

how can I compare so that the user gets 1 point for each correct word?
I found some help here but I dont get a single line. search for NSString Class Reference in Xcode documentation.

Thank you very much.
Please help me! :( ;)
 
You could either use NSScanner to break up the strings into words or use componentsSeparatedByString or componentsSeparatedByCharactersInSet to break up the strings into words. Compare using isEqualToString or possibly using one of the compare methods so you can have more options for the comparison. I strongly recommend that you not use characterAtIndex for comparisons between strings because of the complications of unicode.

Frankly this kind of comparison will be a little tricky. How many points does this get:

@"Sweden is not great"
 
Thank you very much for the reply.

Frankly this kind of comparison will be a little tricky. How many points does this get:

@"Sweden is not great"
Yes, thats a tricky one. Im thinking about that right now. :)

well if source has 3 words in it and the user types 4 words then
only the first three words are counted/go to comparison.
and he will get -2 points because of 1 extra word & 1 wrong word.

Shall I put the Source words in an array and the input words in another one?
 
Could you not save yourself a tonne of effort and just have a multiple choice answer list for the user to select an answer from? Heck you could even do a nice interface similar to the way you play hangman where you have the structure of the sentence displayed as blank boxes and you could drag the correct words from a list of jumbled up words to fill in the blanks.

To do this the way you want to do it, you will need some pretty advanced algorithm that is aware of differences in language structure and as dejo mentioned, multiple meanings for words + probably a lot of other things I haven't even thought of. Not doing this perfectly could and WILL result in bad reviews from frustrated customers. Learning a new language is hard enough as it is and the tool you are using to learn it with should not be a barrier in any way, shape or form.

Just my 2 cents but definitely food for thought
 
is there a way to shorten this code:
Code:
	NSMutableArray *Words = [NSMutableArray array];
	[Words addObject:@"cat"];
	[Words addObject:@"dog"];
	[Words addObject:@"Search"];
	[Words addObject:@"computer"];
	[Words addObject:@"space"];
	[Words addObject:@"Dog"];
 
Code:
NSMutableArray *words = [NSMutableArray arrayWithObjects:@"cat",@"DOG",@"Horse",@"Hemma",@"House",@"Mouse", nil];
Dude, you need to get a book on Objective-C.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.