A few days ago I was searching for a string method in Google. As soon as I had typed in "string", Google Suggest popped in with the following suggestions:
I was amused. Then I thought, what if there were a game where you had to go from cheese, theory, bikini back to "string"? After finding Google's convinient Suggest API, I wrote it in about 25 minutes. The game picks a common word and displays the suggest results - you have to find the connection between them. It's pretty fun. Here are some examples (find the missing word).
***ne state university
*** back into love lyrics
*** back into love
*** back machine
***s of our lives
***s of our lives spoilers
***ton daily news
*** of the dead
***light savings time
***s inn hotels
***** of warcraft
***** war 2
***** series of poker
**** warner cable
I have some ideas for improvements, but this is the half-hour version.
You'll need a word list. The nouns in http://en.wikipedia.org/wiki/Most_common_words_in_English worked well.
Enter q to quit, or n for the next word if you give up.
# Works in Python 2.5, needs internet connection
g_restr = re.compile('<suggestion data="([^"]+)"/>')
astrWords = 'fact,child,problem,part,hand,case'.split(',')
# Put another word list, separated by commas,into the above string.
res = nextword(astrWords[i])
if res == False: return
strUrl = 'http://google.com/complete/search?output=toolbar&q=' + strWord
f = urllib.urlopen(strUrl)
strXml = f.read()
strBlank = '*' * len(strWord)
for match in g_restr.findall(strXml):
print match.replace(strWord, strBlank)
strGuess = raw_input(':')
if strGuess.lower() == strWord.lower():
if strGuess == 'q':
elif strGuess == 'n':
print 'You gave up.'
Answers to the examples are "way", "day", "world", and "time." Have fun!