Java – random generation of meaningful (valid) English words in Android Applications
I'm applying for a dictionary. I also use the Pearson dictionary API. I need to generate a word so that I can query the definition of the word
problem
I know how to generate a random word, but I don't know how to generate a meaningful English word
I try to solve this problem by requesting a JSON response and checking the result [] (the result [] retains the definition of the word) in the response. Therefore, if the result []. Lenght > 0, the word is a valid English word
But the above solution has a serious problem: suppose I want to generate a 5-letter word with up to 26 ^ 5 = 11881376 different combinations, but no meaningful English words with 5 letters. With the increase of letters in the word, the number of combinations also increases. Therefore, it may take a long time to generate meaningful words
How to check whether the generated words are meaningful English words? Is there a viable programming way to do this?
Or is there another way to solve this problem?
resolvent:
As far as I know, you can generate random letter strings and check whether they are words (as you know, this is a slow hit or failure method), or store the word "known good" and select them randomly from the list
How big the list needs depends on what you want to achieve
According to this page, OED has about 171476 main entries, excluding plural forms (cat, cat), standard variants (sit, sit) or words with multiple categories (for example, dogs can be nouns [animals] or verbs) [continuous attention], etc.). According to the data of this page, an adult knows an average of 20000 to 35000 words. Therefore, careful selection of 50000 words should cover most general purposes
The answer to this question (now closed) provides the source of many word lists. Checking one of them (originally provided by infochimps.org, but can be provided as simple text list on GitHub) shows that the average 350000 words are less than 10 characters long. For Linux (there may be other flavors), / usr / share / dict / words may be a useful starting point