Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,17 +29,32 @@ def get_pdf_text(pdf_docs):
|
|
| 29 |
# 과제
|
| 30 |
# 아래 텍스트 추출 함수를 작성
|
| 31 |
|
| 32 |
-
def get_text_file(
|
| 33 |
-
text =
|
| 34 |
return [text]
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
| 37 |
def get_csv_file(docs):
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
|
|
|
| 40 |
|
| 41 |
def get_json_file(docs):
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
|
|
|
|
| 29 |
# 과제
|
| 30 |
# 아래 텍스트 추출 함수를 작성
|
| 31 |
|
| 32 |
+
def get_text_file(docs):
|
| 33 |
+
text = docs.getvalue().decode("utf-8")
|
| 34 |
return [text]
|
| 35 |
|
| 36 |
|
| 37 |
+
import csv
|
| 38 |
+
|
| 39 |
def get_csv_file(docs):
|
| 40 |
+
text_list = []
|
| 41 |
+
decoded_content = docs.getvalue().decode('utf-8')
|
| 42 |
+
csv_reader = csv.reader(decoded_content.splitlines())
|
| 43 |
+
for row in csv_reader:
|
| 44 |
+
text_list.extend(row)
|
| 45 |
+
return text_list
|
| 46 |
+
|
| 47 |
|
| 48 |
+
import json
|
| 49 |
|
| 50 |
def get_json_file(docs):
|
| 51 |
+
text_list = []
|
| 52 |
+
json_content = json.load(docs)
|
| 53 |
+
# Extract text based on JSON structure
|
| 54 |
+
# Example assuming the JSON has a 'text' key:
|
| 55 |
+
for item in json_content:
|
| 56 |
+
text_list.append(item.get('text'))
|
| 57 |
+
return text_list
|
| 58 |
|
| 59 |
|
| 60 |
# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
|