Spaces:
Running
Running
bradley6597
commited on
Commit
•
7bd6a90
1
Parent(s):
2a71eed
Get answers directly from website
Browse filesAdded a way of getting answers directly from the SpellBee website.
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
|
|
3 |
|
4 |
english_dict = pd.read_csv("dictionary.txt",
|
5 |
header = None,
|
@@ -24,14 +25,29 @@ def spell_bee_solver(no_centre, centre):
|
|
24 |
final_word_df = final_word_df.sort_values('word_length', ascending = False)
|
25 |
return(final_word_df)
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
with gr.Blocks() as app:
|
28 |
with gr.Row():
|
29 |
no_centre = gr.Textbox(label = 'Letters Outside of Centre')
|
30 |
centre = gr.Textbox(label = 'Centre Letter')
|
31 |
with gr.Row():
|
32 |
solve_button = gr.Button(value = 'Solve')
|
|
|
33 |
with gr.Row():
|
34 |
output_df = gr.DataFrame(headers = ['word', 'word_length'])
|
35 |
solve_button.click(spell_bee_solver, inputs = [no_centre, centre], outputs = [output_df])
|
|
|
36 |
|
37 |
app.launch(debug = True, share = False)
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
+
from requests_html import HTMLSession
|
4 |
|
5 |
english_dict = pd.read_csv("dictionary.txt",
|
6 |
header = None,
|
|
|
25 |
final_word_df = final_word_df.sort_values('word_length', ascending = False)
|
26 |
return(final_word_df)
|
27 |
|
28 |
+
def get_todays_answers():
|
29 |
+
with HTMLSession() as session:
|
30 |
+
page = session.get(url)
|
31 |
+
valid_words = page.html.render(script = 'game.validWords')
|
32 |
+
|
33 |
+
final_word_df = pd.DataFrame(valid_words, columns = ['word'])
|
34 |
+
final_word_df['word_length'] = final_word_df['word'].str.len()
|
35 |
+
final_word_df = final_word_df[final_word_df['word_length'] > 3]
|
36 |
+
final_word_df = final_word_df.sort_values('word_length', ascending = False)
|
37 |
+
return(final_word_df)
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
with gr.Blocks() as app:
|
42 |
with gr.Row():
|
43 |
no_centre = gr.Textbox(label = 'Letters Outside of Centre')
|
44 |
centre = gr.Textbox(label = 'Centre Letter')
|
45 |
with gr.Row():
|
46 |
solve_button = gr.Button(value = 'Solve')
|
47 |
+
get_today_answers = gr.Button(value = "Get Today's answers")
|
48 |
with gr.Row():
|
49 |
output_df = gr.DataFrame(headers = ['word', 'word_length'])
|
50 |
solve_button.click(spell_bee_solver, inputs = [no_centre, centre], outputs = [output_df])
|
51 |
+
get_today_answers.click(get_todays_answers, inputs = None, outputs = [output_df])
|
52 |
|
53 |
app.launch(debug = True, share = False)
|