se0kcess commited on
Commit
8ccd0bd
โ€ข
1 Parent(s): 3b6702c

"update text"

Browse files
Files changed (1) hide show
  1. app.py +17 -25
app.py CHANGED
@@ -25,31 +25,23 @@ def get_pdf_text(pdf_docs):
25
  # ๊ณผ์ œ
26
  # ์•„๋ž˜ ํ…์ŠคํŠธ ์ถ”์ถœ ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑ
27
  def get_text_file(txt_docs):
28
- temp_dir = tempfile.TemporaryDirectory()
29
- temp_filepath = os.path.join(temp_dir.name, txt_docs.name)
30
- with open(temp_filepath, "w", encoding="utf-8") as t:
31
- t.write(txt_docs.getvalue())
32
- txt_loader = TextLoader(temp_filepath)
33
- txt_doc = txt_loader.load()
34
- return txt_doc
35
-
36
- def get_csv_file(csv_docs):
37
- temp_dir = tempfile.TemporaryDirectory()
38
- temp_filepath = os.path.join(temp_dir.name, csv_docs.name)
39
- with open(temp_filepath, "w", encoding="utf-8") as v:
40
- v.write(csv_docs.getvalue())
41
- csv_loader = CSVLoader(temp_filepath)
42
- csv_doc = csv_loader.load()
43
- return csv_doc
44
-
45
- def get_json_file(json_docs):
46
- temp_dir = tempfile.TemporaryDirectory()
47
- temp_filepath = os.path.join(temp_dir.name, json_docs.name)
48
- with open(temp_filepath, "w", encoding="utf-8") as j:
49
- j.write(json_docs.getvalue())
50
- json_loader = JSONLoader(temp_filepath)
51
- json_doc = json_loader.load()
52
- return json_doc
53
 
54
  # ๋ฌธ์„œ๋“ค์„ ์ฒ˜๋ฆฌํ•˜์—ฌ ํ…์ŠคํŠธ ์ฒญํฌ๋กœ ๋‚˜๋ˆ„๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
55
  def get_text_chunks(documents):
 
25
  # ๊ณผ์ œ
26
  # ์•„๋ž˜ ํ…์ŠคํŠธ ์ถ”์ถœ ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑ
27
  def get_text_file(txt_docs):
28
+ with open(txt_docs, 'r', encoding='utf-8') as file:
29
+ text_content = file.read()
30
+ txt_loader = TextLoader(text_content)
31
+ txt_doc = txt_loader.load()
32
+ return txt_doc
33
+
34
+ # CSV ํŒŒ์ผ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜
35
+ def get_csv_file(docs):
36
+ with open(docs, 'r', encoding='utf-8') as file:
37
+ csv_text = file.read()
38
+ return csv_text
39
+
40
+ # JSON ํŒŒ์ผ๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜
41
+ def get_json_file(docs):
42
+ with open(docs, 'r', encoding='utf-8') as file:
43
+ json_text = file.read()
44
+ return json_text
 
 
 
 
 
 
 
 
45
 
46
  # ๋ฌธ์„œ๋“ค์„ ์ฒ˜๋ฆฌํ•˜์—ฌ ํ…์ŠคํŠธ ์ฒญํฌ๋กœ ๋‚˜๋ˆ„๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
47
  def get_text_chunks(documents):