Spaces:
Build error
Build error
Commit ยท
a531e8e
1
Parent(s): b7e362e
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,15 +27,21 @@ def get_pdf_text(pdf_docs):
|
|
| 27 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 28 |
def get_text_file(docs):
|
| 29 |
text_list = []
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
return text_list
|
| 41 |
|
|
|
|
| 27 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
| 28 |
def get_text_file(docs):
|
| 29 |
text_list = []
|
| 30 |
+
try:
|
| 31 |
+
for file in docs:
|
| 32 |
+
try:
|
| 33 |
+
if file.type == 'text/plain':
|
| 34 |
+
# ํ์ผ์ด .txt์ธ ๊ฒฝ์ฐ
|
| 35 |
+
text = file.getvalue().decode("utf-8") # ํ์ผ ๋ด์ฉ์ utf-8 ํ์์ผ๋ก ๋์ฝ๋ฉํ์ฌ ํ
์คํธ๋ก ๋ณํํฉ๋๋ค.
|
| 36 |
+
text_list.append(text)
|
| 37 |
+
except IndexError as ie:
|
| 38 |
+
print(f"IndexError occurred while processing a text file: {ie}")
|
| 39 |
+
continue # IndexError๊ฐ ๋ฐ์ํ์ ๊ฒฝ์ฐ ์ฒ๋ฆฌ๋ฅผ ๊ฑด๋๋๋๋ค.
|
| 40 |
+
except Exception as e:
|
| 41 |
+
print(f"An error occurred while extracting text: {e}")
|
| 42 |
+
continue # ๋ค๋ฅธ ์์ธ๊ฐ ๋ฐ์ํ๋ฉด ์ฒ๋ฆฌ๋ฅผ ๊ฑด๋๋๋๋ค.
|
| 43 |
+
except Exception as ex:
|
| 44 |
+
print(f"An error occurred while processing files: {ex}")
|
| 45 |
|
| 46 |
return text_list
|
| 47 |
|