Update app.py
Browse files
app.py
CHANGED
@@ -25,14 +25,12 @@ def get_pdf_text(pdf_docs):
|
|
25 |
# ๊ณผ์
|
26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
27 |
|
28 |
-
# ์๋ ์ฝ๋๋ get_text_file, get_csv_file, get_json_file ํจ์ ๋ด์ฉ๋ง ๋ณ๊ฒฝ๋์์ต๋๋ค.
|
29 |
-
|
30 |
def get_text_file(text_docs):
|
31 |
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
32 |
-
temp_filepath = os.path.join(temp_dir.name,
|
33 |
with open(temp_filepath, "wb") as f:
|
34 |
-
f.write(text_docs.getvalue()) #
|
35 |
-
text_loader = TextLoader(temp_filepath) # TextLoader๋ฅผ
|
36 |
text_doc = text_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
37 |
return text_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
38 |
|
|
|
25 |
# ๊ณผ์
|
26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
27 |
|
|
|
|
|
28 |
def get_text_file(text_docs):
|
29 |
temp_dir = tempfile.TemporaryDirectory() # ์์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค.
|
30 |
+
temp_filepath = os.path.join(temp_dir.name, text_docs.name) # ์์ ํ์ผ ๊ฒฝ๋ก๋ฅผ ์์ฑํฉ๋๋ค.
|
31 |
with open(temp_filepath, "wb") as f:
|
32 |
+
f.write(text_docs.getvalue()) # ํ
์คํธ ๋ฌธ์์ ๋ด์ฉ์ ์์ ํ์ผ์ ์๋๋ค.
|
33 |
+
text_loader = TextLoader(temp_filepath) # TextLoader๋ฅผ ์ฌ์ฉํ์ฌ ํ
์คํธ๋ฅผ ๋ก๋ํฉ๋๋ค.
|
34 |
text_doc = text_loader.load() # ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
35 |
return text_doc # ์ถ์ถํ ํ
์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
36 |
|