Spaces:
Sleeping
Sleeping
Commit
Β·
5b9f44d
1
Parent(s):
42fabaa
Update app.py
Browse files
app.py
CHANGED
@@ -44,30 +44,18 @@ def get_csv_file(csv_docs):
|
|
44 |
return csv_doc
|
45 |
|
46 |
import json
|
47 |
-
import mimetypes
|
48 |
-
|
49 |
def get_json_file(docs):
|
|
|
|
|
|
|
|
|
50 |
text_list = []
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
if file_extension == 'json':
|
57 |
-
# Read the JSON content from the file
|
58 |
-
json_content = json.loads(file.getvalue().decode('utf-8'))
|
59 |
-
|
60 |
-
# Extract text from the JSON content
|
61 |
-
if isinstance(json_content, dict):
|
62 |
-
text = ' '.join(str(value) for value in json_content.values())
|
63 |
-
text_list.append(text)
|
64 |
-
elif isinstance(json_content, list):
|
65 |
-
text = ' '.join(str(item) for item in json_content)
|
66 |
-
text_list.append(text)
|
67 |
-
|
68 |
return text_list
|
69 |
|
70 |
-
|
71 |
|
72 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
73 |
def get_text_chunks(documents):
|
|
|
44 |
return csv_doc
|
45 |
|
46 |
import json
|
|
|
|
|
47 |
def get_json_file(docs):
|
48 |
+
# Assuming docs is a file-like object from st.file_uploader
|
49 |
+
json_docs = json.load(docs)
|
50 |
+
|
51 |
+
# Extracting text from the JSON structure (modify this part based on your JSON structure)
|
52 |
text_list = []
|
53 |
+
for item in json_docs:
|
54 |
+
if 'text' in item:
|
55 |
+
text_list.append(item['text'])
|
56 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
return text_list
|
58 |
|
|
|
59 |
|
60 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
61 |
def get_text_chunks(documents):
|