Spaces:
Running
Running
File size: 1,171 Bytes
ee2309a fb96dd8 024c34d 120d25d f33a2c3 fb96dd8 9cb4940 c449641 9cb4940 fb96dd8 134ecd7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
import pandas as pd
dictionary = pd.read_csv("corncob_lowercase.txt",
header = None,
sep = ' '
names = ['word'])
print(dictionary)
def spell_bee_solver(no_centre, centre):
no_centre_set = set(no_centre)
# spell_bee_solver = dictionary[dictionary['word'].str.contains(str(centre), regex = False)]
spell_bee_solver = dictionary
final_words = list()
for i in range(0, spell_bee_solver.shape[0]):
words = spell_bee_solver['word'].iloc[i]
words_set = set(words)
if len(words_set - no_centre_set) == 0:
final_words.append(words)
final_word_df = pd.DataFrame(final_words)
return(final_word_df)
with gr.Blocks() as app:
with gr.Row():
no_centre = gr.Textbox(label = 'Letters Outside of Centre')
centre = gr.Textbox(label = 'Centre Letter')
with gr.Row():
solve_button = gr.Button(value = 'Solve')
with gr.Row():
output_df = gr.DataFrame()
solve_button.click(spell_bee_solver, inputs = [no_centre, centre], outputs = [output_df])
app.launch(debug = True, share = False) |