What would be the best way to go about getting a function that returns a random English word (preferably a noun), without keeping a list of all possible words in a file before hand?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You can't. There is no algorithm to generate meaningful words. You can only generate words that sound like English, but they won't have any meaning.
There's a random word generator here - it's not English but it's English-ish, i.e. the words are similar enough to language that a user can read the words and store them in short-term memory.
Source code is in C# and a bit kludged, but you could use a similar approach in Python to generate lots of words without having to store a massive list.
Alternatively, you could call the web service on the demo page directly - it's hosted on GoDaddy though, so no guarantees it will work in production!