Booguy commited on
Commit
f166ffb
β€’
1 Parent(s): afe7730

Create app.py

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