DDingcheol commited on
Commit
a04e0a2
ยท
1 Parent(s): 64515bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -32,16 +32,15 @@ def get_text_file(docs):
32
  text_list = []
33
 
34
  # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜
35
- def process_txt_file(file):
36
- filename = file.name.lower() # ํŒŒ์ผ ์ด๋ฆ„์„ ์†Œ๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ํ™•์žฅ์ž๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
37
- file_extension = filename.split('.')[-1] # ํŒŒ์ผ ์ด๋ฆ„์—์„œ ํ™•์žฅ์ž ์ถ”์ถœ
38
  if file_extension == 'txt': # ์ถ”์ถœํ•œ ํ™•์žฅ์ž๊ฐ€ 'txt'์ธ์ง€ ํ™•์ธ
39
- text = file.getvalue().decode("utf-8")
40
  text_list.append(text)
41
 
42
  # ์ฃผ์–ด์ง„ ํŒŒ์ผ ๋ชฉ๋ก์„ ๋ฐ˜๋ณตํ•˜๋ฉด์„œ ๊ฐ ํŒŒ์ผ์„ ์ฒ˜๋ฆฌ
43
- for doc in docs:
44
- process_txt_file(doc) # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜ ํ˜ธ์ถœ
45
 
46
  # ๋‹ค๋ฅธ ํŒŒ์ผ ์œ ํ˜•(PDF, CSV, JSON ๋“ฑ)์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ
47
  # ํ•„์š”ํ•˜๋‹ค๋ฉด ์—ฌ๊ธฐ์— ์ถ”๊ฐ€์ ์ธ ํŒŒ์ผ ์ฒ˜๋ฆฌ ๋กœ์ง์„ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
@@ -49,6 +48,7 @@ def get_text_file(docs):
49
  return text_list
50
 
51
 
 
52
  def get_csv_file(docs):
53
  text_list = []
54
  for doc in docs:
 
32
  text_list = []
33
 
34
  # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜
35
+ def process_txt_file(filename, file_content):
36
+ file_extension = filename.split('.')[-1].lower() # ํŒŒ์ผ ์ด๋ฆ„์—์„œ ํ™•์žฅ์ž ์ถ”์ถœ
 
37
  if file_extension == 'txt': # ์ถ”์ถœํ•œ ํ™•์žฅ์ž๊ฐ€ 'txt'์ธ์ง€ ํ™•์ธ
38
+ text = file_content.decode("utf-8")
39
  text_list.append(text)
40
 
41
  # ์ฃผ์–ด์ง„ ํŒŒ์ผ ๋ชฉ๋ก์„ ๋ฐ˜๋ณตํ•˜๋ฉด์„œ ๊ฐ ํŒŒ์ผ์„ ์ฒ˜๋ฆฌ
42
+ for filename, doc in docs:
43
+ process_txt_file(filename, doc) # .txt ํŒŒ์ผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜ ํ˜ธ์ถœ
44
 
45
  # ๋‹ค๋ฅธ ํŒŒ์ผ ์œ ํ˜•(PDF, CSV, JSON ๋“ฑ)์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ
46
  # ํ•„์š”ํ•˜๋‹ค๋ฉด ์—ฌ๊ธฐ์— ์ถ”๊ฐ€์ ์ธ ํŒŒ์ผ ์ฒ˜๋ฆฌ ๋กœ์ง์„ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
 
48
  return text_list
49
 
50
 
51
+
52
  def get_csv_file(docs):
53
  text_list = []
54
  for doc in docs: