Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -90,13 +90,13 @@ class BookRecommender:
|
|
| 90 |
recommendations = []
|
| 91 |
for i, idx in enumerate(similar_books_idx):
|
| 92 |
book_data = {
|
| 93 |
-
'title': self.df.iloc[idx].get('Title', ''),
|
| 94 |
-
'author': self.df.iloc[idx].get('Authors', ''),
|
| 95 |
-
'category': self.df.iloc[idx].get('Category', ''),
|
| 96 |
-
'year': self.df.iloc[idx].get('Publish Date (Year)', ''),
|
| 97 |
-
'description': self.df.iloc[idx].get('Description', '')[:197] + "..." if include_description and 'Description' in self.df.columns else '',
|
| 98 |
'relevance_score': float(similarities[idx]),
|
| 99 |
-
'rank': i + 1
|
| 100 |
}
|
| 101 |
recommendations.append(book_data)
|
| 102 |
return recommendations
|
|
|
|
| 90 |
recommendations = []
|
| 91 |
for i, idx in enumerate(similar_books_idx):
|
| 92 |
book_data = {
|
| 93 |
+
'title': str(self.df.iloc[idx].get('Title', '')),
|
| 94 |
+
'author': str(self.df.iloc[idx].get('Authors', '')),
|
| 95 |
+
'category': str(self.df.iloc[idx].get('Category', '')),
|
| 96 |
+
'year': str(self.df.iloc[idx].get('Publish Date (Year)', '')),
|
| 97 |
+
'description': str(self.df.iloc[idx].get('Description', '')[:197] + "...") if include_description and 'Description' in self.df.columns else '',
|
| 98 |
'relevance_score': float(similarities[idx]),
|
| 99 |
+
'rank': int(i + 1)
|
| 100 |
}
|
| 101 |
recommendations.append(book_data)
|
| 102 |
return recommendations
|