How do I deal with spellings mistakes in text input ?

0 favourites
  • 8 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • I've got a new problem in my geography game, one of the game modes requires you to type in the names of the countries (for example here 20 random European countries are selected (in light blue) and you have to type in their names to colour them in green).

    To do this, I have a list of countries with a loop that compares what is written with what is in the list

    The problem with this method is that it leaves no room for possible spelling mistakes (or abbreviations such as UAE or USA). Is there a better way of doing this?

    https://i.imgur.com/OdMdzLg.png

    https://i.imgur.com/aHFZZ8h.png

  • What do you want to do about spelling errors? After all, Iran is not Iraq, so the user should probably spell it correctly to get the right answer.

    Anyways you can probably rely on the end user device's own spell checking and autocorrect capabilities for that (or intelligence).

    For abbreviations, just add them manually. There are only 195 countries in the world, and only a few of those have abbreviations, so it's not like your list will be inflated dramatically for adding an additional few more correct answers. Using OR conditions (among other methods, depending on how you have it set up), will allow you to have multiple valid answers per country.

  • To be honest, it's true that I hadn't thought about auto-correction, which doesn't correct all the problems, though, for example the country "São Tomé and Príncipe" is probably too unfamiliar for my phone to automatically set the accents. Is there a way to ignore accents when comparing 2 texts?

    However, I think you're right, I should just add the exceptions manually (your examples of Iran and Iraq were perfect for making me understand).

    thanks for your help

  • There are algorithms that let you find out how close one text is to another. Basically the number of character additions, deletions and replacements before the texts are identical.

    Here is one such algorithm:

    en.m.wikipedia.org/wiki/Levenshtein_distance

    I guess you could run that with the typed text and all the possible words, then use the closest one. Effectively it’s kind of your own spell checker with your own set of words. More likely you’d want to not consider words that are more than 5 edits away or something, and if there are multiple words with the same minimum distance away you could maybe show a suggestion to the user.

    You can tweak it further too. Most spell checkers consider adjacent keys as closer. Or transposed characters as being close too. I didn’t look further at different algorithms though. Anyways some ideas you could pursue.

  • it's really interesting but as oosyrag said

    "After all, Iran is not Iraq, so the user should probably spell it correctly to get the right answer."

    and because of that I think it's totally impossible to use this kind of algorithm

    however your post answers the question perfectly and I'm sure it will help people who have the same problem as me

  • Ok I was wrong, there are a lot more alternative spellings of countries than I knew of. But here is a handy list - en.wikipedia.org/wiki/List_of_alternative_country_names.

    It's still just a matter of building your list once though, it will just take some more work.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Add a Text Input, tick the 'Spell check' property, and the browser will use its built-in spellchecker for whatever is typed in.

  • AshleyI did it, but my game is designed for mobile and some country names like "São Tomé and Príncipe" are not corrected by my browser.

    Is making several lists a viable option? Or will it be too demanding in terms of resources? something like that:

    i.imgur.com/FKc1dZy.png

    (I've done some mistakes on the exemple cause I did it quickly but you got the idea)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)