parse_expert_pdf.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from parse_expert_pdf_utils import (
  2. case_number_extraction,
  3. expert_name_extraction,
  4. plaintiff_extraction,
  5. defendent_extraction,
  6. patent_extraction,
  7. on_behalf_of_extraction,
  8. acronym_extraction,
  9. hourly_compensation,
  10. date_extraction,
  11. address_extraction,
  12. )
  13. import tika
  14. import os
  15. from tika import parser
  16. tika.initVM()
  17. import warnings
  18. warnings.filterwarnings("ignore")
  19. def main(path):
  20. required_files = [file for file in os.listdir(path) if file.find(".pdf") != -1]
  21. for idx, file in enumerate(required_files):
  22. print(idx, file)
  23. parsed_pdf = parser.from_file(file)
  24. # print(parsed_pdf.keys())
  25. content = parsed_pdf["content"].strip().replace("\n", "")
  26. # print(content)
  27. date = date_extraction(content)
  28. print(date)
  29. address = address_extraction(content)
  30. print(address)
  31. if __name__ == "__main__":
  32. HOME_DIR = os.path.expanduser("~")
  33. BASE_DIR = "/home/ftech/Code/pdf_parser/pdfs/"
  34. path = os.path.join(HOME_DIR, BASE_DIR)
  35. main(path)