philona commited on
Commit
eb8dc4e
·
1 Parent(s): a179a44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -31,27 +31,27 @@ def get_text_file(txt_docs):
31
  temp_filepath = os.path.join(temp_dir.name, txt_docs.name)
32
  with open(temp_filepath, "wb") as f:
33
  f.write(txt_docs.getvalue())
34
- txt_loader = TextLoader(temp_filepath) # PyPDFLoader를 사용해 PDF를 로드합니다.
35
- txt_doc = txt_loader.load() # 텍스트를 추출합니다.
36
- return txt_doc
37
 
38
  def get_csv_file(csv_docs):
39
  temp_dir = tempfile.TemporaryDirectory()
40
  temp_filepath = os.path.join(temp_dir.name, csv_docs.name)
41
  with open(temp_filepath, "wb") as f:
42
  f.write(csv_docs.getvalue())
43
- csv_loader = CSVLoader(temp_filepath) # CSVLoader를 사용해 PDF를 로드합니다.
44
- csv_doc = csv_loader.load() # 텍스트를 추출합니다.
45
- return csv_doc
46
 
47
  def get_json_file(json_docs):
48
  temp_dir = tempfile.TemporaryDirectory()
49
  temp_filepath = os.path.join(temp_dir.name, json_docs.name)
50
  with open(temp_filepath, "wb") as f:
51
  f.write(json_docs.getvalue())
52
- json_loader = JSONLLoader(temp_filepath) # JSONLoader를 사용해 PDF를 로드합니다.
53
- json_doc = json_loader.load() # 텍스트를 추출합니다.
54
- return json_doc
55
 
56
 
57
  # 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
 
31
  temp_filepath = os.path.join(temp_dir.name, txt_docs.name)
32
  with open(temp_filepath, "wb") as f:
33
  f.write(txt_docs.getvalue())
34
+ txt_loader = TextLoader(temp_filepath) # PyPDFLoader를 사용해 PDF를 로드합니다.
35
+ txt_doc = txt_loader.load() # 텍스트를 추출합니다.
36
+ return txt_doc
37
 
38
  def get_csv_file(csv_docs):
39
  temp_dir = tempfile.TemporaryDirectory()
40
  temp_filepath = os.path.join(temp_dir.name, csv_docs.name)
41
  with open(temp_filepath, "wb") as f:
42
  f.write(csv_docs.getvalue())
43
+ csv_loader = CSVLoader(temp_filepath) # CSVLoader를 사용해 PDF를 로드합니다.
44
+ csv_doc = csv_loader.load() # 텍스트를 추출합니다.
45
+ return csv_doc
46
 
47
  def get_json_file(json_docs):
48
  temp_dir = tempfile.TemporaryDirectory()
49
  temp_filepath = os.path.join(temp_dir.name, json_docs.name)
50
  with open(temp_filepath, "wb") as f:
51
  f.write(json_docs.getvalue())
52
+ json_loader = JSONLLoader(temp_filepath) # JSONLoader를 사용해 PDF를 로드합니다.
53
+ json_doc = json_loader.load() # 텍스트를 추출합니다.
54
+ return json_doc
55
 
56
 
57
  # 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.