Mohzen321 commited on
Commit
77f27da
·
verified ·
1 Parent(s): 865820b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -29,14 +29,17 @@ if uploaded_file is not None:
29
  progress_bar = st.progress(0)
30
  pause_button = st.button("Pause")
31
  stop_button = st.button("Stop")
 
32
  paused = False
33
  stopped = False
 
34
 
35
  # دالة تصنيف الكلمات
36
- def classify_keywords(keywords, categories):
37
- global paused, stopped # استخدام المتغيرات العالمية
38
  total_keywords = len(keywords)
39
- for i, word in enumerate(keywords):
 
40
  if stopped:
41
  break
42
  if paused:
@@ -59,7 +62,7 @@ if uploaded_file is not None:
59
  unknown_words.append(word) # إضافة الكلمة إلى قائمة Unknown إذا لم تكن ضمن الفئات
60
 
61
  # تحديث شريط التقدم
62
- progress = (i + 1) / total_keywords
63
  progress_bar.progress(progress)
64
 
65
  # تحديث النتائج في الوقت الحقيقي
@@ -80,15 +83,19 @@ if uploaded_file is not None:
80
  if st.button("Start"):
81
  stopped = False
82
  paused = False
83
- classify_keywords(keywords, categories)
 
84
 
85
  # زر الإيقاف المؤقت
86
  if pause_button:
87
- paused = not paused
88
- if paused:
89
- st.write("Classification paused.")
90
- else:
91
- st.write("Classification resumed.")
 
 
 
92
 
93
  # زر التوقف الكامل
94
  if stop_button:
 
29
  progress_bar = st.progress(0)
30
  pause_button = st.button("Pause")
31
  stop_button = st.button("Stop")
32
+ continue_button = st.button("Continue") # زر جديد للاستمرار
33
  paused = False
34
  stopped = False
35
+ current_index = 0 # مؤشر للكلمة الحالية
36
 
37
  # دالة تصنيف الكلمات
38
+ def classify_keywords(keywords, categories, start_index=0):
39
+ global paused, stopped, current_index # استخدام المتغيرات العالمية
40
  total_keywords = len(keywords)
41
+ for i, word in enumerate(keywords[start_index:], start=start_index):
42
+ current_index = i # تحديث المؤشر الحالي
43
  if stopped:
44
  break
45
  if paused:
 
62
  unknown_words.append(word) # إضافة الكلمة إلى قائمة Unknown إذا لم تكن ضمن الفئات
63
 
64
  # تحديث شريط التقدم
65
+ progress = (current_index + 1) / total_keywords
66
  progress_bar.progress(progress)
67
 
68
  # تحديث النتائج في الوقت الحقيقي
 
83
  if st.button("Start"):
84
  stopped = False
85
  paused = False
86
+ current_index = 0 # إعادة تعيين المؤشر إلى البداية
87
+ classify_keywords(keywords, categories, start_index=current_index)
88
 
89
  # زر الإيقاف المؤقت
90
  if pause_button:
91
+ paused = True
92
+ st.write("Classification paused.")
93
+
94
+ # زر الاستمرار
95
+ if continue_button and paused:
96
+ paused = False
97
+ st.write("Classification resumed.")
98
+ classify_keywords(keywords, categories, start_index=current_index)
99
 
100
  # زر التوقف الكامل
101
  if stop_button: