satpalsr commited on
Commit
d1cc6ee
β€’
1 Parent(s): 8651d40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -6
app.py CHANGED
@@ -1,12 +1,36 @@
1
  import streamlit as st
2
  from happytransformer import HappyTextToText, TTSettings
3
 
4
- happy_tt = HappyTextToText("T5", "team-writing-assistant/t5-base-c4jfleg")
 
5
  args = TTSettings(num_beams=5, min_length=1)
6
 
7
- input = st.text_area('Enter some text')
 
8
 
9
- if input:
10
- input = "grammar: " + input
11
- result = happy_tt.generate_text(input, args=args)
12
- st.text(result.text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from happytransformer import HappyTextToText, TTSettings
3
 
4
+ checkpoint = "team-writing-assistant/t5-base-c4jfleg"
5
+ happy_tt = HappyTextToText("T5", checkpoint)
6
  args = TTSettings(num_beams=5, min_length=1)
7
 
8
+ st.title("Check & Improve English Grammar")
9
+ st.markdown("This writing assistant detects πŸ” and corrects ✍️ grammatical mistakes for you!")
10
 
11
+ st.subheader("Example text: ")
12
+ col1, col2 = st.columns([1,1])
13
+ with col1:
14
+ example_1 = st.button("Speed of light is fastest then speed of sound")
15
+ with col2:
16
+ example_2 = st.button("Who are the president?")
17
+
18
+ input_text = st.text_area('Enter your text here')
19
+ button = st.button('Submit')
20
+
21
+ def output(input_text):
22
+ with st.spinner('Detecting πŸ”..'):
23
+ input_text = "grammar: " + input_text
24
+ result = happy_tt.generate_text(input_text, args=args)
25
+ st.markdown("## " + result.text)
26
+
27
+ if example_1:
28
+ output("Speed of light is fastest then speed of sound")
29
+ if example_2:
30
+ output("Who are the president?")
31
+ if input_text:
32
+ output(input_text)
33
+
34
+ st.subheader("")
35
+
36
+ st.text("Built by Team Writing Assistant ❀️")