Commit ·
93931ed
1
Parent(s): d4ba722
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,6 +108,9 @@ def deidentify_doc(pdftext, maxtokens, temperature, top_probability):
|
|
| 108 |
)
|
| 109 |
output = output['choices'][0]['message']['content']
|
| 110 |
|
|
|
|
|
|
|
|
|
|
| 111 |
#### Remove Dates ###
|
| 112 |
prompt = "In the following text replace any date such as 23/05/22 with term [redacted]."
|
| 113 |
|
|
@@ -124,6 +127,9 @@ def deidentify_doc(pdftext, maxtokens, temperature, top_probability):
|
|
| 124 |
)
|
| 125 |
output = output['choices'][0]['message']['content']
|
| 126 |
|
|
|
|
|
|
|
|
|
|
| 127 |
#### Remove Locations and Addresses ###
|
| 128 |
prompt = "In the following text replace location or address, such as '3970 Longview Drive, CV36HE' with term [redacted]. Replace any GP address with term [redacted]."
|
| 129 |
|
|
@@ -140,9 +146,12 @@ def deidentify_doc(pdftext, maxtokens, temperature, top_probability):
|
|
| 140 |
)
|
| 141 |
output = output['choices'][0]['message']['content']
|
| 142 |
|
|
|
|
|
|
|
|
|
|
| 143 |
### Remove Registration Numbers ###
|
| 144 |
|
| 145 |
-
prompt = "In the following text replace 'NHS Number' and 'Case note no.'
|
| 146 |
|
| 147 |
output = llm.create_chat_completion(
|
| 148 |
messages=[
|
|
@@ -157,6 +166,9 @@ def deidentify_doc(pdftext, maxtokens, temperature, top_probability):
|
|
| 157 |
)
|
| 158 |
output = output['choices'][0]['message']['content']
|
| 159 |
|
|
|
|
|
|
|
|
|
|
| 160 |
return output
|
| 161 |
|
| 162 |
def pdf_to_text(files, maxtokens=2048, temperature=0, top_probability=0.95):
|
|
|
|
| 108 |
)
|
| 109 |
output = output['choices'][0]['message']['content']
|
| 110 |
|
| 111 |
+
print('---------------Remove Names-----------------------')
|
| 112 |
+
print(output)
|
| 113 |
+
|
| 114 |
#### Remove Dates ###
|
| 115 |
prompt = "In the following text replace any date such as 23/05/22 with term [redacted]."
|
| 116 |
|
|
|
|
| 127 |
)
|
| 128 |
output = output['choices'][0]['message']['content']
|
| 129 |
|
| 130 |
+
print('---------------Remove Dates-----------------------')
|
| 131 |
+
print(output)
|
| 132 |
+
|
| 133 |
#### Remove Locations and Addresses ###
|
| 134 |
prompt = "In the following text replace location or address, such as '3970 Longview Drive, CV36HE' with term [redacted]. Replace any GP address with term [redacted]."
|
| 135 |
|
|
|
|
| 146 |
)
|
| 147 |
output = output['choices'][0]['message']['content']
|
| 148 |
|
| 149 |
+
print('---------------Remove Addresses-----------------------')
|
| 150 |
+
print(output)
|
| 151 |
+
|
| 152 |
### Remove Registration Numbers ###
|
| 153 |
|
| 154 |
+
prompt = "In the following text replace 'NHS Number' and 'Case note no.' with term [redacted]."
|
| 155 |
|
| 156 |
output = llm.create_chat_completion(
|
| 157 |
messages=[
|
|
|
|
| 166 |
)
|
| 167 |
output = output['choices'][0]['message']['content']
|
| 168 |
|
| 169 |
+
print('---------------Remove Registration Numbers-----------------------')
|
| 170 |
+
print(output)
|
| 171 |
+
|
| 172 |
return output
|
| 173 |
|
| 174 |
def pdf_to_text(files, maxtokens=2048, temperature=0, top_probability=0.95):
|