def print_menu(): print("MENU:\n") print("(P)ronunciation - Using IPA \n") print("(D)ictionary - English/Klingon word lookup\n") print("(F)lashcard Game - Randomly selected words in both Klingon and English\n") print("(T)ranslate\n") print("(C)ommon Phrases - Bootstrap your tlhngan Hol knowledge\n") print("(A)bout\n") print("(Q)uit\n") choice = input("Select an option from above:") if choice.upper() == 'P': print("FOO") elif choice.upper() == "T": Translator.translate(None) elif choice.upper() == 'F': Flashcard.loaddeck(20) elif choice.upper() == 'D': Dictionary.loadDictionary('dictionary') Dictionary.lookup(None) elif choice.upper() == 'C': CommonPhrases.loadPhrases() elif choice.upper() == 'Q': exit() else: print_menu()
def loadfiles(): Dictionary.loadDictionary('dictionary') global suffixes, modals, person, imperitive file = FileHandler.loadFile("Resources/person.csv", "r") for line in file: line = line.strip() p = line.split(',') print(len(p)) person.update({p[0]: [p[1], p[2], p[3], p[4], p[5], p[6], p[7]]}) file.close() file = FileHandler.loadFile("Resources/modals.csv", "r") for line in file: line = line.strip() p = line.split(',') modals.update({p[0]: [p[1]]}) file.close() file = FileHandler.loadFile("Resources/suffixes.csv", "r") for line in file: line = line.strip() p = line.split(',') # print(str(p)) suffixes.update({p[0]: [p[1]]}) file.close() file = FileHandler.loadFile("Resources/imperative.csv", "r") for line in file: line = line.strip() p = line.split(',') imperitive.update({p[0]: [ p[1], p[2], p[3], p[4]]})
def search(): ret = str(request.args['query']) Dictionary.loadDictionary('dictionary') #retString = LoadDictionary.lookup(ret) ret = Dictionary.lookup(ret) retHtml = "" for item in ret: retHtml += "<div class='well well-sm'>" retHtml += str(item) retHtml += "</div>" return retHtml
def loaddeck(numcards): global deck tempDict = OrderedDict(Dictionary.loadDictionary("klingon")) tempDeck = [] for key, value in tempDict.items(): item = {key, value} tempDeck.append(item) x = 0 while x < numcards: num = random.randrange(0, len(tempDeck) - 1) deck.append(tempDeck[num]) del (tempDeck[num]) x += 1 menu()