Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,30 +29,20 @@ def get_pdf_text(pdf_docs):
|
|
| 29 |
# 아래 텍스트 추출 함수를 작성
|
| 30 |
|
| 31 |
def get_text_file(text_docs):
|
| 32 |
-
|
| 33 |
-
text_content = docs.getvalue().decode("utf-8") # UTF-8 인코딩을 기준으로 디코딩합니다.
|
| 34 |
return [text_content]
|
| 35 |
|
| 36 |
def get_csv_file(csv_docs):
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
csv_content = docs.getvalue().decode("utf-8") # 바이트를 문자열로 디코딩합니다.
|
| 40 |
-
csv_data = pd.read_csv(pd.compat.StringIO(csv_content)) # Pandas를 사용하여 CSV를 읽어옵니다.
|
| 41 |
text_list = []
|
| 42 |
-
|
| 43 |
-
# 필요한 대로 각 열 또는 행에서 텍스트를 추출합니다.
|
| 44 |
for column in csv_data.columns:
|
| 45 |
text_list.extend(csv_data[column].astype(str).tolist())
|
| 46 |
-
|
| 47 |
return text_list
|
| 48 |
|
| 49 |
def get_json_file(json_docs):
|
| 50 |
-
|
| 51 |
-
import json
|
| 52 |
-
json_content = docs.getvalue().decode("utf-8") # 바이트를 문자열로 디코딩합니다.
|
| 53 |
json_data = json.loads(json_content)
|
| 54 |
-
|
| 55 |
-
# 필요한 대로 JSON 키 또는 값에서 텍스트를 추출합니다.
|
| 56 |
text_list = []
|
| 57 |
for key, value in json_data.items():
|
| 58 |
if isinstance(value, str):
|
|
@@ -61,9 +51,7 @@ def get_json_file(json_docs):
|
|
| 61 |
text_list.extend(value)
|
| 62 |
elif isinstance(value, dict):
|
| 63 |
text_list.extend(value.values())
|
| 64 |
-
|
| 65 |
return text_list
|
| 66 |
-
|
| 67 |
|
| 68 |
# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
|
| 69 |
def get_text_chunks(documents):
|
|
|
|
| 29 |
# 아래 텍스트 추출 함수를 작성
|
| 30 |
|
| 31 |
def get_text_file(text_docs):
|
| 32 |
+
text_content = text_docs.getvalue().decode("utf-8")
|
|
|
|
| 33 |
return [text_content]
|
| 34 |
|
| 35 |
def get_csv_file(csv_docs):
|
| 36 |
+
csv_content = csv_docs.getvalue().decode("utf-8")
|
| 37 |
+
csv_data = pd.read_csv(pd.compat.StringIO(csv_content))
|
|
|
|
|
|
|
| 38 |
text_list = []
|
|
|
|
|
|
|
| 39 |
for column in csv_data.columns:
|
| 40 |
text_list.extend(csv_data[column].astype(str).tolist())
|
|
|
|
| 41 |
return text_list
|
| 42 |
|
| 43 |
def get_json_file(json_docs):
|
| 44 |
+
json_content = json_docs.getvalue().decode("utf-8")
|
|
|
|
|
|
|
| 45 |
json_data = json.loads(json_content)
|
|
|
|
|
|
|
| 46 |
text_list = []
|
| 47 |
for key, value in json_data.items():
|
| 48 |
if isinstance(value, str):
|
|
|
|
| 51 |
text_list.extend(value)
|
| 52 |
elif isinstance(value, dict):
|
| 53 |
text_list.extend(value.values())
|
|
|
|
| 54 |
return text_list
|
|
|
|
| 55 |
|
| 56 |
# 문서들을 처리하여 텍스트 청크로 나누는 함수입니다.
|
| 57 |
def get_text_chunks(documents):
|