ZeeAI1 commited on
Commit
8d1a9f0
Β·
verified Β·
1 Parent(s): 96dc0c7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import language_tool_python
3
+
4
+ # App title
5
+ st.title("English Writing Correction Assistant ✍️")
6
+
7
+ # Initialize LanguageTool for English
8
+ tool = language_tool_python.LanguageTool('en-US')
9
+
10
+ # Text input from user
11
+ user_text = st.text_area("Enter your text here:", height=200)
12
+
13
+ # Analyze button
14
+ if st.button("Correct and Analyze"):
15
+ if user_text.strip() == "":
16
+ st.warning("Please enter some text to analyze.")
17
+ else:
18
+ # Get grammar corrections
19
+ matches = tool.check(user_text)
20
+ corrected_text = language_tool_python.utils.correct(user_text, matches)
21
+
22
+ # Display Corrected Text
23
+ st.subheader("βœ… Corrected Text:")
24
+ st.write(corrected_text)
25
+
26
+ # Detailed feedback on issues
27
+ st.subheader("πŸ“ Improvement Suggestions:")
28
+ if matches:
29
+ for idx, match in enumerate(matches, start=1):
30
+ st.markdown(f"**{idx}. Issue:** {match.ruleDescription}")
31
+ st.markdown(f"**Context:** ...{match.context}...")
32
+ if match.replacements:
33
+ st.markdown(f"**Suggested Corrections:** {', '.join(match.replacements)}")
34
+ else:
35
+ st.markdown("**Suggested Corrections:** None provided.")
36
+ st.markdown("---")
37
+ else:
38
+ st.success("No grammatical or stylistic issues found!")
39
+
40
+ # Learning suggestions
41
+ st.subheader("πŸ“š Learning Recommendations:")
42
+ if matches:
43
+ st.info("Consider reviewing:")
44
+ suggestions = set(match.ruleIssueType for match in matches if match.ruleIssueType)
45
+ for s in suggestions:
46
+ st.markdown(f"- {s.replace('_', ' ').title()}")
47
+ else:
48
+ st.write("Your writing looks great! Keep it up! πŸŽ‰")