1
This commit is contained in:
@@ -1009,6 +1009,23 @@ def save_error(id=0, e=Exception):
|
||||
file.write(error + '\n' + 50*'*' + '\n')
|
||||
return error
|
||||
|
||||
def is_image_file(file_path):
|
||||
if not file_path :
|
||||
return False
|
||||
|
||||
ext = os.path.splitext(file_path)[1].lower()
|
||||
|
||||
image_extensions = {
|
||||
'.jpg', '.jpeg', '.png', '.gif', '.bmp',
|
||||
'.webp', '.tiff', '.svg', '.ico'
|
||||
}
|
||||
|
||||
is_image = ext in image_extensions
|
||||
return is_image
|
||||
# # example
|
||||
# info = is_image_file('/path/to/file.png')
|
||||
# print(info)
|
||||
|
||||
# تابع برای تعیین نوع عنوان قانونی
|
||||
def getTitleType(caption: str) -> str:
|
||||
# عادیسازی متن ورودی
|
||||
@@ -1018,17 +1035,20 @@ def getTitleType(caption: str) -> str:
|
||||
if "موافقتنامه" in caption or "موافقت نامه" in caption or "کنوانسیون" in caption or \
|
||||
"قرارداد بین المللی" in caption or "مقررات بین المللی" in caption or "الحاق دولت" in caption or \
|
||||
"الحاق ایران" in caption or "قرارداد بین المللی" in caption or \
|
||||
caption.startswith("قانون عضویت دولت") or caption.startswith("قانون عضویت ایران") or caption.startswith("قانون اجازه عضویت"):
|
||||
caption.startswith("قانون عضویت دولت") or caption.startswith("قانون عضویت ایران") or \
|
||||
caption.startswith("قانون اجازه عضویت") or caption.startswith("قانون معاهده") or caption.startswith("قانون یادداشت تفاهم بین") :
|
||||
|
||||
return "موافقتنامه"
|
||||
elif caption.startswith("الحاق ") or caption.startswith("قانون الحاق ") or caption.startswith("قانون الحاقیه "):
|
||||
return "الحاقی"
|
||||
elif re.match(r"^قانون اضافه.*قانون", caption):
|
||||
return "الحاقی"
|
||||
elif caption.startswith("اصلاح ") or re.match(r"^قانون اصلاح(?:ی)? .*قانون", caption) or re.match(r"^لایحه قانونی اصلاح(?:ی)? .*لایحه", caption):
|
||||
elif caption.startswith("اصلاح ") or re.match(r"^قانون اصلاح(?:ی)? .*(قانون|قوانین)", caption) or re.match(r"^لایحه قانونی اصلاح(?:ی)? .*لایحه", caption):
|
||||
return "اصلاحی"
|
||||
elif re.match(r"^قانون اصلاحیه.*قانون", caption):
|
||||
return "اصلاحی"
|
||||
elif caption.startswith("اصلاحیه "):
|
||||
return "اصلاحی"
|
||||
elif re.match(r"^قانون تغییر.*قانون", caption):
|
||||
return "اصلاحی"
|
||||
elif caption.startswith("نظر تفسیری ") or caption.startswith("استفساریه ") or caption.startswith("تفسیر ") or caption.startswith("قانون تفسیر ") or caption.startswith("قانون استفساریه "):
|
||||
@@ -1075,7 +1095,7 @@ def getTitleType(caption: str) -> str:
|
||||
else:
|
||||
return "اصلی"
|
||||
|
||||
|
||||
# ["الحاقی","اصلاحی","تفسیری","نامه","لغو","حذفی","تمدیدی","شمولی","نسخی","مربوط"]
|
||||
|
||||
#////////////////////////////////////////////////////////////
|
||||
#////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user