Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -50,6 +50,20 @@ if uploaded_file is not None:
|
|
50 |
current_index = 0 # مؤشر للكلمة الحالية
|
51 |
batch_size = 10 # عدد العناصر التي يتم معالجتها في الدفعة الواحدة
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# دالة تصنيف الكلمات باستخدام الدفعات
|
54 |
def classify_keywords_batch(items, categories, start_index=0):
|
55 |
global paused, stopped, current_index
|
@@ -166,10 +180,15 @@ if uploaded_file is not None:
|
|
166 |
paused = False
|
167 |
current_index = 0
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
# زر الإيقاف المؤقت
|
175 |
if pause_button:
|
|
|
50 |
current_index = 0 # مؤشر للكلمة الحالية
|
51 |
batch_size = 10 # عدد العناصر التي يتم معالجتها في الدفعة الواحدة
|
52 |
|
53 |
+
# دالة التحقق من صحة الملف
|
54 |
+
def validate_file(items, operation):
|
55 |
+
if operation == "Filter Keywords":
|
56 |
+
# التحقق من أن الملف يحتوي على كلمات مفتاحية فقط
|
57 |
+
for item in items:
|
58 |
+
if re.match(r'https?://', item):
|
59 |
+
return False, "File should contain keywords only."
|
60 |
+
elif operation == "Extra & Filter Param (URLs)":
|
61 |
+
# التحقق من أن الملف يحتوي على روابط فقط
|
62 |
+
for item in items:
|
63 |
+
if not re.match(r'https?://', item):
|
64 |
+
return False, "File should contain URLs only."
|
65 |
+
return True, ""
|
66 |
+
|
67 |
# دالة تصنيف الكلمات باستخدام الدفعات
|
68 |
def classify_keywords_batch(items, categories, start_index=0):
|
69 |
global paused, stopped, current_index
|
|
|
180 |
paused = False
|
181 |
current_index = 0
|
182 |
|
183 |
+
# التحقق من صحة الملف
|
184 |
+
is_valid, error_message = validate_file(items, operation)
|
185 |
+
if not is_valid:
|
186 |
+
st.error(error_message)
|
187 |
+
else:
|
188 |
+
if operation == "Filter Keywords":
|
189 |
+
classify_keywords_batch(items, categories, start_index=current_index)
|
190 |
+
elif operation == "Extra & Filter Param (URLs)":
|
191 |
+
classify_parameters(items, categories, start_index=current_index)
|
192 |
|
193 |
# زر الإيقاف المؤقت
|
194 |
if pause_button:
|