Commit
ยท
9923ac4
1
Parent(s):
ad710b8
Update app.py
Browse files
app.py
CHANGED
@@ -31,22 +31,25 @@ def get_pdf_text(pdf_docs):
|
|
31 |
def get_text_file(docs):
|
32 |
text_list = []
|
33 |
|
34 |
-
# .txt ํ์ผ ์ฒ๋ฆฌ
|
35 |
def process_txt_file(file):
|
36 |
-
|
|
|
37 |
text = file.getvalue().decode("utf-8")
|
38 |
text_list.append(text)
|
39 |
|
|
|
40 |
for doc in docs:
|
41 |
process_txt_file(doc) # .txt ํ์ผ ์ฒ๋ฆฌ ํจ์ ํธ์ถ
|
42 |
|
43 |
# ๋ค๋ฅธ ํ์ผ ์ ํ(PDF, CSV, JSON ๋ฑ)์ ๋ํ ์ฒ๋ฆฌ
|
44 |
-
#
|
45 |
|
46 |
return text_list
|
47 |
|
48 |
|
49 |
|
|
|
50 |
def get_csv_file(docs):
|
51 |
text_list = []
|
52 |
for doc in docs:
|
|
|
31 |
def get_text_file(docs):
|
32 |
text_list = []
|
33 |
|
34 |
+
# .txt ํ์ผ ์ฒ๋ฆฌ ํจ์
|
35 |
def process_txt_file(file):
|
36 |
+
filename = file.name.lower() # ํ์ผ ์ด๋ฆ์ ์๋ฌธ์๋ก ๋ณํํ์ฌ ํ์ฅ์๋ฅผ ํ์ธํฉ๋๋ค.
|
37 |
+
if filename.endswith('.txt'):
|
38 |
text = file.getvalue().decode("utf-8")
|
39 |
text_list.append(text)
|
40 |
|
41 |
+
# ์ฃผ์ด์ง ํ์ผ ๋ชฉ๋ก์ ๋ฐ๋ณตํ๋ฉด์ ๊ฐ ํ์ผ์ ์ฒ๋ฆฌ
|
42 |
for doc in docs:
|
43 |
process_txt_file(doc) # .txt ํ์ผ ์ฒ๋ฆฌ ํจ์ ํธ์ถ
|
44 |
|
45 |
# ๋ค๋ฅธ ํ์ผ ์ ํ(PDF, CSV, JSON ๋ฑ)์ ๋ํ ์ฒ๋ฆฌ
|
46 |
+
# ๋ง์ฝ ํ์ํ๋ค๋ฉด ์ฌ๊ธฐ์ ์ถ๊ฐ์ ์ธ ํ์ผ ์ฒ๋ฆฌ ๋ก์ง์ ๊ตฌํํฉ๋๋ค.
|
47 |
|
48 |
return text_list
|
49 |
|
50 |
|
51 |
|
52 |
+
|
53 |
def get_csv_file(docs):
|
54 |
text_list = []
|
55 |
for doc in docs:
|