Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,12 @@ from sentence_transformers import SentenceTransformer, util
|
|
| 3 |
import PyPDF2
|
| 4 |
import nltk
|
| 5 |
from nltk.tokenize import sent_tokenize
|
|
|
|
| 6 |
|
| 7 |
# Ensure NLTK resources are downloaded
|
| 8 |
-
nltk.
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Function to extract text from the uploaded PDF
|
| 11 |
def extract_text_from_pdf(pdf_file):
|
|
|
|
| 3 |
import PyPDF2
|
| 4 |
import nltk
|
| 5 |
from nltk.tokenize import sent_tokenize
|
| 6 |
+
from pathlib import Path
|
| 7 |
|
| 8 |
# Ensure NLTK resources are downloaded
|
| 9 |
+
nltk_data_path = Path(nltk.data.find("tokenizers/punkt").path) if nltk.data.find("tokenizers/punkt") else None
|
| 10 |
+
if not nltk_data_path:
|
| 11 |
+
nltk.download("punkt", quiet=True)
|
| 12 |
|
| 13 |
# Function to extract text from the uploaded PDF
|
| 14 |
def extract_text_from_pdf(pdf_file):
|