Straive-Kripa commited on
Commit
8ce41f4
·
verified ·
1 Parent(s): 2ff0089

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -6,15 +6,18 @@ def upload_file(filepath):
6
  name = Path(filepath).name
7
  return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]
8
 
9
- def scrub_file(filepath):
10
  # Temporary list to hold stripped lines
11
  stripped_lines = []
 
12
 
13
  # Open the original file and strip each line
14
  with open(filepath, 'r', encoding='utf-8') as file:
15
  for line in file:
16
- #stripped_lines.append(line.strip())
17
- stripped_lines.append(pii_anonymizer.anonymize_text_including_proper_nouns_and_addresses(line))
 
 
18
 
19
  # Overwrite the original file with pii replaced lines
20
  with open(filepath, 'w', encoding='utf-8') as file:
 
6
  name = Path(filepath).name
7
  return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]
8
 
9
+ def scrub_file(filepath, progress=gr.Progress()):
10
  # Temporary list to hold stripped lines
11
  stripped_lines = []
12
+ pii_lines = []
13
 
14
  # Open the original file and strip each line
15
  with open(filepath, 'r', encoding='utf-8') as file:
16
  for line in file:
17
+ stripped_lines.append(line.strip())
18
+ progress(0, desc="Starting...")
19
+ for line in progress.tqdm(stripped_lines):
20
+ pii_lines.append(pii_anonymizer.anonymize_text_including_proper_nouns_and_addresses(line))
21
 
22
  # Overwrite the original file with pii replaced lines
23
  with open(filepath, 'w', encoding='utf-8') as file: