Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update read_pdf_noocr.py #8

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading