I am developing a Windows Phone app that requires users to type in valid words that would be in a standard English dictionary. I’m a little confused, however, as to how to go about checking that a word is real. Does anyone know of a good dictionary API to interact with, or will I need to add a word list to my app as a text file?
Share
This link seems to indicate that the spell checking API is not exposed to the developer, although there is at least one third party product that claims it provides an API-based solution (which also has an evaluation with which you can test how it works).
As to how you implement this feature if you cannot use a third party product, the problem with English is every other language 🙂 By that, I mean, it wasn’t necessarily that consistent to begin with, and it has “lifted” words from dozens of other languages.
Hence there are no really decent rules that can tell you if a word is valid.
You’ll need to maintain a dictionary and, given the bizarre corners of the language, you’ll probably have to restrict it to common words (and, if space is an issue, short ones as well).
And, by the way, if you do go the self-written dictionary-based approach, you can use a little trick I learnt many years ago.
You can encode each word as:
So the word list
You’re saving 7 bytes straight up there (19%) and I suspect the saving would be similar for a 20,000 word dictionary just due to the minimum distances between (ie, common prefixes of) adjacent words.
To speed lookup, you can also maintain a 26-entry table in memory which held the starting offsets for words beginning with
a,b,c, …,z. The words at these offsets always will automatically have 0 as the first byte as they have no letters in common with the previous word.