File size: 1,496 Bytes
87d5615
2414dea
87d5615
2414dea
 
 
 
 
 
 
 
 
 
e387f6f
 
 
 
 
 
 
 
34cc4af
 
42cb2f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b06718d
 
 
 
 
 
 
 
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
import streamlit as st
import logging

# Render Streamlit page
st.title("Anonymise your text!")
st.markdown(
    "This mini-app anonymises text using Bert. You can find the code on [GitHub(WIP)](#)"
)
# Configure logger
logging.basicConfig(format="\n%(asctime)s\n%(message)s", level=logging.INFO, force=True)

def anonymise_text(text: str, metadata: str = "", white_listed_words: str = ""):
    st.session_state.text_anon = "this is anonymised"

if "text" not in st.session_state:
    st.session_state.text = ""
if "text_error" not in st.session_state:
    st.session_state.text_error = ""
if "text_anon" not in st.session_state:
    st.session_state.text_anon = ""
if "n_requests" not in st.session_state:
    st.session_state.n_requests = 0

text = st.text_input(label="Text to be anonymised", placeholder="Write your text here")
metadata = st.text_input(
    label="Data to be redacted (optional)",
    placeholder="inspirational",
)
white_listed_words = st.text_input(
    label="Data to be ignored (optional)",
    placeholder="inspirational",
)
# button return true when clicked
anonymise_now = st.button(
    label="Anonymise text",
    type="primary",
    on_click=anonymise_text,
    args=(text, metadata, white_listed_words),
)
text_spinner_placeholder = st.empty()
if st.session_state.text_error:
    st.error(st.session_state.text_error)

if st.session_state.text_anon:
    st.markdown("""---""")
    st.text_area(label="Text anonymised", value=st.session_state.text_anon, height=100)