File size: 1,955 Bytes
8b414b0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
import re
import seaborn as sns
import streamlit as st
from demo.utils import load_model, process_text
st.set_page_config(
page_title="BERT Keyword Extractor",
page_icon="π",
)
def _max_width_():
max_width_str = "max-width: 1400px;"
st.markdown(
f"""
<style>
.reportview-container .main .block-container{{
{max_width_str}
}}
</style>
""",
unsafe_allow_html=True,
)
st.header("π Automated Essay Evaluator")
with st.expander("βΉοΈ - About this app", expanded=True):
st.write(
"""
- This application demonstrates how automated essay evaluation works: given as an input text with max. \
length of 512, it scores it (from 1.0 to 4.0) for different criteria: cohesion, syntax, vocabulary, \
phraseology, grammar and conventions.
- This solution is based on fine-tuned deberta-v3-large model.
"""
)
st.markdown("")
st.markdown("")
st.markdown("## π **Paste document**", unsafe_allow_html=True)
with st.form(key="my_form"):
_, c2, _ = st.columns([0.07, 5, 0.07])
with c2:
doc = st.text_area(
"Paste your text below (max 500 words)",
height=510,
)
MAX_WORDS = 500
res = len(re.findall(r"\w+", doc))
doc = doc[:MAX_WORDS]
submit_button = st.form_submit_button(label="β¨ Assess my text!")
if not submit_button:
st.stop()
st.markdown("## π **Check results**")
st.header("")
cs, c1, c2, c3, cLast = st.columns([2, 1.5, 1.5, 1.5, 2])
st.header("")
model = load_model()
df = process_text(doc, model)
df.index += 1
# Add styling
cmGreen = sns.light_palette("green", as_cmap=True)
cmRed = sns.light_palette("red", as_cmap=True)
df = df.style.background_gradient(
cmap=cmGreen,
subset=[
"Grade",
],
)
format_dictionary = {
"Relevancy": "{:.1%}",
}
df = df.format(format_dictionary)
st.table(df)
|