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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
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
- 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
 
 
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: