Rasha-83 commited on
Commit
ba14c11
·
verified ·
1 Parent(s): 96060c5

Update app.py

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