- Home /
importing english dictionary as text file?
Is there any way to import the english dictionary as a text file? Or a way to reference the english dictionary through code in order to compare a user defined string.
For example: If the player types in a word, how can i compare the word the player typed to determine if it is an actual english word?
Such as:
//Does the (English Dictionary) contain the word that the player input? If so, do something.....
Answer by HenryStrattonFW · Mar 01, 2017 at 08:07 PM
There is, but you need a file that contains all of the valid English words that you want to allow use of. You would have to locate one such file for yourself however as it does not exist as part of Unity. Once you have the file, you'd just have to load it in and use it to validate your content (various methods of doing this, either process the file into a dictionary/list and then compare by looking for the word, or just searching the raw text of the file for a matching string, there's probably some really fancy regex line that would do that, but that stuff is like magic.
There may alternatively be online API services that would support this, never known of one myself, but given that the English language doesn't change all that frequently this is probably unnecessary as a dictionary file would more than suffice for most cases in terms of being up to date.
A quick search gave me this link http://wordlist.aspell.net/ which looks like it could be a useful resource
EDIT: Had a quick look over that wordlist site, has a n ice online tool to generate a list based on some customizable options (include spelling variations, americanized variations etc). However it does seem to include a bunch of letter combinations at the start that i wouldn't really consider words, so you may want to trim some of those off if you use this resource.
Your answer
Follow this Question
Related Questions
Comparing string to a dictionary entry? 0 Answers
How to take the text from a rich text input field and save each line into an array 1 Answer
GUI Text manipulation - flexible enough for my project? 2 Answers
Split Textasset into List 1 Answer
Printing text one by one, and changing text colors using Markup 0 Answers