cjber commited on
Commit
051f5c0
·
1 Parent(s): 32ffa94

simplify expressions

Browse files
planning_ai/preprocessing/process_pdfs.py CHANGED
@@ -45,9 +45,7 @@ def extract_text_from_pdf(file_path):
45
  """Extracts text from a PDF file using PyPDF2."""
46
  try:
47
  reader = PdfReader(file_path, strict=True)
48
- text = []
49
- for page in reader.pages:
50
- text.append(page.extract_text() or "")
51
  return "\n".join(text).strip()
52
  except Exception as e:
53
  print(e)
@@ -74,7 +72,7 @@ def main():
74
  ]
75
 
76
  response = send_request_to_api(messages)
77
- if not "choices" in response:
78
  continue
79
  out = response["choices"][0]["message"]["content"]
80
  if outfile.exists():
 
45
  """Extracts text from a PDF file using PyPDF2."""
46
  try:
47
  reader = PdfReader(file_path, strict=True)
48
+ text = [page.extract_text() or "" for page in reader.pages]
 
 
49
  return "\n".join(text).strip()
50
  except Exception as e:
51
  print(e)
 
72
  ]
73
 
74
  response = send_request_to_api(messages)
75
+ if "choices" not in response:
76
  continue
77
  out = response["choices"][0]["message"]["content"]
78
  if outfile.exists():