Spaces:
Sleeping
Sleeping
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
from transformers import pipeline
|
4 |
+
import time
|
5 |
+
|
6 |
+
grammarChecker = pipeline(task='sentiment-analysis', model='samarla/RoBERTa-base-cola')
|
7 |
+
|
8 |
+
header = 'GramcheckAI'
|
9 |
+
|
10 |
+
caption1 = "Enhance Your Writing with GramChekAI: Your Ultimate Grammar Assistant"
|
11 |
+
|
12 |
+
caption2 = "Powered by CoLA Fine-Tuned Reborta-base Model - A Smart App to Ensure Flawless Grammar and Language Acceptability!"
|
13 |
+
|
14 |
+
body = """Introducing "GramCheckAI" - Your Ultimate Grammar Assistant!
|
15 |
+
|
16 |
+
GramChekAI is a cutting-edge web application designed to enhance your writing skills and ensure impeccable grammar in every sentence you compose. Powered by the state-of-the-art "Reborta-base" language model, fine-tuned with the comprehensive CoLA dataset, this app promises to revolutionize the way you communicate.
|
17 |
+
|
18 |
+
Key Features:
|
19 |
+
|
20 |
+
1. Grammar Accuracy: Say goodbye to embarrassing grammar mistakes! GramChekAI uses advanced Natural Language Processing (NLP) algorithms to meticulously analyze each sentence you input, detecting potential grammatical errors with precision.
|
21 |
+
|
22 |
+
2. CoLA Dataset Fine-Tuning: Our language model has been fine-tuned on the Corpus of Linguistic Acceptability (CoLA) dataset, which makes it exceptionally proficient in evaluating sentence acceptability, ensuring reliable and trustworthy results.
|
23 |
+
|
24 |
+
|
25 |
+
Say farewell to grammar mistakes and unlock your true writing potential with GramcheckAI. Use the app now and experience the seamless blend of AI sophistication and user-friendly design that will empower you to write with confidence and clarity like never before. Happy writing!"""
|
26 |
+
|
27 |
+
#header section
|
28 |
+
st.header(f':violet[{header}]', )
|
29 |
+
st.caption(caption1)
|
30 |
+
st.caption(caption2)
|
31 |
+
st.markdown("Let's dive and check your sentence :eyes:")
|
32 |
+
|
33 |
+
#image = Image.open('./gramcheck.jpg')
|
34 |
+
#st.image(image=image, caption='check grammer')
|
35 |
+
|
36 |
+
|
37 |
+
def coloringAcceptance(acc, conf):
|
38 |
+
if acceptance == 'Acceptable':
|
39 |
+
st.subheader(f"Sentence is :green[{acceptance}] with confidence of {conf} %")
|
40 |
+
else:
|
41 |
+
st.subheader(f"Sentence is :red[{acceptance}] with confidence of {conf} %")
|
42 |
+
|
43 |
+
options = (
|
44 |
+
'',
|
45 |
+
'GramcheckAI helps writers improve their language skills and confidence',
|
46 |
+
'The app identifies errors and provides real-time suggestions for corrections',
|
47 |
+
"The app finded sentence errors, but it's still useful"
|
48 |
+
)
|
49 |
+
|
50 |
+
container = st.container()
|
51 |
+
selected_option = container.selectbox(
|
52 |
+
'Test with an example', options=options
|
53 |
+
)
|
54 |
+
|
55 |
+
count =1
|
56 |
+
|
57 |
+
while len(selected_option)>0:
|
58 |
+
text = container.text_input('Type your own Sentence', selected_option, key=f'opted_sentence{count}')
|
59 |
+
count+=1
|
60 |
+
break
|
61 |
+
else:
|
62 |
+
text = container.text_input('Type your own Sentence',key='typed_sentence')
|
63 |
+
|
64 |
+
button_bool = container.button('Check now')
|
65 |
+
if len(text) > 0:
|
66 |
+
with st.spinner('Wait for it...'):
|
67 |
+
result = grammarChecker(text)
|
68 |
+
acceptance = result[0]['label']
|
69 |
+
conf_score = round(result[0]['score']*100,2)
|
70 |
+
coloringAcceptance(acceptance, conf_score)
|
71 |
+
else:
|
72 |
+
container.text('Input the sentence please!')
|
73 |
+
|
74 |
+
|
75 |
+
expander = st.expander("Brief about")
|
76 |
+
expander.text('\n\n\n\n\n')
|
77 |
+
expander.title(body)
|
78 |
+
|
79 |
+
|