DDingcheol commited on
Commit
ad710b8
ยท
1 Parent(s): acbcadf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -30,13 +30,20 @@ def get_pdf_text(pdf_docs):
30
  # ํ…์ŠคํŠธ ํŒŒ์ผ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
31
  def get_text_file(docs):
32
  text_list = []
33
- for doc in docs:
34
- if doc.type == 'text/plain':
35
- # ์—…๋กœ๋“œ๋œ .txt ํŒŒ์ผ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ฝ์–ด์˜ต๋‹ˆ๋‹ค
36
- text = doc.getvalue().decode("utf-8") # UTF-8 ์ธ์ฝ”๋”ฉ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฐ”์ดํŠธ๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋””์ฝ”๋”ฉํ•ฉ๋‹ˆ๋‹ค
 
37
  text_list.append(text)
38
- return text_list
39
 
 
 
 
 
 
 
 
40
 
41
 
42
 
 
30
  # ํ…์ŠคํŠธ ํŒŒ์ผ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
31
  def get_text_file(docs):
32
  text_list = []
33
+
34
+ # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
35
+ def process_txt_file(file):
36
+ if file.type == 'text/plain':
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