예제 #1
0
파일: __init__.py 프로젝트: ChellsChen/wind
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)
예제 #2
0
파일: __init__.py 프로젝트: ChellsChen/wind
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)
예제 #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
예제 #4
0
def open_source_to_words(f):
    f = codecs.open(f, 'r','utf8')
    return split(f.read())
예제 #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("")