Spaces:
Running
Running
t commited on
Commit ·
045dca4
1
Parent(s): b49d3e6
- classifier_routes.py +16 -1
classifier_routes.py
CHANGED
|
@@ -257,7 +257,22 @@ def extract_and_classify_all(session_id):
|
|
| 257 |
|
| 258 |
new_subject = item.get('subject')
|
| 259 |
new_chapter = item.get('chapter_title')
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
if new_subject and new_subject != 'Unclassified' and new_chapter and new_chapter != 'Unclassified':
|
| 262 |
conn.execute('UPDATE questions SET subject = ?, chapter = ? WHERE image_id = ?', (new_subject, new_chapter, matched_id))
|
| 263 |
batch_update_count += 1
|
|
|
|
| 257 |
|
| 258 |
new_subject = item.get('subject')
|
| 259 |
new_chapter = item.get('chapter_title')
|
| 260 |
+
|
| 261 |
+
# Ensure new_subject and new_chapter are strings, not lists
|
| 262 |
+
if isinstance(new_subject, list):
|
| 263 |
+
new_subject = ', '.join(str(x) for x in new_subject) if new_subject else 'Unclassified'
|
| 264 |
+
elif new_subject is None:
|
| 265 |
+
new_subject = 'Unclassified'
|
| 266 |
+
else:
|
| 267 |
+
new_subject = str(new_subject)
|
| 268 |
+
|
| 269 |
+
if isinstance(new_chapter, list):
|
| 270 |
+
new_chapter = ', '.join(str(x) for x in new_chapter) if new_chapter else 'Unclassified'
|
| 271 |
+
elif new_chapter is None:
|
| 272 |
+
new_chapter = 'Unclassified'
|
| 273 |
+
else:
|
| 274 |
+
new_chapter = str(new_chapter)
|
| 275 |
+
|
| 276 |
if new_subject and new_subject != 'Unclassified' and new_chapter and new_chapter != 'Unclassified':
|
| 277 |
conn.execute('UPDATE questions SET subject = ?, chapter = ? WHERE image_id = ?', (new_subject, new_chapter, matched_id))
|
| 278 |
batch_update_count += 1
|