12345678910111213141516171819202122232425262728293031323334353637 |
- from parse_expert_pdf_utils import (
- date_extraction,
- address_extraction,
- refer_exteraction,
- )
- import tika
- import os
- from tika import parser
- tika.initVM()
- import warnings
- warnings.filterwarnings("ignore")
- def main(path):
- required_files = [file for file in os.listdir(path) if file.find(".pdf") != -1]
- for idx, file in enumerate(required_files):
- print(idx, file)
- print(file)
- content = parser.from_file(file)["content"].strip().replace("\n", "")
- # content = parsed_pdf["content"].strip().replace("\n", "")
- # print(content)
- date = date_extraction(content)
- print(date)
- address = address_extraction(content)
- print(address)
- refer = refer_exteraction(content)
- print(refer)
- if __name__ == "__main__":
- HOME_DIR = os.path.expanduser("~")
- BASE_DIR = "Code/pdf_parser/pdfs"
- path = os.path.join(HOME_DIR, BASE_DIR)
- main(path)
|