Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,14 +12,20 @@ class HadithClassificationApp:
|
|
| 12 |
# Download NLTK resources if needed
|
| 13 |
nltk.download('punkt')
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Load the dataset and labels
|
| 16 |
-
self.dataset = pd.read_csv(
|
| 17 |
self.labels = self.dataset['Arabic_Grade']
|
| 18 |
|
| 19 |
# Load the models
|
| 20 |
-
with open(
|
| 21 |
self.vectorizer = pickle.load(f)
|
| 22 |
-
with open(
|
| 23 |
self.X = pickle.load(f)
|
| 24 |
|
| 25 |
@staticmethod
|
|
|
|
| 12 |
# Download NLTK resources if needed
|
| 13 |
nltk.download('punkt')
|
| 14 |
|
| 15 |
+
# Define file paths
|
| 16 |
+
base_path = os.path.dirname(__file__)
|
| 17 |
+
dataset_path = os.path.join(base_path, "Preprocess_LK_Hadith_dataset.csv")
|
| 18 |
+
vectorizer_path = os.path.join(base_path, "tfidf_vectorizer.pkl")
|
| 19 |
+
similarity_model_path = os.path.join(base_path, "cosine_similarity_model.pkl")
|
| 20 |
+
|
| 21 |
# Load the dataset and labels
|
| 22 |
+
self.dataset = pd.read_csv(dataset_path)
|
| 23 |
self.labels = self.dataset['Arabic_Grade']
|
| 24 |
|
| 25 |
# Load the models
|
| 26 |
+
with open(vectorizer_path, "rb") as f:
|
| 27 |
self.vectorizer = pickle.load(f)
|
| 28 |
+
with open(similarity_model_path, "rb") as f:
|
| 29 |
self.X = pickle.load(f)
|
| 30 |
|
| 31 |
@staticmethod
|