srijaydeshpande commited on
Commit
2a1dfbd
·
verified ·
1 Parent(s): 123786b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -103,6 +103,10 @@ def deidentify_doc(llm, pdftext, maxtokens, temperature, top_probability):
103
  if find_index != -1:
104
  output = output[find_index:].strip()
105
 
 
 
 
 
106
  output = llm.create_chat_completion(
107
  messages=[
108
  {"from": "user", "value": prompt + ' Text: ' + output},
@@ -116,6 +120,10 @@ def deidentify_doc(llm, pdftext, maxtokens, temperature, top_probability):
116
  find_index = output.find(' '.join(pdftext.split()[:3]))
117
  if find_index != -1:
118
  output = output[find_index:].strip()
 
 
 
 
119
 
120
  return output
121
 
 
103
  if find_index != -1:
104
  output = output[find_index:].strip()
105
 
106
+ last_index = output.rfind(' '.join(pdftext.split()[-3:]))
107
+ if last_index != -1:
108
+ output = output[:last_index].strip()
109
+
110
  output = llm.create_chat_completion(
111
  messages=[
112
  {"from": "user", "value": prompt + ' Text: ' + output},
 
120
  find_index = output.find(' '.join(pdftext.split()[:3]))
121
  if find_index != -1:
122
  output = output[find_index:].strip()
123
+
124
+ last_index = output.rfind(' '.join(pdftext.split()[-3:]))
125
+ if last_index != -1:
126
+ output = output[:last_index].strip()
127
 
128
  return output
129