Rasha-83 commited on
Commit
c5ef4a2
·
verified ·
1 Parent(s): e45568d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -28
app.py CHANGED
@@ -70,35 +70,15 @@ class ContractAnalyzer:
70
  if end_idx != -1:
71
  info["parties"].append(text[start_idx:end_idx].strip())
72
 
73
- # البحث عن موضوع العقد
74
- subject_indicators = [
75
- "موضوع العقد", "الغرض من العقد", "يتفق الطرفان على",
76
- "اتفق الطرفان على", "حيث أن", "حيث إن", "تمهيد",
77
- "بشأن", "لغرض", "عقد"
78
- ]
79
-
80
- for indicator in subject_indicators:
81
- if indicator in text:
82
- start_idx = text.find(indicator)
83
- # البحث عن نهاية الجملة
84
- end_idx = text.find(".", start_idx)
85
- if end_idx == -1:
86
- end_idx = text.find("\n", start_idx)
87
- if end_idx != -1:
88
- subject_text = text[start_idx:end_idx].strip()
89
- # تجنب النصوص القصيرة جداً
90
- if len(subject_text) > 10:
91
- info["subject"] = subject_text
92
- break
93
-
94
- # محاولة ثانية للعثور على الموضوع إذا لم يتم العثور عليه
95
- ## if info["subject"] == "غير محدد":
96
  # البحث في الجمل الأولى من العقد
97
- # first_sentences = text.split('.')[:3] # أول ثلاث جمل
98
- # for sentence in first_sentences:
99
- # if any(word in sentence.lower() for word in ["اتفاق", "عقد", "تعاقد"]):
100
- # info["subject"] = sentence.strip()
101
- # break
102
 
103
  return info
104
 
 
70
  if end_idx != -1:
71
  info["parties"].append(text[start_idx:end_idx].strip())
72
 
73
+
74
+ # محاولة للعثور على الموضوع
75
+ if info["subject"] == "غير محدد":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  # البحث في الجمل الأولى من العقد
77
+ first_sentences = text.split('.')[:3] # أول ثلاث جمل
78
+ for sentence in first_sentences:
79
+ if any(word in sentence.lower() for word in ["اتفاق", "عقد", "تعاقد"]):
80
+ info["subject"] = sentence.strip()
81
+ break
82
 
83
  return info
84