Spaces:
Sleeping
Sleeping
Commit
•
0ae62b7
1
Parent(s):
41adfee
Upload 2 files
Browse files- app.py +10 -32
- text_converter.py +0 -1
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
from text_converter import fre_levels, sbert_levels, model_types, generate_similar_sentence, user_input_readability_level
|
3 |
|
4 |
APP_DESCRIPTION = '''# Reading Level Converter
|
5 |
<div id="content_align">Convert any text to a specified reading level while retaining the core text meaning</div>'''
|
@@ -21,36 +21,14 @@ with gr.Blocks(css='styles.css') as app:
|
|
21 |
gr.Markdown(APP_DESCRIPTION)
|
22 |
|
23 |
with gr.Tab("FRE"):
|
24 |
-
with gr.Row():
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
fetch_score_and_lvl_btn.click(
|
32 |
-
fn=user_input_readability_level,
|
33 |
-
inputs=[input_text, "FRE"],
|
34 |
-
outputs=[output_input_reading_score, output_input_reading_level]
|
35 |
-
)
|
36 |
-
|
37 |
-
grade_level = gr.Radio(choices=list(fre_levels.keys()), label="Target Reading Level", value = list(fre_levels.keys())[0], interactive=True)
|
38 |
-
|
39 |
-
output_reading_level = gr.Textbox(label="Output Reading Level", placeholder="Output Reading Level...", lines=1)
|
40 |
-
output_similarity = gr.Textbox(label="Similarity", placeholder="Similarity Score...", lines=1)
|
41 |
-
output_converted_text = gr.Textbox(label="Converted Text", placeholder="Results will appear here...", lines=4)
|
42 |
-
|
43 |
-
output_message = gr.Textbox(label="Message", placeholder="System Message...", lines=2)
|
44 |
-
|
45 |
-
convert_button = gr.Button("Convert Text")
|
46 |
-
|
47 |
-
convert_button.click(
|
48 |
-
fn=convert_text,
|
49 |
-
inputs=[input_text, grade_level, output_input_reading_score, "FRE"],
|
50 |
-
outputs=[output_converted_text, output_similarity, output_reading_level, output_message]
|
51 |
)
|
52 |
|
53 |
-
with gr.Tab("SBERT"):
|
54 |
with gr.Row():
|
55 |
input_text = gr.Textbox(label="Input Text", placeholder="Type here...", lines=4, scale = 2)
|
56 |
fetch_score_and_lvl_btn = gr.Button("Fetch Score and Level", scale = 1)
|
@@ -60,11 +38,11 @@ with gr.Blocks(css='styles.css') as app:
|
|
60 |
|
61 |
fetch_score_and_lvl_btn.click(
|
62 |
fn=user_input_readability_level,
|
63 |
-
inputs=[input_text,
|
64 |
outputs=[output_input_reading_score, output_input_reading_level]
|
65 |
)
|
66 |
|
67 |
-
grade_level = gr.Radio(choices=list(
|
68 |
|
69 |
output_reading_level = gr.Textbox(label="Output Reading Level", placeholder="Output Reading Level...", lines=1)
|
70 |
output_similarity = gr.Textbox(label="Similarity", placeholder="Similarity Score...", lines=1)
|
@@ -76,7 +54,7 @@ with gr.Blocks(css='styles.css') as app:
|
|
76 |
|
77 |
convert_button.click(
|
78 |
fn=convert_text,
|
79 |
-
inputs=[input_text, grade_level, output_input_reading_score,
|
80 |
outputs=[output_converted_text, output_similarity, output_reading_level, output_message]
|
81 |
)
|
82 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from text_converter import fre_levels, sbert_levels, model_types, generate_similar_sentence, user_input_readability_level, set_reading_levels
|
3 |
|
4 |
APP_DESCRIPTION = '''# Reading Level Converter
|
5 |
<div id="content_align">Convert any text to a specified reading level while retaining the core text meaning</div>'''
|
|
|
21 |
gr.Markdown(APP_DESCRIPTION)
|
22 |
|
23 |
with gr.Tab("FRE"):
|
24 |
+
#with gr.Row():
|
25 |
+
readability_model = gr.Radio(choices=model_types, label="Readability Model", value = model_types[0], interactive=True)
|
26 |
+
readability_model.click(
|
27 |
+
fn=set_reading_levels,
|
28 |
+
inputs=[readability_model],
|
29 |
+
outputs=[]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
)
|
31 |
|
|
|
32 |
with gr.Row():
|
33 |
input_text = gr.Textbox(label="Input Text", placeholder="Type here...", lines=4, scale = 2)
|
34 |
fetch_score_and_lvl_btn = gr.Button("Fetch Score and Level", scale = 1)
|
|
|
38 |
|
39 |
fetch_score_and_lvl_btn.click(
|
40 |
fn=user_input_readability_level,
|
41 |
+
inputs=[input_text, readability_model],
|
42 |
outputs=[output_input_reading_score, output_input_reading_level]
|
43 |
)
|
44 |
|
45 |
+
grade_level = gr.Radio(choices=list(fre_levels.keys()) if readability_model == model_types[0] else list(sbert_levels.keys()), label="Target Reading Level", interactive=True)
|
46 |
|
47 |
output_reading_level = gr.Textbox(label="Output Reading Level", placeholder="Output Reading Level...", lines=1)
|
48 |
output_similarity = gr.Textbox(label="Similarity", placeholder="Similarity Score...", lines=1)
|
|
|
54 |
|
55 |
convert_button.click(
|
56 |
fn=convert_text,
|
57 |
+
inputs=[input_text, grade_level, output_input_reading_score, readability_model],
|
58 |
outputs=[output_converted_text, output_similarity, output_reading_level, output_message]
|
59 |
)
|
60 |
|
text_converter.py
CHANGED
@@ -61,7 +61,6 @@ def set_reading_levels(level_type):
|
|
61 |
inverse_reading_levels = {v: k for k, v in reading_levels.items()}
|
62 |
|
63 |
def user_input_readability_level(input_text, model_type):
|
64 |
-
set_reading_levels(model_type)
|
65 |
current_score = ping_api(input_text, model_type)
|
66 |
print(f'Reading score for user input is: {current_score} for model type: {model_type}')
|
67 |
current_level = ''
|
|
|
61 |
inverse_reading_levels = {v: k for k, v in reading_levels.items()}
|
62 |
|
63 |
def user_input_readability_level(input_text, model_type):
|
|
|
64 |
current_score = ping_api(input_text, model_type)
|
65 |
print(f'Reading score for user input is: {current_score} for model type: {model_type}')
|
66 |
current_level = ''
|