File size: 1,997 Bytes
127f052
 
b33e0d1
3426c39
 
 
 
 
 
 
 
 
 
 
 
 
2706b2b
3426c39
 
2706b2b
 
 
 
 
3426c39
 
 
2706b2b
 
 
 
b33e0d1
3426c39
 
 
 
 
b33e0d1
3426c39
 
 
 
 
1533e2a
3426c39
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
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr

def calc_input_reading_level(input_text):
    # Placeholder for actual implementation of the reading level calculation.
    return len(input_text) % 10  # Random operation as a placeholder for demonstration.

def generate_and_analyze_text(input_text, target_level):
    # Placeholder for generating text and analyzing it against the target level.
    output_text = input_text[::-1]  # Reversing text as a simple example operation.
    output_reading_level = int(target_level)  # Placeholder for demonstration.
    similarity = 0.75  # Fixed similarity value for demonstration.
    input_level = calc_input_reading_level(input_text)  # Reuse the reading level calc for input level.
    return input_level, output_text, output_reading_level, similarity

with gr.Blocks() as app:
    with gr.Row():
        with gr.Column(scale=1):
            input_text1 = gr.Textbox(label="Input Text for Reading Level")
            button1 = gr.Button("Calculate Reading Level")
        with gr.Column(scale=1):
            input_reading_level = gr.Textbox(label="Input Text Reading Level")

    with gr.Row():
        with gr.Column(scale=1):
            input_text2 = gr.Textbox(label="Input Text for Generation")
            target_level = gr.Dropdown(choices=["1", "2", "3", "4", "5"], label="Target Reading Level")
            button2 = gr.Button("Generate and Analyze Text")
        with gr.Column(scale=1):
            output_text = gr.Textbox(label="Output Text")
            output_reading_level = gr.Textbox(label="Output Text Reading Level")
            output_text_similarity = gr.Textbox(label="Output Text Similarity to Input Text")

    button1.click(
        fn=calc_input_reading_level,
        inputs=input_text1,
        outputs=input_reading_level
    )

    button2.click(
        fn=generate_and_analyze_text,
        inputs=[input_text2, target_level],
        outputs=[input_reading_level, output_text, output_reading_level, output_text_similarity]
    )

app.launch()