Spaces:
Runtime error
Runtime error
EC2 Default User
commited on
Commit
•
f719192
1
Parent(s):
cc00572
debug
Browse files
app.py
CHANGED
@@ -14,8 +14,9 @@ logging.basicConfig(format="\n%(asctime)s\n%(message)s", level=logging.INFO, for
|
|
14 |
|
15 |
@st.cache(suppress_st_warning=True)
|
16 |
def load_tagger():
|
17 |
-
|
18 |
-
|
|
|
19 |
def anonymise_text(text: str, metadata: str = "", white_listed_words: str = ""):
|
20 |
"""anonymise text"""
|
21 |
if st.session_state.n_requests >= 50:
|
@@ -31,8 +32,6 @@ def anonymise_text(text: str, metadata: str = "", white_listed_words: str = ""):
|
|
31 |
st.session_state.text_error = "Please enter your text"
|
32 |
return
|
33 |
|
34 |
-
# load tagger
|
35 |
-
tagger = load_tagger()
|
36 |
with text_spinner_placeholder:
|
37 |
with st.spinner("Please wait while your text is being anonymised..."):
|
38 |
|
@@ -43,6 +42,8 @@ def anonymise_text(text: str, metadata: str = "", white_listed_words: str = ""):
|
|
43 |
# return
|
44 |
|
45 |
# else:
|
|
|
|
|
46 |
sentence = Sentence(text)
|
47 |
# predict NER tags
|
48 |
tagger.predict(sentence)
|
|
|
14 |
|
15 |
@st.cache(suppress_st_warning=True)
|
16 |
def load_tagger():
|
17 |
+
with text_spinner_placeholder:
|
18 |
+
tagger=SequenceTagger.load("flair/ner-english-large")
|
19 |
+
return tagger
|
20 |
def anonymise_text(text: str, metadata: str = "", white_listed_words: str = ""):
|
21 |
"""anonymise text"""
|
22 |
if st.session_state.n_requests >= 50:
|
|
|
32 |
st.session_state.text_error = "Please enter your text"
|
33 |
return
|
34 |
|
|
|
|
|
35 |
with text_spinner_placeholder:
|
36 |
with st.spinner("Please wait while your text is being anonymised..."):
|
37 |
|
|
|
42 |
# return
|
43 |
|
44 |
# else:
|
45 |
+
# load tagger
|
46 |
+
tagger = load_tagger()
|
47 |
sentence = Sentence(text)
|
48 |
# predict NER tags
|
49 |
tagger.predict(sentence)
|