import gradio as gr import difflib,time,numpy # Dictionary dictionaryFile=open('words.txt','r') # Open words file dictionary=dictionaryFile.readlines() # Read words file into list def check3(inp, inp2): if len(inp) > len(inp2): longest = inp shortest = inp2 else: shortest = inp longest = inp2 ls = len(shortest) ll = len(longest) out = 0 for i in range(ls): if shortest[i] in longest: out += 1 if shortest[i] == longest[i]: out += 2 return out - ((out-ls)*0.5) - (ll-ls) * 0.5 # Work def get_matches(text): # prepare text textR=str(text) textR=textR.split() # Some shitty code # Variables countl=0 queue=len(textR) output="" # try to correct it try: ##return(difflib.get_close_matches(text, dictionary)) #[0].replace("\n", "") for x in range(queue): output=output+str(textR[countl])+": "+str(difflib.get_close_matches(textR[countl], dictionary))+"\n" if countl<=queue: countl+=1 if countl>=queue: return(output) except Exception as ex: # Print error if error return(ex) iface = gr.Interface(fn=get_matches, inputs="text", outputs="text") iface.launch()