Skip to content

Commit

Permalink
Update read_pdf_noocr.py (#8)
Browse files Browse the repository at this point in the history
* Update read_pdf_noocr.py

* fix: pre-commit issue
  • Loading branch information
JustinHsu1019 authored Nov 14, 2024
1 parent dc9c5ba commit ef946b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Preprocess/data_process/read_pdf_noocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from tqdm import tqdm


# 讀取單個PDF文件並返回其文本內容
def read_pdf(pdf_loc):
"""讀取單個PDF文件並返回其文本內容"""
pdf = pdfplumber.open(pdf_loc)
pdf_text = ''
for page in pdf.pages:
Expand All @@ -17,8 +17,8 @@ def read_pdf(pdf_loc):
return pdf_text


# 從指定資料夾載入PDF文件,並根據資料夾名稱設定category
def load_data_by_category(source_path, category):
"""從指定資料夾載入PDF文件,並根據資料夾名稱設定category"""
pdf_files = [f for f in os.listdir(source_path) if f.endswith('.pdf')]
data = []
for file in tqdm(pdf_files):
Expand All @@ -28,8 +28,8 @@ def load_data_by_category(source_path, category):
return data


# 主程式
def generate_json(output_path):
"""Gen JSON 主程式"""
all_data = []

# 載入不同類別的PDF資料
Expand Down

0 comments on commit ef946b7

Please sign in to comment.