Example #1
0
def condition(word):
    if word in data:
        return condition(word)
    elif len(g(word, data.keys())) > 0:
        e1 = Entry(window)
        if e1.get() == "y":
            return condition(data[g(word, data.keys()[0])])
        elif e1.get() == "n":

            return w
        else:
            return w
    else:
        return w
Example #2
0
def meaning():

    w = e1_value.get()

    if w in data:
        for i, j in enumerate(data[w]):
            t1.insert(END, str(i) + ' ' + j + '\n')
    elif w.upper() in data:
        for i, j in enumerate(data[w.upper()]):
            t1.insert(END, str(i) + ' ' + j + '\n')
    elif w.title() in data:
        for i, j in enumerate(data[w.title()]):
            t1.insert(END, str(i) + ' ' + j + '\n')
    else:
        list = g(w, keys, n=1, cutoff=0.8)
        if len(list) == 0:
            t1.insert(END, "Sorry, no word found!")
        else:
            real = list[0]
            answer = tkinter.messagebox.askquestion(
                "Word Suggestion", "Is your word " + real + "?")

            if answer == "yes":
                for i, j in enumerate(data[real]):
                    t1.insert(END, str(i) + ' ' + j + '\n')
            #elif x == "yes":
            #for i, j in enumerate(data[real]):
            #t1.insert(END,str(i)+' '+j+'\n')
            else:
                t1.insert(
                    END,
                    "Apologies, no word found. Please check your input word again."
                )
def meaning():
    w = e1_value.get()

    if w in data:
        for i, j in enumerate(data[w]):
            t1.insert(END, str(i) + ' ' + j + '\n')
    elif w.upper() in data:  #in case user enters words like USA or NATO
        for i, j in enumerate(data[w.upper()]):
            t1.insert(END, str(i) + ' ' + j + '\n')
    elif w.title(
    ) in data:  #if user entered "texas" this will check for "Texas" as well.
        for i, j in enumerate(data[w.title()]):
            t1.insert(END, str(i) + ' ' + j + '\n')
    else:
        list = g(w, keys, n=1, cutoff=0.8)
        if len(list) == 0:
            t1.insert(END, "The word doesn't exist. Please double check it.")
        else:
            real = list[0]
            answer = tkinter.messagebox.askquestion(
                "Word Suggestion", "Is Your Word " + real + "?")

            if answer == "yes":
                for i, j in enumerate(data[real]):
                    t1.insert(END, str(i) + ' ' + j + '\n')
            else:
                t1.insert(
                    END,
                    "Apologies, No Word Found, Please Recheck Your Input Word."
                )
def translate():

    w = e1_value.get()

    if w in data:
        for i, j in enumerate(data[w]):
            t1.insert(END,str(i)+' '+j+'\n')
    elif w.upper() in data:
        for i, j in enumerate(data[w.upper()]):
            t1.insert(END,str(i)+' '+j+'\n')
    elif w.title() in data:
        for i, j in enumerate(data[w.title()]):
            t1.insert(END,str(i)+' '+j+'\n')
    else:
        list=g(w,keys,n=1,cutoff=0.8)
        if len(list) == 0:
            t1.insert(END,"No word found!")
        else:
            real=list[0]
            answer=tkinter.messagebox.askquestion("Did you mean-" +real+ "?")
            
            if answer == "yes":
                for i, j in enumerate(data[real]):
                    t1.insert(END,str(i)+' '+j+'\n')
           
            else:
                t1.insert(END,"No word found. Please check again")
Example #5
0
def define(word):
    w = word.lower()  # lowercase version of word
    w2 = w.capitalize(
    )  # capitalized version of word for proper nouns, like 'Texas'.
    w3 = w.upper()  # upercase version of word for acronymns like 'USA'.
    if w in data or w2 in data or w3 in data:
        if w in data:
            return (data[w])
        elif w2 in data:
            return (data[w2])
        elif w3 in data:
            return (data[w3])
    else:
        close_matches = g(w, data.keys())
        if len(close_matches) > 0:
            test = close_matches[0]
            inp = input(f"Did you mean {test}? (Y/N): ")
            if inp == "Y":
                return data[test]
            elif inp == "N":
                return f"The word {w} does not exist. Please double check it."
            else:
                return "User input not recognized. Exiting..."
        else:
            return f"The word {w} does not exist. Please double check it."
Example #6
0
def define(word):
    w = word.lower()
    if w in data:
        return(data[w])
    else:
        close_matches = g(w, data.keys())
        if len(close_matches) > 0:
            test = close_matches[0]
            inp = input(f"Did you mean {test}? (Y/N): ")
            if inp == "Y":
                return data[test]
            elif inp == "N":
                return f"The word {w} does not exist. Please double check it."
            else:
                return "User input not recognized. Exiting..."
        else: 
            return f"The word {w} does not exist. Please double check it."