Update app.py
Browse files
app.py
CHANGED
@@ -28,8 +28,14 @@ def get_pdf_text(pdf_docs):
|
|
28 |
# 과제
|
29 |
# 아래 텍스트 추출 함수를 작성
|
30 |
|
31 |
-
def get_text_file(
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
|
35 |
def get_csv_file(docs):
|
|
|
28 |
# 과제
|
29 |
# 아래 텍스트 추출 함수를 작성
|
30 |
|
31 |
+
def get_text_file(text_docs):
|
32 |
+
temp_dir1 = tempfile.TemporaryDirectory() # 임시 디렉토리를 생성합니다.
|
33 |
+
temp_filepath1 = os.path.join(temp_dir1.name, text_docs.name) # 임시 파일 경로를 생성합니다.
|
34 |
+
with open(temp_filepath1, "wb") as f: # 임시 파일을 바이너리 쓰기 모드로 엽니다.
|
35 |
+
f.write(text_docs.getvalue()) # PDF 문서의 내용을 임시 파일에 씁니다.
|
36 |
+
text_loader = TEXTLoader(temp_filepath1) # PyPDFLoader를 사용해 PDF를 로드합니다.
|
37 |
+
text_doc = text_loader.load() # 텍스트를 추출합니다.
|
38 |
+
return text_doc # 추출한 텍스트를 반환합니다.
|
39 |
|
40 |
|
41 |
def get_csv_file(docs):
|