Spaces:
Runtime error
Runtime error
Commit ·
71baa59
1
Parent(s): 24545c3
Update app.py
Browse files
app.py
CHANGED
|
@@ -121,12 +121,12 @@ def extractScannedPDF(filePath, chainType):
|
|
| 121 |
else:
|
| 122 |
print(f"Folder {folder_path} already exists.")
|
| 123 |
|
| 124 |
-
with open('
|
| 125 |
f.write(text)
|
| 126 |
-
with open(
|
| 127 |
docRead = f.read()
|
| 128 |
|
| 129 |
-
documents = SimpleDirectoryReader(
|
| 130 |
index = GPTSimpleVectorIndex.from_documents(documents)
|
| 131 |
index.save_to_disk('index2.json')
|
| 132 |
|
|
@@ -159,8 +159,6 @@ def extractPDF(filePath, chainType):
|
|
| 159 |
text += txt.extract_text() + "\n"
|
| 160 |
print('Total No. of pages = ', counter)
|
| 161 |
|
| 162 |
-
# folder_path = "/content/doc"
|
| 163 |
-
|
| 164 |
print('Save to output1.txt')
|
| 165 |
if not os.path.exists(folder_path):
|
| 166 |
os.makedirs(folder_path)
|
|
|
|
| 121 |
else:
|
| 122 |
print(f"Folder {folder_path} already exists.")
|
| 123 |
|
| 124 |
+
with open(folder_path + 'output2.txt', 'w') as f:
|
| 125 |
f.write(text)
|
| 126 |
+
with open(folder_path + 'output2.txt') as f:
|
| 127 |
docRead = f.read()
|
| 128 |
|
| 129 |
+
documents = SimpleDirectoryReader(folder_path).load_data()
|
| 130 |
index = GPTSimpleVectorIndex.from_documents(documents)
|
| 131 |
index.save_to_disk('index2.json')
|
| 132 |
|
|
|
|
| 159 |
text += txt.extract_text() + "\n"
|
| 160 |
print('Total No. of pages = ', counter)
|
| 161 |
|
|
|
|
|
|
|
| 162 |
print('Save to output1.txt')
|
| 163 |
if not os.path.exists(folder_path):
|
| 164 |
os.makedirs(folder_path)
|