Spaces:
Runtime error
Runtime error
add copy the result to clipboard
Browse files- app.py +19 -5
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -2,6 +2,9 @@ import streamlit as st
|
|
| 2 |
from happytransformer import HappyTextToText, TTSettings
|
| 3 |
from annotated_text import annotated_text
|
| 4 |
import difflib
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
checkpoint = "team-writing-assistant/t5-base-c4jfleg"
|
| 7 |
|
|
@@ -60,14 +63,25 @@ input_text = st.text_area('Enter your text here')
|
|
| 60 |
button = st.button('Submit')
|
| 61 |
|
| 62 |
|
| 63 |
-
def output(
|
| 64 |
with st.spinner('Detecting 🔍..'):
|
| 65 |
-
|
| 66 |
-
result = happy_tt.generate_text(
|
| 67 |
-
|
| 68 |
-
diff = diff_strings(input_text[9:], result.text)
|
| 69 |
annotated_text(*diff)
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
if example_1:
|
| 73 |
output("Speed of light is fastest then speed of sound")
|
|
|
|
| 2 |
from happytransformer import HappyTextToText, TTSettings
|
| 3 |
from annotated_text import annotated_text
|
| 4 |
import difflib
|
| 5 |
+
from bokeh.models.widgets import Button
|
| 6 |
+
from bokeh.models import CustomJS
|
| 7 |
+
from streamlit_bokeh_events import streamlit_bokeh_events
|
| 8 |
|
| 9 |
checkpoint = "team-writing-assistant/t5-base-c4jfleg"
|
| 10 |
|
|
|
|
| 63 |
button = st.button('Submit')
|
| 64 |
|
| 65 |
|
| 66 |
+
def output(text):
|
| 67 |
with st.spinner('Detecting 🔍..'):
|
| 68 |
+
text = "grammar: " + text
|
| 69 |
+
result = happy_tt.generate_text(text, args=args)
|
| 70 |
+
diff = diff_strings(text[9:], result.text)
|
|
|
|
| 71 |
annotated_text(*diff)
|
| 72 |
|
| 73 |
+
copy_button = Button(label="Copy the Result")
|
| 74 |
+
copy_button.js_on_event("button_click", CustomJS(args=dict(result=result.text), code="""
|
| 75 |
+
navigator.clipboard.writeText(result);
|
| 76 |
+
"""))
|
| 77 |
+
streamlit_bokeh_events(
|
| 78 |
+
copy_button,
|
| 79 |
+
events="GET_TEXT",
|
| 80 |
+
key="get_text",
|
| 81 |
+
refresh_on_update=True,
|
| 82 |
+
override_height=75,
|
| 83 |
+
debounce_time=0)
|
| 84 |
+
|
| 85 |
|
| 86 |
if example_1:
|
| 87 |
output("Speed of light is fastest then speed of sound")
|
requirements.txt
CHANGED
|
@@ -1,2 +1,4 @@
|
|
| 1 |
happytransformer
|
| 2 |
st-annotated-text
|
|
|
|
|
|
|
|
|
| 1 |
happytransformer
|
| 2 |
st-annotated-text
|
| 3 |
+
bokeh
|
| 4 |
+
streamlit-bokeh-events
|