Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import cgi,words,cgitb
  3. cgitb.enable()
  4. print "Content-type: text/html\n\n"
  5. print """
  6. Search in our beloved dictionary.<br/>
  7. <form method = 'get' action = ''>
  8. <input type = 'text' name = 'wor
  9. <input type = 'submit' value = 'Search'/>
  10. </form>
  11. """
  12. english_dict = words.words
  13. form = cgi.FieldStorage()
  14. if form.has_key('word'):
  15. word = form['word'].value
  16. word = word.split()
  17. filters = ['and','but','or','so','there','was','a','is','an','of']
  18. for x in filters:
  19. if x in word:
  20. word.remove(x)
  21. word_value = len(word)
  22. for x in english_dict:
  23. t = 0
  24. for words in word:
  25. if words in english_dict[x]:
  26. t = t+1
  27. if t == word_value:
  28. print "<b>"+x+"</b>: "+english_dict[x]+"<br/>"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement