Spaces:
Sleeping
Sleeping
Commit ยท
aa0948a
1
Parent(s): 4b11872
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,10 +11,6 @@ from langchain.document_loaders import PyPDFLoader, TextLoader, JSONLoader, CSVL
|
|
| 11 |
import tempfile # ์์ ํ์ผ์ ์์ฑํ๊ธฐ ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์
๋๋ค.
|
| 12 |
import os
|
| 13 |
from huggingface_hub import hf_hub_download # Hugging Face Hub์์ ๋ชจ๋ธ์ ๋ค์ด๋ก๋ํ๊ธฐ ์ํ ํจ์์
๋๋ค.
|
| 14 |
-
#์ถ๊ฐ๋ก ํ์ํ ๊ฒ๋ค
|
| 15 |
-
from PyPDF2 import PdfReader
|
| 16 |
-
import io
|
| 17 |
-
import fitz
|
| 18 |
|
| 19 |
|
| 20 |
# PDF ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์์
๋๋ค.
|
|
@@ -30,20 +26,7 @@ def get_pdf_text(pdf_docs):
|
|
| 30 |
# ๊ณผ์
|
| 31 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 32 |
def get_text_file(docs):
|
| 33 |
-
|
| 34 |
-
for doc in docs:
|
| 35 |
-
if isinstance(doc, bytes):
|
| 36 |
-
# Bytes ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ์ฌ PdfReader๋ฅผ ์ด๊ธฐํํฉ๋๋ค.
|
| 37 |
-
pdf_reader = PdfReader(io.BytesIO(doc))
|
| 38 |
-
else:
|
| 39 |
-
# ํ์ผ ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ์ฌ PdfReader๋ฅผ ์ด๊ธฐํํฉ๋๋ค.
|
| 40 |
-
pdf_reader = PdfReader(doc)
|
| 41 |
-
|
| 42 |
-
# ๊ฐ ํ์ด์ง์ ํ
์คํธ๋ฅผ ์ถ์ถํ์ฌ text_list์ ์ถ๊ฐํฉ๋๋ค.
|
| 43 |
-
for page in pdf_reader.pages:
|
| 44 |
-
text = page.extract_text()
|
| 45 |
-
text_list.append(text)
|
| 46 |
-
return text_list
|
| 47 |
|
| 48 |
|
| 49 |
|
|
|
|
| 11 |
import tempfile # ์์ ํ์ผ์ ์์ฑํ๊ธฐ ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์
๋๋ค.
|
| 12 |
import os
|
| 13 |
from huggingface_hub import hf_hub_download # Hugging Face Hub์์ ๋ชจ๋ธ์ ๋ค์ด๋ก๋ํ๊ธฐ ์ํ ํจ์์
๋๋ค.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
# PDF ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์์
๋๋ค.
|
|
|
|
| 26 |
# ๊ณผ์
|
| 27 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 28 |
def get_text_file(docs):
|
| 29 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
|