Update app.py
Browse files
app.py
CHANGED
@@ -24,15 +24,33 @@ def get_pdf_text(pdf_docs):
|
|
24 |
|
25 |
# κ³Όμ
|
26 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
27 |
-
def get_text_file(
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
38 |
def get_text_chunks(documents):
|
|
|
24 |
|
25 |
# κ³Όμ
|
26 |
# μλ ν
μ€νΈ μΆμΆ ν¨μλ₯Ό μμ±
|
27 |
+
def get_text_file(text_docs):
|
28 |
+
text_data = []
|
29 |
+
for doc in docs:
|
30 |
+
if doc.lower().endswith('.txt'):
|
31 |
+
with open(doc, 'r', encoding='utf-8') as file:
|
32 |
+
text = file.read()
|
33 |
+
text_data.append(text)
|
34 |
+
return text_data
|
35 |
+
|
36 |
+
def get_csv_file(csv_docs):
|
37 |
+
csv_data = []
|
38 |
+
for doc in docs:
|
39 |
+
if doc.lower().endswith('.csv'):
|
40 |
+
with open(doc, 'r', newline='', encoding='utf-8') as file:
|
41 |
+
csv_reader = csv.reader(file)
|
42 |
+
data = [row for row in csv_reader]
|
43 |
+
csv_data.append(data)
|
44 |
+
return csv_data
|
45 |
+
|
46 |
+
def get_json_file(json_docs):
|
47 |
+
json_data = []
|
48 |
+
for doc in docs:
|
49 |
+
if doc.lower().endswith('.json'):
|
50 |
+
with open(doc, 'r', encoding='utf-8') as file:
|
51 |
+
data = json.load(file)
|
52 |
+
json_data.append(data)
|
53 |
+
return json_data
|
54 |
|
55 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
56 |
def get_text_chunks(documents):
|