aftersix commited on
Commit
1cc6ea3
1 Parent(s): b802ec0

adding presidio

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -2,6 +2,9 @@ import streamlit as st
2
  import streamlit as st
3
  from st_aggrid import AgGrid
4
  import pandas as pd
 
 
 
5
 
6
  #resource list to display after the assessment is complete
7
  resourceList = pd.read_csv('resources.csv')
@@ -23,6 +26,11 @@ with open('auditorytext.csv', newline='') as csvfile:
23
  #set page config
24
  st.set_page_config(page_title='auditory skills resources', page_icon='icon-128x128.png')
25
 
 
 
 
 
 
26
  #define session variables
27
  if 'one' not in st.session_state:
28
  st.session_state['one'] = 'value'
@@ -108,6 +116,9 @@ def main():
108
  submitted = st.form_submit_button("Get Results")
109
  if submitted:
110
  #load everything
 
 
 
111
  from transformers import pipeline
112
 
113
  #define classifier for zero shot classification
@@ -119,7 +130,13 @@ def main():
119
  while x < 35:
120
  if details[x] != "none":
121
  st.markdown(questions[x])
122
- st.markdown("**"+details[x]+"**")
 
 
 
 
 
 
123
  sequence = details[x]
124
  print(details[x])
125
  output = classifier(sequence, sequence_labels)
 
2
  import streamlit as st
3
  from st_aggrid import AgGrid
4
  import pandas as pd
5
+ #for the PII masking
6
+
7
+
8
 
9
  #resource list to display after the assessment is complete
10
  resourceList = pd.read_csv('resources.csv')
 
26
  #set page config
27
  st.set_page_config(page_title='auditory skills resources', page_icon='icon-128x128.png')
28
 
29
+ #masking set up
30
+
31
+ # Call analyzer to get results
32
+
33
+
34
  #define session variables
35
  if 'one' not in st.session_state:
36
  st.session_state['one'] = 'value'
 
116
  submitted = st.form_submit_button("Get Results")
117
  if submitted:
118
  #load everything
119
+ from presidio_analyzer import AnalyzerEngine
120
+ from presidio_anonymizer import AnonymizerEngine
121
+ analyzer = AnalyzerEngine()
122
  from transformers import pipeline
123
 
124
  #define classifier for zero shot classification
 
130
  while x < 35:
131
  if details[x] != "none":
132
  st.markdown(questions[x])
133
+ text=details[x]
134
+ results = analyzer.analyze(text=text,
135
+ language='en')
136
+ anonymizer = AnonymizerEngine()
137
+ anonymized_text = anonymizer.anonymize(text=text,analyzer_results=results)
138
+ maskedText = anonymized_text.text
139
+ st.markdown("**"+maskedText+"**")
140
  sequence = details[x]
141
  print(details[x])
142
  output = classifier(sequence, sequence_labels)