import language_tool_python import gradio as gr # Initialize LanguageTool for English tool = language_tool_python.LanguageTool('en-US') # Function to correct grammar def grammar_correction(text): matches = tool.check(text) corrected_text = language_tool_python.utils.correct(text, matches) return corrected_text # Gradio interface for testing the grammar correction def main(): iface = gr.Interface( fn=grammar_correction, inputs="text", outputs="text", title="Grammar Correction Tool", description="Enter text to correct grammar and spelling errors." ) iface.launch() if __name__ == "__main__": main()