Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,33 +25,30 @@ def get_pdf_text(pdf_docs):
|
|
25 |
# ๊ณผ์
|
26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
27 |
def get_text_file(docs):
|
28 |
-
|
29 |
-
return [text] # ํ
์คํธ๋ฅผ ๋ฆฌ์คํธ์ ๋ด์ ๋ฐํํฉ๋๋ค.
|
30 |
|
31 |
def get_csv_file(docs):
|
32 |
-
|
33 |
-
|
34 |
-
# CSV ํ์ผ์ Pandas DataFrame์ผ๋ก ์ฝ์ต๋๋ค.
|
35 |
-
df = pd.read_csv(file)
|
36 |
-
|
37 |
-
# ์ฌ๊ธฐ์์ ์ํ๋ ์ด์ ์ ํํ๊ฑฐ๋ ์ ์ฒด ํ์ผ์ ์ฝ์ด์ฌ ์ ์์ต๋๋ค.
|
38 |
-
# ์๋ฅผ ๋ค์ด, 'text_column' ์ด์์ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
|
39 |
-
texts = df['text_column'].tolist()
|
40 |
-
|
41 |
-
return texts # ํ
์คํธ ๋ฆฌ์คํธ๋ฅผ ๋ฐํํฉ๋๋ค.
|
42 |
|
43 |
def get_json_file(docs):
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
# ์ฌ๊ธฐ์์ ์ ์ ํ ๋ฐฉ๋ฒ์ผ๋ก JSON ๋ฐ์ดํฐ์์ ํ
์คํธ๋ฅผ ์ถ์ถํฉ๋๋ค.
|
50 |
-
# ์๋ฅผ ๋ค์ด, 'text' ํค์ ํด๋นํ๋ ๊ฐ์ ์ถ์ถํ๋ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
|
51 |
-
texts = [item['text'] for item in data]
|
52 |
-
|
53 |
-
return texts
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
57 |
def get_text_chunks(documents):
|
|
|
25 |
# ๊ณผ์
|
26 |
# ์๋ ํ
์คํธ ์ถ์ถ ํจ์๋ฅผ ์์ฑ
|
27 |
def get_text_file(docs):
|
28 |
+
pass
|
|
|
29 |
|
30 |
def get_csv_file(docs):
|
31 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
def get_json_file(docs):
|
34 |
+
temp_dir = tempfile.TemporaryDirectory()
|
35 |
+
temp_filepath = os.path.join(temp_dir.name, pdf_docs.name)
|
36 |
+
with open(temp_filepath, "wb") as f:
|
37 |
+
f.write(pdf_docs.getvalue())
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
|
40 |
+
loader = JSONLoader(
|
41 |
+
file_path='./example_data/facebook_chat.json',
|
42 |
+
jq_schema='.messages[].content',
|
43 |
+
text_content=False)
|
44 |
+
|
45 |
+
data = loader.load()
|
46 |
+
return data
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
|
53 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
54 |
def get_text_chunks(documents):
|