Spaces:
				
			
			
	
			
			
		Build error
		
	
	
	
			
			
	
	
	
	
		
		
		Build error
		
	Separating functions
Browse files
    	
        app.py
    CHANGED
    
    | @@ -1,25 +1,29 @@ | |
| 1 | 
             
            import gradio as gr
         | 
| 2 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 3 | 
             
            def calc_input_reading_level(input_text):
         | 
| 4 | 
            -
                #  | 
| 5 | 
             
                return len(input_text) % 10  # Random operation as a placeholder
         | 
| 6 |  | 
| 7 | 
             
            def get_output_text_level_and_similarity(input_text, target_level):
         | 
| 8 | 
            -
                #  | 
| 9 | 
             
                output_text = input_text[::-1]  # Example operation: reverse the input
         | 
| 10 | 
             
                output_level = int(target_level)  # Assuming target_level is directly the output level
         | 
| 11 | 
             
                similarity = 0.5  # Example fixed similarity
         | 
| 12 | 
             
                return output_text, output_level, similarity
         | 
| 13 |  | 
| 14 | 
            -
            # Create the Gradio app interface
         | 
| 15 | 
             
            iface = gr.Interface(
         | 
| 16 | 
            -
                fn= | 
| 17 | 
            -
                    "Input Reading Level": calc_input_reading_level,
         | 
| 18 | 
            -
                    "Output Text, Level and Similarity": get_output_text_level_and_similarity
         | 
| 19 | 
            -
                },
         | 
| 20 | 
             
                inputs=[
         | 
| 21 | 
             
                    gr.components.Textbox(label="Input Text", lines=2),
         | 
| 22 | 
            -
                    gr.components.Dropdown(choices=["1", "2", "3", "4", "5"], label="Target Reading Level")
         | 
|  | |
| 23 | 
             
                ],
         | 
| 24 | 
             
                outputs=[
         | 
| 25 | 
             
                    gr.components.Text(label="Input Reading Level"),
         | 
| @@ -27,8 +31,8 @@ iface = gr.Interface( | |
| 27 | 
             
                    gr.components.Text(label="Output Reading Level"),
         | 
| 28 | 
             
                    gr.components.Text(label="Output Text Similarity")
         | 
| 29 | 
             
                ],
         | 
| 30 | 
            -
                title="Text  | 
| 31 | 
            -
                description=" | 
| 32 | 
             
            )
         | 
| 33 |  | 
| 34 | 
             
            iface.launch()
         | 
|  | |
| 1 | 
             
            import gradio as gr
         | 
| 2 |  | 
| 3 | 
            +
            def main_function(input_text, target_level, action):
         | 
| 4 | 
            +
                if action == "Calculate Input Level":
         | 
| 5 | 
            +
                    return calc_input_reading_level(input_text), None, None, None
         | 
| 6 | 
            +
                elif action == "Generate Text":
         | 
| 7 | 
            +
                    output_text, output_level, similarity = get_output_text_level_and_similarity(input_text, target_level)
         | 
| 8 | 
            +
                    return None, output_text, output_level, similarity
         | 
| 9 | 
            +
             | 
| 10 | 
             
            def calc_input_reading_level(input_text):
         | 
| 11 | 
            +
                # Placeholder function implementation.
         | 
| 12 | 
             
                return len(input_text) % 10  # Random operation as a placeholder
         | 
| 13 |  | 
| 14 | 
             
            def get_output_text_level_and_similarity(input_text, target_level):
         | 
| 15 | 
            +
                # Placeholder function implementation.
         | 
| 16 | 
             
                output_text = input_text[::-1]  # Example operation: reverse the input
         | 
| 17 | 
             
                output_level = int(target_level)  # Assuming target_level is directly the output level
         | 
| 18 | 
             
                similarity = 0.5  # Example fixed similarity
         | 
| 19 | 
             
                return output_text, output_level, similarity
         | 
| 20 |  | 
|  | |
| 21 | 
             
            iface = gr.Interface(
         | 
| 22 | 
            +
                fn=main_function,
         | 
|  | |
|  | |
|  | |
| 23 | 
             
                inputs=[
         | 
| 24 | 
             
                    gr.components.Textbox(label="Input Text", lines=2),
         | 
| 25 | 
            +
                    gr.components.Dropdown(choices=["1", "2", "3", "4", "5"], label="Target Reading Level"),
         | 
| 26 | 
            +
                    gr.components.Radio(choices=["Calculate Input Level", "Generate Text"], label="Action")
         | 
| 27 | 
             
                ],
         | 
| 28 | 
             
                outputs=[
         | 
| 29 | 
             
                    gr.components.Text(label="Input Reading Level"),
         | 
|  | |
| 31 | 
             
                    gr.components.Text(label="Output Reading Level"),
         | 
| 32 | 
             
                    gr.components.Text(label="Output Text Similarity")
         | 
| 33 | 
             
                ],
         | 
| 34 | 
            +
                title="Text Analysis Tool",
         | 
| 35 | 
            +
                description="Calculate the reading level of input text or generate and analyze new text at a specified reading level."
         | 
| 36 | 
             
            )
         | 
| 37 |  | 
| 38 | 
             
            iface.launch()
         |