minji1115
commited on
Commit
ยท
49cc238
1
Parent(s):
01ef41c
text loader
Browse files
app.py
CHANGED
|
@@ -29,7 +29,13 @@ def get_pdf_text(pdf_docs):
|
|
| 29 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 30 |
|
| 31 |
def get_text_file(text_docs):
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
def get_csv_file(csv_docs):
|
|
|
|
| 29 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 30 |
|
| 31 |
def get_text_file(text_docs):
|
| 32 |
+
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
| 33 |
+
temp_filepath = os.path.join(temp_dir.name, text_docs.name) # ์์ ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
| 34 |
+
with open(temp_filepath, "wb") as f: # ์์ ํ์ผ์ ๋ฐ์ด๋๋ฆฌ ์ฐ๊ธฐ ๋ชจ๋๋ก ์ฝ๋๋ค.
|
| 35 |
+
f.write(text_docs.getvalue()) # PDF ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
| 36 |
+
text_loader = TextLoader(temp_filepath) # PyPDFLoader๋ฅผ ์ฌ์ฉํด PDF๋ฅผ ๋ก๋ํฉ๋๋ค.
|
| 37 |
+
text_docs = text_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
| 38 |
+
return text_docs # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
| 39 |
|
| 40 |
|
| 41 |
def get_csv_file(csv_docs):
|