quoc-khanh commited on
Commit
5c08ccc
·
verified ·
1 Parent(s): 773629e

Update file_loader.py

Browse files
Files changed (1) hide show
  1. file_loader.py +7 -2
file_loader.py CHANGED
@@ -10,13 +10,16 @@ from helpers import (
10
  get_splits, # Xử lý file docx thành splits
11
  get_json_splits_only, # Xử lý file JSON (FAQ)
12
  get_web_documents, # Xử lý dữ liệu từ web
 
 
13
  )
14
 
15
  import json
16
 
17
  def get_vectorstore():
18
  ### Xử lý tất cả các tài liệu và nhét vào database
19
- folder_path = "syllabus_nct_word_format/"
 
20
  #'syllabus_nct_word_format/Trường Công nghệ/debug'
21
  # 'syllabus_nct_word_format/Trường Công nghệ/Chương trình An toàn thông tin'
22
  #
@@ -39,8 +42,10 @@ def get_vectorstore():
39
  output_json_path = f"output_{i}.json"
40
 
41
  try:
 
42
  splits = get_splits(file_path, output_json_path)
43
- all_splits += splits # Append successful splits
 
44
  except Exception as e:
45
  print(f"Error processing {file_path}: {e}")
46
  error_files.append(file_path) # Store the problematic file
 
10
  get_splits, # Xử lý file docx thành splits
11
  get_json_splits_only, # Xử lý file JSON (FAQ)
12
  get_web_documents, # Xử lý dữ liệu từ web
13
+ update_documents_metadata,
14
+ define_metadata
15
  )
16
 
17
  import json
18
 
19
  def get_vectorstore():
20
  ### Xử lý tất cả các tài liệu và nhét vào database
21
+ folder_path = 'syllabus_nct_word_format/Trường Công nghệ/Chương trình An toàn thông tin'
22
+ #"syllabus_nct_word_format/"
23
  #'syllabus_nct_word_format/Trường Công nghệ/debug'
24
  # 'syllabus_nct_word_format/Trường Công nghệ/Chương trình An toàn thông tin'
25
  #
 
42
  output_json_path = f"output_{i}.json"
43
 
44
  try:
45
+ metadata = define_metadata(file_path)
46
  splits = get_splits(file_path, output_json_path)
47
+ splits_with_metadata = update_documents_metadata(splits, metadata)
48
+ all_splits += splits_with_metadata
49
  except Exception as e:
50
  print(f"Error processing {file_path}: {e}")
51
  error_files.append(file_path) # Store the problematic file