Rasha-83 commited on
Commit
ba8d812
·
verified ·
1 Parent(s): 7c3f1a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -1
app.py CHANGED
@@ -73,7 +73,49 @@ class ContractAnalyzer:
73
  5. توصيات قانونية:
74
  {recommendations}
75
  """
76
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  def compute_similarity(self, sentences: List[str]) -> float:
78
  """حساب درجة التشابه بين الجمل"""
79
  if not sentences:
 
73
  5. توصيات قانونية:
74
  {recommendations}
75
  """
76
+ def extract_contract_info(self, text):
77
+ """استخراج المعلومات الأساسية من العقد"""
78
+ info = {
79
+ "date": "غير محدد",
80
+ "parties": [],
81
+ "subject": "غير محدد"
82
+ }
83
+
84
+ # البحث عن التاريخ
85
+ date_indicators = ["بتاريخ", "في يوم", "الموافق"]
86
+ for indicator in date_indicators:
87
+ if indicator in text:
88
+ # استخراج التاريخ باستخدام تعبير نمطي بسيط
89
+ start_idx = text.find(indicator)
90
+ end_idx = text.find("\n", start_idx)
91
+ if end_idx == -1:
92
+ end_idx = text.find(".", start_idx)
93
+ if end_idx != -1:
94
+ info["date"] = text[start_idx:end_idx].strip()
95
+
96
+ # البحث عن الأطراف
97
+ party_indicators = ["طرف أول", "طرف ثاني", "الطرف الأول", "الطرف الثاني", "الفريق الأول", "الفريق الثاني"]
98
+ for indicator in party_indicators:
99
+ if indicator in text:
100
+ start_idx = text.find(indicator)
101
+ end_idx = text.find("\n", start_idx)
102
+ if end_idx == -1:
103
+ end_idx = text.find(".", start_idx)
104
+ if end_idx != -1:
105
+ info["parties"].append(text[start_idx:end_idx].strip())
106
+
107
+
108
+ # محاولة للعثور على الموضوع
109
+ if info["subject"] == "غير محدد":
110
+ # البحث في الجمل الأولى من العقد
111
+ first_sentences = text.split('\n')[:3] # أول ثلاث جمل
112
+ for sentence in first_sentences:
113
+ if any(word in sentence.lower() for word in ["اتفاق", "عقد", "تعاقد"]):
114
+ info["subject"] = sentence.strip()
115
+ break
116
+
117
+ return info
118
+
119
  def compute_similarity(self, sentences: List[str]) -> float:
120
  """حساب درجة التشابه بين الجمل"""
121
  if not sentences: