Example #1
0
def handle(f=None, buf=None):
    if f:
        buf = codecs.open(f, 'r','utf8').read()

    if not buf:
        return

    ws = prehandler(split(buf))
    return SplitParagraph(ws, 0)
Example #2
0
def texstohtml(src, o):
    import traceback
    try:
        words = prehandler(split(src))
        html = SplitParagraph(words, 0).html()
    except:
        html = '<pre>%s</pre>' % traceback.format_exc()


    f = codecs.open(o, 'w','utf8')
    f.write(html)
Example #3
0
def generate_suggestions(words):
  """
  Creates a list of words to send back to the app. This function will be
  called whenever a query in the app returns an empty list of specialties or 
  codes, so it first checks if the word is actually misspelled or just not
  in the database.
  """
  word_list = words.split()
  suggestions = []

  for word in word_list:
	 word.lower()
    # confirm the word is misspelled
	 if word not in NWORDS:
		  suggestions[-1:] = correct(word)
  return suggestions
Example #4
0
def open_source_to_words(f):
    f = codecs.open(f, 'r','utf8')
    return split(f.read())
Example #5
0
import random
import words

words = words.words()
wordCollection = list(words.split())
randomNumber = random.randint(0, len(wordCollection) - 1)
chosenWord = wordCollection[randomNumber].lower()
unknownWord = ""
health = 10

for letter in range(len(chosenWord)):
    unknownWord += "*"
print(unknownWord)
gameState = True
while gameState == True:

    guessedLetter = input("Enter Your Guess: ")
    if guessedLetter in chosenWord:
        for i in range(len(chosenWord)):
            if chosenWord[i] == guessedLetter:
                guessedIndex = chosenWord.index(guessedLetter)
                unknownLst = list(unknownWord)
                unknownLst[i] = chosenWord[i]
                unknownWord = "".join(unknownLst)
                unknownWord = unknownWord

        print("Correct guess!")
        print("Current health is: ", health)
        print(unknownWord)
        print("-----------------")
        print("")