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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="ar" dir="rtl">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>نظام المقارنة والترجمة الخاص بشركة موندو لينجوا</title>
|
7 |
+
<!-- استيراد مكتبات Tailwind وFont Awesome وMammoth -->
|
8 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
|
9 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
|
10 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
11 |
+
<style>
|
12 |
+
/* ================================
|
13 |
+
تنسيقات الحركات والتأثيرات
|
14 |
+
================================= */
|
15 |
+
@keyframes gradient {
|
16 |
+
0% { background-position: 0% 50%; }
|
17 |
+
50% { background-position: 100% 50%; }
|
18 |
+
100% { background-position: 0% 50%; }
|
19 |
+
}
|
20 |
+
.animate-gradient {
|
21 |
+
background-size: 200% 200%;
|
22 |
+
animation: gradient 15s ease infinite;
|
23 |
+
}
|
24 |
+
.transition-all { transition: all 0.3s ease-in-out; }
|
25 |
+
.animate-scale { transition: transform 0.2s ease-in-out; }
|
26 |
+
.animate-scale:hover { transform: scale(1.02); }
|
27 |
+
.pulse-animation { animation: pulse 2s infinite; }
|
28 |
+
@keyframes pulse {
|
29 |
+
0% { box-shadow: 0 0 0 0 rgba(156,39,176,0.4); }
|
30 |
+
70% { box-shadow: 0 0 0 10px rgba(156,39,176,0); }
|
31 |
+
100% { box-shadow: 0 0 0 0 rgba(156,39,176,0); }
|
32 |
+
}
|
33 |
+
|
34 |
+
/* ================================
|
35 |
+
تنسيقات النصوص والتحديد
|
36 |
+
================================= */
|
37 |
+
.text-comparison { line-height: 1.8; white-space: pre-wrap; }
|
38 |
+
.highlight-number {
|
39 |
+
background-color: #FDE68A;
|
40 |
+
padding: 0 4px;
|
41 |
+
border-radius: 3px;
|
42 |
+
font-weight: bold;
|
43 |
+
}
|
44 |
+
.highlight-missing {
|
45 |
+
background-color: #BFDBFE;
|
46 |
+
padding: 0 4px;
|
47 |
+
border-radius: 3px;
|
48 |
+
font-style: italic;
|
49 |
+
}
|
50 |
+
.highlight-meaning {
|
51 |
+
background-color: #fecaca;
|
52 |
+
color: #B91C1C;
|
53 |
+
padding: 0 4px;
|
54 |
+
border-radius: 3px;
|
55 |
+
font-weight: bold;
|
56 |
+
}
|
57 |
+
|
58 |
+
/* ================================
|
59 |
+
تنسيق عرض السطور في المعاينة
|
60 |
+
================================= */
|
61 |
+
.split-view {
|
62 |
+
display: grid;
|
63 |
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
64 |
+
gap: 1rem;
|
65 |
+
}
|
66 |
+
.line-item {
|
67 |
+
display: flex;
|
68 |
+
align-items: flex-start;
|
69 |
+
margin-bottom: 0.5rem;
|
70 |
+
}
|
71 |
+
.line-number {
|
72 |
+
width: 30px;
|
73 |
+
font-weight: bold;
|
74 |
+
color: #4B5563;
|
75 |
+
flex-shrink: 0;
|
76 |
+
}
|
77 |
+
.line-text { flex: 1; }
|
78 |
+
|
79 |
+
/* ================================
|
80 |
+
تحسين تنسيق البطاقات والعناصر
|
81 |
+
================================= */
|
82 |
+
.card-hover {
|
83 |
+
transition: all 0.3s ease;
|
84 |
+
}
|
85 |
+
.card-hover:hover {
|
86 |
+
box-shadow: 0 10px 25px -5px rgba(156,39,176,0.1), 0 10px 10px -5px rgba(156,39,176,0.04);
|
87 |
+
transform: translateY(-2px);
|
88 |
+
}
|
89 |
+
|
90 |
+
/* ================================
|
91 |
+
تنسيقات المسودة المخفية والتقسيمات
|
92 |
+
================================= */
|
93 |
+
.collapsible-section {
|
94 |
+
border: 1px solid #e5e7eb;
|
95 |
+
border-radius: 8px;
|
96 |
+
margin-bottom: 8px;
|
97 |
+
overflow: hidden;
|
98 |
+
background-color: #f9fafb;
|
99 |
+
}
|
100 |
+
|
101 |
+
.section-header {
|
102 |
+
background-color: #f3f4f6;
|
103 |
+
padding: 12px 16px;
|
104 |
+
cursor: pointer;
|
105 |
+
display: flex;
|
106 |
+
justify-content: space-between;
|
107 |
+
align-items: center;
|
108 |
+
font-weight: 600;
|
109 |
+
border-bottom: 1px solid #e5e7eb;
|
110 |
+
}
|
111 |
+
|
112 |
+
.section-header:hover {
|
113 |
+
background-color: #e5e7eb;
|
114 |
+
}
|
115 |
+
|
116 |
+
.section-content {
|
117 |
+
max-height: 0;
|
118 |
+
overflow: hidden;
|
119 |
+
transition: max-height 0.3s ease-out;
|
120 |
+
padding: 0 16px;
|
121 |
+
}
|
122 |
+
|
123 |
+
.section-content.open {
|
124 |
+
max-height: 1000px; /* تغييره حسب احتياجك */
|
125 |
+
padding: 16px;
|
126 |
+
transition: max-height 0.5s ease-in, padding 0.3s ease-in;
|
127 |
+
}
|
128 |
+
|
129 |
+
.draft-marker {
|
130 |
+
display: inline-block;
|
131 |
+
background-color: #e5e7eb;
|
132 |
+
padding: 2px 6px;
|
133 |
+
border-radius: 4px;
|
134 |
+
font-size: 0.75rem;
|
135 |
+
margin-right: 8px;
|
136 |
+
color: #4b5563;
|
137 |
+
}
|
138 |
+
|
139 |
+
.sync-word {
|
140 |
+
color: #4f46e5;
|
141 |
+
font-weight: 500;
|
142 |
+
}
|
143 |
+
|
144 |
+
.paragraph-section {
|
145 |
+
border-left: 3px solid #d1d5db;
|
146 |
+
padding-left: 12px;
|
147 |
+
margin-bottom: 16px;
|
148 |
+
}
|
149 |
+
</style>
|
150 |
+
</head>
|
151 |
+
<body class="bg-gradient-to-br from-gray-100 via-blue-100 to-indigo-100 min-h-screen">
|
152 |
+
<div class="min-h-screen pb-12">
|
153 |
+
<!-- ============ رأس الصفحة ============ -->
|
154 |
+
<header class="bg-gradient-to-r from-indigo-700 via-purple-700 to-pink-700 animate-gradient text-white py-10 mb-10 shadow-xl">
|
155 |
+
<div class="max-w-6xl mx-auto px-4">
|
156 |
+
<h1 class="text-5xl font-bold text-center mb-4 animate-scale">النظام المراجع الذكي </h1>
|
157 |
+
<p class="text-center text-xl text-blue-100 opacity-90">مقارنة وتحليل النصوص – المصدر مرجع أساسي</p>
|
158 |
+
</div>
|
159 |
+
</header>
|
160 |
+
|
161 |
+
<!-- ============ شرح البرنامج التعريفي ============ -->
|
162 |
+
<section id="programExplanation" class="max-w-6xl mx-auto px-4 mb-8">
|
163 |
+
<div class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100">
|
164 |
+
<p class="text-lg text-gray-800">
|
165 |
+
هذا البرنامج مصمم لمقارنة النصوص التقنية وتحليلها بدقة عالية، مع تحديد الاختلافات في الأرقام، النصوص المفقودة واختلافات المعنى. يمكنك أيضًا التحقق مما إذا تم استخدام قاعدة المصطلحات أثناء التحليل وتنزيل تقرير مفصل بصيغة إكسيل أو وورد.
|
166 |
+
</p>
|
167 |
+
</div>
|
168 |
+
</section>
|
169 |
+
|
170 |
+
<!-- ============ المحتوى الرئيسي ============ -->
|
171 |
+
<main class="max-w-6xl mx-auto px-4">
|
172 |
+
<!-- قسم رفع الملفات -->
|
173 |
+
<div class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100 hover:shadow-xl transition-all animate-scale mb-8 card-hover">
|
174 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800 flex items-center border-b pb-3">
|
175 |
+
<i class="fas fa-file-upload text-indigo-600 ml-2"></i> تحميل الملفات
|
176 |
+
</h2>
|
177 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
178 |
+
<!-- ملف السورس -->
|
179 |
+
<div class="group border-2 border-dashed border-indigo-300 rounded-xl p-8 text-center hover:border-indigo-500 transition-colors duration-300 bg-indigo-50 hover:bg-indigo-100">
|
180 |
+
<label class="cursor-pointer block">
|
181 |
+
<input type="file" id="sourceFile" accept=".docx,.pdf" class="hidden">
|
182 |
+
<i class="fas fa-file-upload text-5xl text-indigo-500 mb-4"></i>
|
183 |
+
<span class="text-lg text-indigo-600 group-hover:text-indigo-700">ملف السورس</span>
|
184 |
+
</label>
|
185 |
+
</div>
|
186 |
+
<!-- ملف التارجت -->
|
187 |
+
<div class="group border-2 border-dashed border-pink-300 rounded-xl p-8 text-center hover:border-pink-500 transition-colors duration-300 bg-pink-50 hover:bg-pink-100">
|
188 |
+
<label class="cursor-pointer block">
|
189 |
+
<input type="file" id="targetFile" accept=".docx,.pdf" class="hidden">
|
190 |
+
<i class="fas fa-file-download text-5xl text-pink-500 mb-4"></i>
|
191 |
+
<span class="text-lg text-pink-600 group-hover:text-pink-700">ملف التارجت</span>
|
192 |
+
</label>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
<div id="processStatus" class="hidden mt-4">
|
196 |
+
<div class="flex items-center justify-center space-x-3 bg-indigo-100 rounded-xl p-4">
|
197 |
+
<div class="animate-spin h-8 w-8 border-4 border-indigo-600 rounded-full border-t-transparent"></div>
|
198 |
+
<span class="text-lg text-indigo-700">جارٍ معالجة الملف...</span>
|
199 |
+
</div>
|
200 |
+
</div>
|
201 |
+
</div>
|
202 |
+
|
203 |
+
<!-- قسم إدخال النصوص يدويًا وخيار استخدام قاعدة المصطلحات -->
|
204 |
+
<div class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100 hover:shadow-xl transition-all animate-scale mb-8 card-hover">
|
205 |
+
<div class="space-y-6">
|
206 |
+
<!-- النص المصدر -->
|
207 |
+
<div class="group">
|
208 |
+
<label class="block text-lg font-bold text-gray-700 mb-3 flex items-center">
|
209 |
+
<i class="fas fa-language text-indigo-600 ml-2"></i> النص المصدر
|
210 |
+
</label>
|
211 |
+
<textarea id="sourceText" dir="rtl" class="w-full px-6 py-4 border-2 border-gray-200 rounded-xl focus:ring-indigo-200 focus:border-indigo-400 transition-all resize-none text-lg" rows="6" placeholder="اكتب النص المصدر هنا..."></textarea>
|
212 |
+
</div>
|
213 |
+
<!-- النص الهدف -->
|
214 |
+
<div class="group">
|
215 |
+
<label class="block text-lg font-bold text-gray-700 mb-3 flex items-center">
|
216 |
+
<i class="fas fa-language text-pink-600 ml-2"></i> النص الهدف
|
217 |
+
</label>
|
218 |
+
<textarea id="targetText" dir="ltr" class="w-full px-6 py-4 border-2 border-gray-200 rounded-xl focus:ring-pink-200 focus:border-pink-400 transition-all resize-none text-lg" rows="6" placeholder="اكتب النص الهدف هنا..."></textarea>
|
219 |
+
</div>
|
220 |
+
<!-- خيار استخدام قاعدة المصطلحات -->
|
221 |
+
<div class="mt-4 flex items-center">
|
222 |
+
<input type="checkbox" id="terminologyCheck" class="mr-2">
|
223 |
+
<label for="terminologyCheck" class="text-lg text-gray-700">استخدام قاعدة المصطلحات</label>
|
224 |
+
</div>
|
225 |
+
</div>
|
226 |
+
</div>
|
227 |
+
|
228 |
+
<!-- قسم المصادر الإضافية -->
|
229 |
+
<div class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100 hover:shadow-xl transition-all animate-scale mb-8 card-hover">
|
230 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800 flex items-center border-b pb-3">
|
231 |
+
<i class="fas fa-book-open text-green-600 ml-2"></i> مصادر إضافية
|
232 |
+
</h2>
|
233 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
234 |
+
<!-- رفع ملف المصادر الإضافية -->
|
235 |
+
<div class="group border-2 border-dashed border-green-300 rounded-xl p-8 text-center hover:border-green-500 transition-colors duration-300 bg-green-50 hover:bg-green-100">
|
236 |
+
<label class="cursor-pointer block">
|
237 |
+
<input type="file" id="sourceExtraFile" accept=".docx,.pdf" class="hidden">
|
238 |
+
<i class="fas fa-upload text-5xl text-green-500 mb-4"></i>
|
239 |
+
<span class="text-lg text-green-600 group-hover:text-green-700">تحميل ملف المصدر</span>
|
240 |
+
</label>
|
241 |
+
</div>
|
242 |
+
<!-- إدخال المصادر يدويًا -->
|
243 |
+
<div class="group">
|
244 |
+
<label class="block text-lg font-bold text-gray-700 mb-3 flex items-center">
|
245 |
+
<i class="fas fa-edit text-green-600 ml-2"></i> إدخال المصادر يدويًا
|
246 |
+
</label>
|
247 |
+
<textarea id="sourceExtraText" dir="rtl" class="w-full px-6 py-4 border-2 border-green-200 rounded-xl focus:ring-green-200 focus:border-green-400 transition-all resize-none text-lg" rows="6" placeholder="اكتب المصادر هنا..."></textarea>
|
248 |
+
</div>
|
249 |
+
</div>
|
250 |
+
</div>
|
251 |
+
|
252 |
+
<!-- زر التحليل -->
|
253 |
+
<button id="submitBtn" class="w-full bg-gradient-to-r from-indigo-600 to-pink-600 hover:from-indigo-700 hover:to-pink-700 text-white font-bold py-5 px-8 rounded-xl transition-all transform hover:scale-105 focus:ring-indigo-200 text-xl shadow-lg hover:shadow-xl mb-8 pulse-animation">
|
254 |
+
<div class="flex items-center justify-center">
|
255 |
+
<i class="fas fa-sync-alt ml-2"></i> تحليل النصوص
|
256 |
+
</div>
|
257 |
+
</button>
|
258 |
+
|
259 |
+
<!-- شاشة عرض نتائج التحليل -->
|
260 |
+
<div id="resultSection" class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100 hover:shadow-xl transition-all animate-scale mb-8 hidden card-hover">
|
261 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-3 flex items-center">
|
262 |
+
<i class="fas fa-search text-green-600 ml-2"></i> نتائج التحليل والمقارنة
|
263 |
+
</h2>
|
264 |
+
<div id="errorsList" class="space-y-3 mb-6"></div>
|
265 |
+
<div class="result-section split-view">
|
266 |
+
<!-- عرض النص المصدر بعد التحديد مع ترقيم السطور -->
|
267 |
+
<div>
|
268 |
+
<h4 class="text-lg font-bold text-gray-700 mb-3 flex items-center">
|
269 |
+
<i class="fas fa-file-alt text-indigo-600 ml-2"></i> النص المصدر (مع التعليم)
|
270 |
+
</h4>
|
271 |
+
<div id="sourceTextReview" class="bg-indigo-50 rounded-xl p-6 min-h-[200px] border-2 border-indigo-100 text-comparison"></div>
|
272 |
+
</div>
|
273 |
+
<!-- عرض النص الهدف بعد التحديد مع ترقيم السطور -->
|
274 |
+
<div>
|
275 |
+
<h4 class="text-lg font-bold text-gray-700 mb-3 flex items-center">
|
276 |
+
<i class="fas fa-file-alt text-pink-600 ml-2"></i> النص الهدف (مع التعليم)
|
277 |
+
</h4>
|
278 |
+
<div id="targetTextReview" class="bg-gray-50 rounded-xl p-6 min-h-[200px] border-2 border-gray-200 text-comparison"></div>
|
279 |
+
</div>
|
280 |
+
</div>
|
281 |
+
</div>
|
282 |
+
|
283 |
+
<!-- صندوق عرض الشرح التفصيلي للنتائج -->
|
284 |
+
<div id="explanationBox" class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100 hover:shadow-xl transition-all animate-scale mb-8 hidden card-hover">
|
285 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-3 flex items-center">
|
286 |
+
<i class="fas fa-info-circle text-green-600 ml-2"></i> شرح الاختلافات
|
287 |
+
</h2>
|
288 |
+
<div id="explanationText" class="text-lg text-gray-700"></div>
|
289 |
+
</div>
|
290 |
+
|
291 |
+
<!-- قسم المسودة (تقسيمات الفقرات) - محسن ومخفي بشكل افتراضي -->
|
292 |
+
<div id="fullTextDraftSection" class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100 transition-all animate-scale mb-8 hidden card-hover">
|
293 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-3 flex items-center">
|
294 |
+
<i class="fas fa-file-alt text-blue-600 ml-2"></i> مسودة التحليل النصي الكامل
|
295 |
+
<span class="draft-marker mr-2">مسودة</span>
|
296 |
+
</h2>
|
297 |
+
<div id="paragraphDivisionsContainer" class="mt-4 space-y-2">
|
298 |
+
<!-- سيتم إنشاء التقسيمات هنا بواسطة JavaScript -->
|
299 |
+
</div>
|
300 |
+
</div>
|
301 |
+
|
302 |
+
<div class="flex flex-col md:flex-row md:items-center md:justify-between mb-8 space-y-4 md:space-y-0">
|
303 |
+
<button id="toggleDraftBtn" class="w-full md:w-auto bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
|
304 |
+
عرض/إخفاء مسودة التحليل
|
305 |
+
</button>
|
306 |
+
<!-- أزرار تنزيل التقرير -->
|
307 |
+
<div class="flex space-x-4">
|
308 |
+
<button id="downloadExcelBtn" class="w-full md:w-auto bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded">
|
309 |
+
تنزيل التقرير (Excel)
|
310 |
+
</button>
|
311 |
+
<button id="downloadWordBtn" class="w-full md:w-auto bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 px-4 rounded">
|
312 |
+
تنزيل التقرير (Word)
|
313 |
+
</button>
|
314 |
+
</div>
|
315 |
+
</div>
|
316 |
+
</main>
|
317 |
+
</div>
|
318 |
+
|
319 |
+
<!-- ================================
|
320 |
+
جافا سكريبت: الوظائف والمعالجة
|
321 |
+
================================= -->
|
322 |
+
<script>
|
323 |
+
// إعدادات API
|
324 |
+
const DEEPSEEK_API_URL = 'https://api.deepseek.com/chat/completions';
|
325 |
+
const DEEPSEEK_API_KEY = 'sk-15606736ed9e4aea8b7cc11a195d2b01';
|
326 |
+
|
327 |
+
// إعدادات API ChatGPT-4o
|
328 |
+
const CHATGPT_API_URL = 'https://api.openai.com/v1/chat/completions';
|
329 |
+
const CHATGPT_API_KEY = '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';
|
330 |
+
|
331 |
+
let fullAnalysisText = ''; // متغير لتخزين النص الكامل للتحليل
|
332 |
+
let analysisSegments = []; // متغير لتخزين مقاطع التحليل المقسمة
|
333 |
+
|
334 |
+
/*
|
335 |
+
البرومبت الجديد: يتم فيه تحديد أن النصوص مليئة بالأخطاء والنواقص،
|
336 |
+
مع ضرورة الحفاظ على علامات التحديد (التعليم) كما هي.
|
337 |
+
*/
|
338 |
+
const ANALYSIS_PROMPT = `أنت خبير لغوي متخصص في مراجعة الترجمة التقنية. مهمتك مقارنة النص المصدر والنص الهدف بدقة عالية مع العلم أن النصوص مليانة بالأخطاء والنواقص.
|
339 |
+
لا تقم بإزالة أو تعديل العلامات التالية:
|
340 |
+
• الأرقام: تحافظ على علامات < و >.
|
341 |
+
• النصوص المفقودة: تحافظ على علامات __ و __.
|
342 |
+
• اختلافات المعنى: تحافظ على علامات [MEANING] و [/MEANING].
|
343 |
+
|
344 |
+
اعتمد النص المصدر كأساس للمقارنة، وقم بتحديد:
|
345 |
+
1. اختلافات الأرقام باستخدام <الرقم_في_المصدر> → <الرقم_في_الهدف>.
|
346 |
+
2. النصوص المفقودة كما هي بين علامتي __.
|
347 |
+
3. اختلافات المعنى باستخدام [MEANING] مع الحفاظ على التعليم.
|
348 |
+
|
349 |
+
النص المصدر:
|
350 |
+
{source}
|
351 |
+
|
352 |
+
النص الهدف:
|
353 |
+
{target}`;
|
354 |
+
|
355 |
+
// برومبت لتقسيم النص باستخدام ChatGPT-4o
|
356 |
+
const TEXT_DIVISION_PROMPT = `قم بتقسيم النص التالي إلى أجزاء منطقية للتحليل.
|
357 |
+
يجب أن يكون كل جزء وحدة متماسكة (فقرة، قسم، إلخ) لا تتجاوز 500 كلمة.
|
358 |
+
أعد النص كمصفوفة JSON بالأجزاء. الصيغة: {"segments": ["جزء1", "جزء2", ...]}
|
359 |
+
|
360 |
+
النص للتقسيم:
|
361 |
+
{text}`;
|
362 |
+
|
363 |
+
// برومبت لإيجاد الكلمة الأخيرة المشتركة للتزامن
|
364 |
+
const SYNC_WORD_PROMPT = `قم بتحليل النص التالي وإيجاد آخر كلمة أو جملة قصيرة (لا تزيد عن 3 كلمات) مناسبة ليمكن استخدامها كنقطة تزامن بين الفقرات. اختر كلمة أو جملة تظهر بشكل طبيعي في النص وتكون مناسبة للتقسيم.
|
365 |
+
أعِد فقط الكلمة أو الجملة المحددة دون أي إضافات أخرى.
|
366 |
+
|
367 |
+
النص:
|
368 |
+
{text}`;
|
369 |
+
|
370 |
+
/* =====================================
|
371 |
+
دالة لتقسيم النص باستخدام ChatGPT-4o
|
372 |
+
===================================== */
|
373 |
+
async function divideTextWithChatGPT(text) {
|
374 |
+
try {
|
375 |
+
// إذا كان النص قصيرًا، لا داعي لتقسيمه
|
376 |
+
if (countWords(text) <= 500) {
|
377 |
+
return [text];
|
378 |
+
}
|
379 |
+
|
380 |
+
// تحضير البيانات لـ ChatGPT-4o
|
381 |
+
const prompt = TEXT_DIVISION_PROMPT.replace("{text}", text);
|
382 |
+
const payload = {
|
383 |
+
model: "gpt-4o",
|
384 |
+
messages: [
|
385 |
+
{ role: "system", content: "أنت مساعد متخصص في تقسيم النصوص إلى أجزاء منطقية." },
|
386 |
+
{ role: "user", content: prompt }
|
387 |
+
],
|
388 |
+
temperature: 0.3,
|
389 |
+
max_tokens: 1024
|
390 |
+
};
|
391 |
+
|
392 |
+
// استدعاء API ChatGPT
|
393 |
+
const response = await fetch(CHATGPT_API_URL, {
|
394 |
+
method: 'POST',
|
395 |
+
headers: {
|
396 |
+
'Authorization': 'Bearer ' + CHATGPT_API_KEY,
|
397 |
+
'Content-Type': 'application/json'
|
398 |
+
},
|
399 |
+
body: JSON.stringify(payload)
|
400 |
+
});
|
401 |
+
|
402 |
+
if (!response.ok) {
|
403 |
+
throw new Error('خطأ في API ChatGPT: ' + response.statusText);
|
404 |
+
}
|
405 |
+
|
406 |
+
const data = await response.json();
|
407 |
+
const content = data.choices[0].message.content.trim();
|
408 |
+
|
409 |
+
// محاولة تحليل الاستجابة كـ JSON
|
410 |
+
try {
|
411 |
+
const jsonResponse = JSON.parse(content);
|
412 |
+
if (jsonResponse.segments && Array.isArray(jsonResponse.segments)) {
|
413 |
+
return jsonResponse.segments;
|
414 |
+
}
|
415 |
+
} catch (e) {
|
416 |
+
// إذا تعذر تحليلها كـ JSON، حاول استخراج الأجزاء يدويًا
|
417 |
+
const segments = content.split(/\n{2,}/).filter(seg => seg.trim().length > 0);
|
418 |
+
if (segments.length > 0) {
|
419 |
+
return segments;
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
// إذا فشل كل شيء، قسم النص إلى فقرات
|
424 |
+
return text.split(/\n{2,}/).filter(para => para.trim().length > 0);
|
425 |
+
|
426 |
+
} catch (error) {
|
427 |
+
console.error('خطأ في تقسيم النص باستخدام ChatGPT:', error);
|
428 |
+
// الخطة البديلة: تقسيم حسب الفقرات
|
429 |
+
return text.split(/\n{2,}/).filter(para => para.trim().length > 0);
|
430 |
+
}
|
431 |
+
}
|
432 |
+
|
433 |
+
/* =====================================
|
434 |
+
دالة لإيجاد الكلمة المتزامنة في نهاية كل فقرة
|
435 |
+
===================================== */
|
436 |
+
async function findSyncWord(text) {
|
437 |
+
try {
|
438 |
+
// تحضير البيانات لـ ChatGPT-4o
|
439 |
+
const prompt = SYNC_WORD_PROMPT.replace("{text}", text);
|
440 |
+
const payload = {
|
441 |
+
model: "gpt-4o",
|
442 |
+
messages: [
|
443 |
+
{ role: "system", content: "أنت مساعد متخصص في تحليل النصوص وإيجاد نقاط تزامن مناسبة." },
|
444 |
+
{ role: "user", content: prompt }
|
445 |
+
],
|
446 |
+
temperature: 0.3,
|
447 |
+
max_tokens: 50
|
448 |
+
};
|
449 |
+
|
450 |
+
// استدعاء API ChatGPT
|
451 |
+
const response = await fetch(CHATGPT_API_URL, {
|
452 |
+
method: 'POST',
|
453 |
+
headers: {
|
454 |
+
'Authorization': 'Bearer ' + CHATGPT_API_KEY,
|
455 |
+
'Content-Type': 'application/json'
|
456 |
+
},
|
457 |
+
body: JSON.stringify(payload)
|
458 |
+
});
|
459 |
+
|
460 |
+
if (!response.ok) {
|
461 |
+
throw new Error('خطأ في API ChatGPT: ' + response.statusText);
|
462 |
+
}
|
463 |
+
|
464 |
+
const data = await response.json();
|
465 |
+
const syncWord = data.choices[0].message.content.trim();
|
466 |
+
|
467 |
+
return syncWord;
|
468 |
+
} catch (error) {
|
469 |
+
console.error('خطأ في إيجاد الكلمة المتزامنة:', error);
|
470 |
+
// في حالة الفشل، نعيد كلمة افتراضية
|
471 |
+
return "نهاية الفقرة";
|
472 |
+
}
|
473 |
+
}
|
474 |
+
|
475 |
+
/* =====================================
|
476 |
+
دالة لتحليل الأجزاء باستخدام DeepSeek ودمج النتائج
|
477 |
+
===================================== */
|
478 |
+
async function analyzeTextSegments(sourceSegments, targetSegments) {
|
479 |
+
// التحقق من أن لدينا نفس عدد الأجزاء
|
480 |
+
if (sourceSegments.length !== targetSegments.length) {
|
481 |
+
throw new Error('عدد أجزاء المصدر والهدف غير متطابق');
|
482 |
+
}
|
483 |
+
|
484 |
+
let combinedAnalysis = '';
|
485 |
+
const progressDiv = document.createElement('div');
|
486 |
+
progressDiv.className = "bg-indigo-100 p-4 rounded-xl mb-4";
|
487 |
+
progressDiv.innerHTML = `<div class="flex items-center justify-between">
|
488 |
+
<div class="flex items-center">
|
489 |
+
<div class="animate-spin h-6 w-6 border-4 border-indigo-600 rounded-full border-t-transparent ml-3"></div>
|
490 |
+
<span>جارٍ التحليل...</span>
|
491 |
+
</div>
|
492 |
+
<span id="segmentProgress">0/${sourceSegments.length}</span>
|
493 |
+
</div>`;
|
494 |
+
document.getElementById('errorsList').appendChild(progressDiv);
|
495 |
+
|
496 |
+
// تخزين مقاطع التحليل المنفصلة
|
497 |
+
analysisSegments = [];
|
498 |
+
|
499 |
+
// تحليل كل زوج من الأجزاء
|
500 |
+
for (let i = 0; i < sourceSegments.length; i++) {
|
501 |
+
// تحديث التقدم
|
502 |
+
document.getElementById('segmentProgress').textContent = `${i+1}/${sourceSegments.length}`;
|
503 |
+
|
504 |
+
// بناء البرومبت لهذا الجزء
|
505 |
+
const prompt = ANALYSIS_PROMPT
|
506 |
+
.replace("{source}", sourceSegments[i])
|
507 |
+
.replace("{target}", targetSegments[i]);
|
508 |
+
|
509 |
+
// استدعاء DeepSeek API
|
510 |
+
const payload = {
|
511 |
+
model: "deepseek-reasoner",
|
512 |
+
messages: [
|
513 |
+
{ role: "system", content: "أنت خبير في تحليل النصوص ومقارنتها بدقة عالية." },
|
514 |
+
{ role: "user", content: prompt }
|
515 |
+
],
|
516 |
+
temperature: 0.3,
|
517 |
+
max_tokens: 2048,
|
518 |
+
stream: false
|
519 |
+
};
|
520 |
+
|
521 |
+
const response = await fetch(DEEPSEEK_API_URL, {
|
522 |
+
method: 'POST',
|
523 |
+
headers: {
|
524 |
+
'Authorization': 'Bearer ' + DEEPSEEK_API_KEY,
|
525 |
+
'Content-Type': 'application/json'
|
526 |
+
},
|
527 |
+
body: JSON.stringify(payload)
|
528 |
+
});
|
529 |
+
|
530 |
+
if (!response.ok) {
|
531 |
+
throw new Error('حدث خطأ بالشبكة: ' + response.statusText);
|
532 |
+
}
|
533 |
+
|
534 |
+
const data = await response.json();
|
535 |
+
const segmentAnalysis = data.choices[0].message.content.trim();
|
536 |
+
|
537 |
+
// أضف هذا المقطع إلى المصفوفة
|
538 |
+
analysisSegments.push({
|
539 |
+
source: sourceSegments[i],
|
540 |
+
target: targetSegments[i],
|
541 |
+
analysis: segmentAnalysis
|
542 |
+
});
|
543 |
+
|
544 |
+
// دمج مع التحليل السابق
|
545 |
+
if (i > 0) combinedAnalysis += '\n\n---\n\n';
|
546 |
+
combinedAnalysis += `[الجزء ${i+1}]\n${segmentAnalysis}`;
|
547 |
+
}
|
548 |
+
|
549 |
+
progressDiv.remove();
|
550 |
+
return combinedAnalysis;
|
551 |
+
}
|
552 |
+
|
553 |
+
/* =====================================
|
554 |
+
دالة لعرض التقسيمات كمسودة قابلة للطي
|
555 |
+
===================================== */
|
556 |
+
async function displayDraftSections() {
|
557 |
+
const container = document.getElementById('paragraphDivisionsContainer');
|
558 |
+
container.innerHTML = ''; // مسح المحتوى الحالي
|
559 |
+
|
560 |
+
// إنشاء قسم لكل مقطع تحليل
|
561 |
+
for (let i = 0; i < analysisSegments.length; i++) {
|
562 |
+
const segment = analysisSegments[i];
|
563 |
+
|
564 |
+
// البحث عن كلمة متزامنة في نهاية المقطع
|
565 |
+
const syncWord = await findSyncWord(segment.source);
|
566 |
+
|
567 |
+
// إنشاء عنصر القسم القابل للطي
|
568 |
+
const sectionDiv = document.createElement('div');
|
569 |
+
sectionDiv.className = 'collapsible-section';
|
570 |
+
|
571 |
+
// إنشاء الترويسة
|
572 |
+
const headerDiv = document.createElement('div');
|
573 |
+
headerDiv.className = 'section-header';
|
574 |
+
headerDiv.innerHTML = `
|
575 |
+
<div class="flex items-center">
|
576 |
+
<span class="draft-marker">مسودة</span>
|
577 |
+
<span>القسم ${i+1}: ${truncateText(segment.source, 50)}</span>
|
578 |
+
</div>
|
579 |
+
<i class="fas fa-chevron-down"></i>
|
580 |
+
`;
|
581 |
+
|
582 |
+
// إنشاء محتوى القسم
|
583 |
+
const contentDiv = document.createElement('div');
|
584 |
+
contentDiv.className = 'section-content';
|
585 |
+
|
586 |
+
// تحديد النص المصدر مع تمييز الكلمة المتزامنة في النهاية
|
587 |
+
const sourceWithSync = highlightSyncWord(segment.source, syncWord);
|
588 |
+
// تحديد النص الهدف مع تمييز الكلمة المتزامنة في النهاية إن وجدت
|
589 |
+
const targetWithSync = highlightSyncWord(segment.target, syncWord);
|
590 |
+
|
591 |
+
contentDiv.innerHTML = `
|
592 |
+
<div class="paragraph-section mb-4">
|
593 |
+
<h4 class="font-bold text-gray-700 mb-2">النص المصدر:</h4>
|
594 |
+
<div class="bg-indigo-50 p-3 rounded-lg">${sourceWithSync}</div>
|
595 |
+
</div>
|
596 |
+
<div class="paragraph-section mb-4">
|
597 |
+
<h4 class="font-bold text-gray-700 mb-2">النص الهدف:</h4>
|
598 |
+
<div class="bg-pink-50 p-3 rounded-lg">${targetWithSync}</div>
|
599 |
+
</div>
|
600 |
+
<div class="paragraph-section">
|
601 |
+
<h4 class="font-bold text-gray-700 mb-2">التحليل:</h4>
|
602 |
+
<div class="bg-gray-50 p-3 rounded-lg">${formatAnalysisText(segment.analysis)}</div>
|
603 |
+
</div>
|
604 |
+
`;
|
605 |
+
|
606 |
+
// إضافة الأقسام إلى الحاوية
|
607 |
+
sectionDiv.appendChild(headerDiv);
|
608 |
+
sectionDiv.appendChild(contentDiv);
|
609 |
+
container.appendChild(sectionDiv);
|
610 |
+
|
611 |
+
// إضافة مستمع الحدث للنقر على الترويسة
|
612 |
+
headerDiv.addEventListener('click', function() {
|
613 |
+
contentDiv.classList.toggle('open');
|
614 |
+
const icon = headerDiv.querySelector('i.fas');
|
615 |
+
icon.classList.toggle('fa-chevron-down');
|
616 |
+
icon.classList.toggle('fa-chevron-up');
|
617 |
+
});
|
618 |
+
}
|
619 |
+
}
|
620 |
+
|
621 |
+
/* =====================================
|
622 |
+
دوال مساعدة للتعامل مع النصوص
|
623 |
+
===================================== */
|
624 |
+
// حساب عدد الكلمات في النص
|
625 |
+
function countWords(text) {
|
626 |
+
return text.trim().split(/\s+/).filter(word => word !== "").length;
|
627 |
+
}
|
628 |
+
// هروب أحرف Regex الخاصة
|
629 |
+
function escapeRegExp(string) {
|
630 |
+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
631 |
+
}
|
632 |
+
// تقسيم النص إلى أسطر مع عرض رقم السطر
|
633 |
+
function splitIntoLines(text) {
|
634 |
+
return text.split('\n').map((line, i) => `<div class="line-item"><span class="line-number">${i+1}:</span> <span class="line-text">${line}</span></div>`).join('');
|
635 |
+
}
|
636 |
+
// الحصول على رقم السطر لظهور عبارة معينة
|
637 |
+
function getLineNumber(text, substring) {
|
638 |
+
const index = text.indexOf(substring);
|
639 |
+
if (index === -1) return "غير محدد";
|
640 |
+
return text.substring(0, index).split("\n").length;
|
641 |
+
}
|
642 |
+
// اقتطاع النص إذا كان طوي��ا جدا
|
643 |
+
function truncateText(text, maxLength) {
|
644 |
+
if (text.length <= maxLength) return text;
|
645 |
+
return text.substring(0, maxLength) + '...';
|
646 |
+
}
|
647 |
+
// تنسيق نص التحليل بتمييز الكلمات المهمة
|
648 |
+
function formatAnalysisText(text) {
|
649 |
+
// تمييز الكلمات المهمة مثل "الأرقام" و "المفقودة" و "المعنى"
|
650 |
+
text = text.replace(/الأرقام/g, '<span class="font-bold text-indigo-600">الأرقام</span>');
|
651 |
+
text = text.replace(/المفقودة/g, '<span class="font-bold text-pink-600">المفقودة</span>');
|
652 |
+
text = text.replace(/المعنى/g, '<span class="font-bold text-green-600">المعنى</span>');
|
653 |
+
|
654 |
+
// تحديد علامات التمييز
|
655 |
+
text = text.replace(/<([^<>]+)>/g, '<span class="highlight-number"><$1></span>');
|
656 |
+
text = text.replace(/__(.*?)__/g, '<span class="highlight-missing">__$1__</span>');
|
657 |
+
text = text.replace(/\[MEANING\](.*?)\[\/MEANING\]/g, '<span class="highlight-meaning">$1</span>');
|
658 |
+
|
659 |
+
return text;
|
660 |
+
}
|
661 |
+
// تمييز الكلمة المتزامنة في النص
|
662 |
+
function highlightSyncWord(text, syncWord) {
|
663 |
+
if (!syncWord || !text.includes(syncWord)) return text;
|
664 |
+
|
665 |
+
// تجنب تمييز الكلمة إذا كانت جزءًا من كلمة أكبر
|
666 |
+
const regex = new RegExp(`(\\b${escapeRegExp(syncWord)}\\b)`, 'g');
|
667 |
+
// جعل الظهور الأخير للكلمة ممَيز
|
668 |
+
const lastIndex = text.lastIndexOf(syncWord);
|
669 |
+
if (lastIndex !== -1) {
|
670 |
+
const beforeSync = text.substring(0, lastIndex);
|
671 |
+
const afterSync = text.substring(lastIndex + syncWord.length);
|
672 |
+
return beforeSync + '<span class="sync-word">' + syncWord + '</span>' + afterSync;
|
673 |
+
}
|
674 |
+
|
675 |
+
return text;
|
676 |
+
}
|
677 |
+
|
678 |
+
/* =====================================
|
679 |
+
دوال التمييز (Highlighting) للنتائج
|
680 |
+
===================================== */
|
681 |
+
// دالة محسنة لتحديد النصوص التي بها مشاكل فقط على الأسطر المتأثرة
|
682 |
+
function applyHighlights(originalText, analysisOutput) {
|
683 |
+
// استخراج النصوص التي بها مشاكل من التحليل
|
684 |
+
const numberMatches = Array.from(analysisOutput.matchAll(/<([^<>]+)>/g)).map(m => m[1].trim());
|
685 |
+
const missingMatches = Array.from(analysisOutput.matchAll(/__(.*?)__/g)).map(m => m[1].trim());
|
686 |
+
const meaningMatches = Array.from(analysisOutput.matchAll(/\[MEANING\](.*?)\[\/MEANING\]/g)).map(m => m[1].trim());
|
687 |
+
|
688 |
+
// تقسيم النص الأصلي إلى أسطر
|
689 |
+
const lines = originalText.split('\n');
|
690 |
+
|
691 |
+
// معالجة كل سطر على حدة وتطبيق التحديد إذا وُجدت مشكلة
|
692 |
+
const highlightedLines = lines.map(line => {
|
693 |
+
// تحديد اختلافات الأرقام
|
694 |
+
numberMatches.forEach(phrase => {
|
695 |
+
if (line.includes(phrase)) {
|
696 |
+
const regex = new RegExp(escapeRegExp(phrase), 'g');
|
697 |
+
line = line.replace(regex, `<span class="highlight-number">${phrase}</span>`);
|
698 |
+
}
|
699 |
+
});
|
700 |
+
// تحديد النصوص المفقودة
|
701 |
+
missingMatches.forEach(phrase => {
|
702 |
+
if (line.includes(phrase)) {
|
703 |
+
const regex = new RegExp(escapeRegExp(phrase), 'g');
|
704 |
+
line = line.replace(regex, `<span class="highlight-missing">__${phrase}__</span>`);
|
705 |
+
}
|
706 |
+
});
|
707 |
+
// تحديد اختلافات المعنى
|
708 |
+
meaningMatches.forEach(phrase => {
|
709 |
+
if (line.includes(phrase)) {
|
710 |
+
const regex = new RegExp(escapeRegExp(phrase), 'g');
|
711 |
+
line = line.replace(regex, `<span class="highlight-meaning">${phrase}</span>`);
|
712 |
+
}
|
713 |
+
});
|
714 |
+
return line;
|
715 |
+
});
|
716 |
+
|
717 |
+
return highlightedLines.join('\n');
|
718 |
+
}
|
719 |
+
|
720 |
+
/* =====================================
|
721 |
+
دالة توليد الشرح التفصيلي Organized Explanation
|
722 |
+
يتم تقسيم الشرح إلى خطوات منظمة
|
723 |
+
===================================== */
|
724 |
+
function generateExplanation(sourceText, analysisOutput) {
|
725 |
+
let steps = [];
|
726 |
+
// الخطوة 1: النصوص المفقودة
|
727 |
+
const missingRegex = /__(.*?)__/g;
|
728 |
+
let match;
|
729 |
+
while ((match = missingRegex.exec(analysisOutput)) !== null) {
|
730 |
+
const phrase = match[1].trim();
|
731 |
+
if (phrase) {
|
732 |
+
const lineNum = getLineNumber(sourceText, phrase);
|
733 |
+
steps.push(`<li><strong>الخطوة 1:</strong> في السطر ${lineNum}، الجزء "<span class="highlight-missing">__${phrase}__</span>" من النص المصدر مفقود في النص الهدف. تأكد من إضافته لتحسين الدقة.</li>`);
|
734 |
+
}
|
735 |
+
}
|
736 |
+
// الخطوة 2: اختلافات الأرقام
|
737 |
+
const numberRegex = /<([^<>]+)>/g;
|
738 |
+
while ((match = numberRegex.exec(analysisOutput)) !== null) {
|
739 |
+
const phrase = match[1].trim();
|
740 |
+
if (phrase) {
|
741 |
+
const lineNum = getLineNumber(sourceText, phrase);
|
742 |
+
steps.push(`<li><strong>الخطوة 2:</strong> في السطر ${lineNum}، الرقم "<span class="highlight-number">${phrase}</span>" في المصدر لا يتطابق مع الرقم في الهدف. يرجى المراجعة.</li>`);
|
743 |
+
}
|
744 |
+
}
|
745 |
+
// الخطوة 3: اختلافات المعنى
|
746 |
+
const meaningRegex = /\[MEANING\](.*?)\[\/MEANING\]/g;
|
747 |
+
while ((match = meaningRegex.exec(analysisOutput)) !== null) {
|
748 |
+
const phrase = match[1].trim();
|
749 |
+
if (phrase) {
|
750 |
+
const lineNum = getLineNumber(sourceText, phrase);
|
751 |
+
steps.push(`<li><strong>الخطوة 3:</strong> في السطر ${lineNum}، تم العثور على اختلاف في المعنى مع التعبير "<span class="highlight-meaning">${phrase}</span>". تحقق من الدقة.</li>`);
|
752 |
+
}
|
753 |
+
}
|
754 |
+
// إذا لم يكن هناك اختلافات
|
755 |
+
if (steps.length === 0) {
|
756 |
+
return `<p>النصوص متطابقة تماماً ولا توجد فروقات تحتاج للتنبيه.</p>`;
|
757 |
+
}
|
758 |
+
return `<ol class="list-decimal ml-6 space-y-2">${steps.join('')}</ol>`;
|
759 |
+
}
|
760 |
+
|
761 |
+
/* =====================================
|
762 |
+
دالة معالجة الملفات (PDF و DOCX)
|
763 |
+
===================================== */
|
764 |
+
async function processFile(file) {
|
765 |
+
let text = "";
|
766 |
+
if (file.type === 'application/pdf') {
|
767 |
+
const form = new FormData();
|
768 |
+
form.append('image', file);
|
769 |
+
const response = await fetch('https://demo.api4ai.cloud/ocr/v1/results', {
|
770 |
+
method: 'POST',
|
771 |
+
body: form,
|
772 |
+
headers: { 'A4A-CLIENT-APP-ID': 'sample' }
|
773 |
+
});
|
774 |
+
const data = await response.json();
|
775 |
+
text = data.results[0].entities[0].objects[0].entities[0].text;
|
776 |
+
} else if (file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
|
777 |
+
const arrayBuffer = await file.arrayBuffer();
|
778 |
+
const result = await mammoth.extractRawText({ arrayBuffer });
|
779 |
+
text = result.value;
|
780 |
+
} else {
|
781 |
+
throw new Error('نوع الملف غير مدعوم');
|
782 |
+
}
|
783 |
+
return text;
|
784 |
+
}
|
785 |
+
|
786 |
+
/* =====================================
|
787 |
+
دوال رفع الملفات وإدخال النصوص
|
788 |
+
===================================== */
|
789 |
+
// رفع ملف السورس
|
790 |
+
document.getElementById('sourceFile')?.addEventListener('change', async (event) => {
|
791 |
+
const file = event.target.files[0];
|
792 |
+
if (!file) return;
|
793 |
+
document.getElementById('processStatus').classList.remove('hidden');
|
794 |
+
try {
|
795 |
+
const text = await processFile(file);
|
796 |
+
document.getElementById('sourceText').value = text;
|
797 |
+
} catch (error) {
|
798 |
+
console.error('Error processing source file:', error);
|
799 |
+
addError('خطأ في معالجة ملف السورس');
|
800 |
+
} finally {
|
801 |
+
document.getElementById('processStatus').classList.add('hidden');
|
802 |
+
}
|
803 |
+
});
|
804 |
+
// رفع ملف التارجت
|
805 |
+
document.getElementById('targetFile')?.addEventListener('change', async (event) => {
|
806 |
+
const file = event.target.files[0];
|
807 |
+
if (!file) return;
|
808 |
+
document.getElementById('processStatus').classList.remove('hidden');
|
809 |
+
try {
|
810 |
+
const text = await processFile(file);
|
811 |
+
document.getElementById('targetText').value = text;
|
812 |
+
} catch (error) {
|
813 |
+
console.error('Error processing target file:', error);
|
814 |
+
addError('خطأ في معالجة ملف التارجت');
|
815 |
+
} finally {
|
816 |
+
document.getElementById('processStatus').classList.add('hidden');
|
817 |
+
}
|
818 |
+
});
|
819 |
+
// رفع ملف المصادر الإضافية
|
820 |
+
document.getElementById('sourceExtraFile')?.addEventListener('change', async (event) => {
|
821 |
+
const file = event.target.files[0];
|
822 |
+
if (!file) return;
|
823 |
+
document.getElementById('processStatus').classList.remove('hidden');
|
824 |
+
try {
|
825 |
+
const text = await processFile(file);
|
826 |
+
document.getElementById('sourceExtraText').value = text;
|
827 |
+
} catch (error) {
|
828 |
+
console.error('Error processing extra source file:', error);
|
829 |
+
addError('خطأ في معالجة ملف المصدر الإضافي');
|
830 |
+
} finally {
|
831 |
+
document.getElementById('processStatus').classList.add('hidden');
|
832 |
+
}
|
833 |
+
});
|
834 |
+
|
835 |
+
/* =====================================
|
836 |
+
دالة عرض الأخطاء والرسائل
|
837 |
+
===================================== */
|
838 |
+
function addError(message, type = 'error') {
|
839 |
+
const errorsList = document.getElementById('errorsList');
|
840 |
+
if (!errorsList) return;
|
841 |
+
const errorDiv = document.createElement('div');
|
842 |
+
errorDiv.className = `p-4 rounded-xl ${type === 'error' ? 'bg-red-50 text-red-700' : 'bg-yellow-50 text-yellow-700'}`;
|
843 |
+
errorDiv.innerHTML = `<div class="flex items-center">
|
844 |
+
<i class="fas fa-${type === 'error' ? 'exclamation-circle' : 'info-circle'} ml-2 text-${type === 'error' ? 'red' : 'yellow'}-500"></i>
|
845 |
+
<span>${message}</span>
|
846 |
+
</div>`;
|
847 |
+
errorsList.appendChild(errorDiv);
|
848 |
+
}
|
849 |
+
|
850 |
+
/* =====================================
|
851 |
+
معالجة عملية التحليل عند الضغط على الزر
|
852 |
+
===================================== */
|
853 |
+
document.getElementById('submitBtn').addEventListener('click', async () => {
|
854 |
+
const sourceText = document.getElementById('sourceText').value;
|
855 |
+
const targetText = document.getElementById('targetText').value;
|
856 |
+
// مسح الرسائل السابقة وإظهار النتائج
|
857 |
+
document.getElementById('errorsList').innerHTML = '';
|
858 |
+
document.getElementById('resultSection').classList.remove('hidden');
|
859 |
+
document.getElementById('explanationBox').classList.remove('hidden');
|
860 |
+
|
861 |
+
if (!sourceText || !targetText) {
|
862 |
+
addError('يرجى إدخال كلا النصين المصدر والهدف');
|
863 |
+
return;
|
864 |
+
}
|
865 |
+
|
866 |
+
// مقارنة عدد الكلمات وتنبيه إن وجد اختلاف
|
867 |
+
const sourceWordCount = countWords(sourceText);
|
868 |
+
const targetWordCount = countWords(targetText);
|
869 |
+
if (sourceWordCount !== targetWordCount) {
|
870 |
+
addError(`عدد كلمات النص المصدر (${sourceWordCount}) يختلف عن النص الهدف (${targetWordCount})`, 'warning');
|
871 |
+
}
|
872 |
+
|
873 |
+
try {
|
874 |
+
// عرض مؤشر التقدم الأولي
|
875 |
+
const initialProgressDiv = document.createElement('div');
|
876 |
+
initialProgressDiv.className = "bg-indigo-100 p-4 rounded-xl mb-4";
|
877 |
+
initialProgressDiv.innerHTML = `<div class="flex items-center">
|
878 |
+
<div class="animate-spin h-6 w-6 border-4 border-indigo-600 rounded-full border-t-transparent ml-3"></div>
|
879 |
+
<span>جارٍ تقسيم النصوص...</span>
|
880 |
+
</div>`;
|
881 |
+
document.getElementById('errorsList').appendChild(initialProgressDiv);
|
882 |
+
|
883 |
+
// الخطوة 1: تقسيم النصوص باستخدام ChatGPT-4o
|
884 |
+
const sourceSegments = await divideTextWithChatGPT(sourceText);
|
885 |
+
const targetSegments = await divideTextWithChatGPT(targetText);
|
886 |
+
|
887 |
+
initialProgressDiv.remove();
|
888 |
+
|
889 |
+
// الخطوة 2: تحليل الأجزاء باستخدام DeepSeek
|
890 |
+
const analysisOutput = await analyzeTextSegments(sourceSegments, targetSegments);
|
891 |
+
fullAnalysisText = analysisOutput; // حفظ التحليل الكامل
|
892 |
+
|
893 |
+
// الخطوة 3: إنشاء تقسيمات المسودة
|
894 |
+
await displayDraftSections();
|
895 |
+
|
896 |
+
// معالجة النتائج كما كان من قبل
|
897 |
+
if (analysisOutput.includes('[MATCH]')) {
|
898 |
+
const checkDiv = document.createElement('div');
|
899 |
+
checkDiv.className = "p-4 rounded-xl bg-green-50 text-green-700 flex items-center";
|
900 |
+
checkDiv.innerHTML = `<i class="fas fa-check-circle ml-2 text-lg"></i> <span class="text-lg">النصوص متطابقة تماماً</span>`;
|
901 |
+
document.getElementById('errorsList').appendChild(checkDiv);
|
902 |
+
document.getElementById('sourceTextReview').innerHTML = splitIntoLines(sourceText);
|
903 |
+
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetText);
|
904 |
+
document.getElementById('explanationText').innerHTML = `<p>النصوص متطابقة ولا يوجد اختلاف يجب الإشارة إليه.</p>`;
|
905 |
+
} else {
|
906 |
+
// تطبيق التحديد على النصوص
|
907 |
+
const sourceHighlighted = applyHighlights(sourceText, analysisOutput);
|
908 |
+
const targetHighlighted = applyHighlights(targetText, analysisOutput);
|
909 |
+
document.getElementById('sourceTextReview').innerHTML = splitIntoLines(sourceHighlighted);
|
910 |
+
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetHighlighted);
|
911 |
+
// توليد شرح منظم على شكل خطوات
|
912 |
+
const explanationHTML = generateExplanation(sourceText, analysisOutput);
|
913 |
+
document.getElementById('explanationText').innerHTML = explanationHTML;
|
914 |
+
|
915 |
+
// عرض ملخص الاختلافات (اختياري)
|
916 |
+
const numDiffCount = (analysisOutput.match(/<([^<>]+)>/g) || []).length;
|
917 |
+
const missingDiffCount = (analysisOutput.match(/__(.*?)__/g) || []).length;
|
918 |
+
const meaningDiffCount = (analysisOutput.match(/\[MEANING\](.*?)\[\/MEANING\]/g) || []).length;
|
919 |
+
if (numDiffCount > 0 || missingDiffCount > 0 || meaningDiffCount > 0) {
|
920 |
+
const summaryDiv = document.createElement('div');
|
921 |
+
summaryDiv.className = "p-4 rounded-xl bg-yellow-50 text-gray-800";
|
922 |
+
let summaryText = '<div class="font-bold mb-2">ملخص الاختلافات:</div><ul class="list-disc mr-6 space-y-1">';
|
923 |
+
if (numDiffCount > 0) summaryText += `<li>اختلاف في الأرقام: ${numDiffCount}</li>`;
|
924 |
+
if (missingDiffCount > 0) summaryText += `<li>النصوص المفقودة: ${missingDiffCount}</li>`;
|
925 |
+
if (meaningDiffCount > 0) summaryText += `<li>اختلاف في المعنى: ${meaningDiffCount}</li>`;
|
926 |
+
summaryText += '</ul>';
|
927 |
+
summaryDiv.innerHTML = summaryText;
|
928 |
+
document.getElementById('errorsList').appendChild(summaryDiv);
|
929 |
+
}
|
930 |
+
}
|
931 |
+
} catch (error) {
|
932 |
+
document.getElementById('errorsList').innerHTML = '';
|
933 |
+
addError(`خطأ في التحليل: ${error.message}`);
|
934 |
+
}
|
935 |
+
});
|
936 |
+
|
937 |
+
// زر تبديل عرض/إخفاء المسودة (التحليل النصي الكامل)
|
938 |
+
document.getElementById('toggleDraftBtn').addEventListener('click', function() {
|
939 |
+
const draftSection = document.getElementById('fullTextDraftSection');
|
940 |
+
if (draftSection.classList.contains('hidden')) {
|
941 |
+
draftSection.classList.remove('hidden');
|
942 |
+
} else {
|
943 |
+
draftSection.classList.add('hidden');
|
944 |
+
}
|
945 |
+
});
|
946 |
+
|
947 |
+
/* =====================================
|
948 |
+
دوال إنشاء وتنزيل التقرير
|
949 |
+
===================================== */
|
950 |
+
// دالة لجمع بيانات التقرير
|
951 |
+
function getReportData() {
|
952 |
+
const sourceText = document.getElementById('sourceText').value;
|
953 |
+
const targetText = document.getElementById('targetText').value;
|
954 |
+
const terminologyUsed = document.getElementById('terminologyCheck').checked ? "نعم" : "لا";
|
955 |
+
return {
|
956 |
+
sourceText,
|
957 |
+
targetText,
|
958 |
+
fullAnalysisText,
|
959 |
+
terminologyUsed
|
960 |
+
};
|
961 |
+
}
|
962 |
+
|
963 |
+
// تنزيل التقرير بصيغة CSV (Excel)
|
964 |
+
document.getElementById('downloadExcelBtn').addEventListener('click', () => {
|
965 |
+
const data = getReportData();
|
966 |
+
let csvContent = "data:text/csv;charset=utf-8,";
|
967 |
+
csvContent += "الحقل,القيمة\n";
|
968 |
+
csvContent += `النص المصدر,"${data.sourceText.replace(/"/g, '""')}"\n`;
|
969 |
+
csvContent += `النص الهدف,"${data.targetText.replace(/"/g, '""')}"\n`;
|
970 |
+
csvContent += `تحليل النصوص,"${data.fullAnalysisText.replace(/"/g, '""')}"\n`;
|
971 |
+
csvContent += `قاعدة المصطلحات المستخدمة,${data.terminologyUsed}\n`;
|
972 |
+
|
973 |
+
const encodedUri = encodeURI(csvContent);
|
974 |
+
const link = document.createElement("a");
|
975 |
+
link.setAttribute("href", encodedUri);
|
976 |
+
link.setAttribute("download", "تقرير_التحليل.csv");
|
977 |
+
document.body.appendChild(link);
|
978 |
+
link.click();
|
979 |
+
document.body.removeChild(link);
|
980 |
+
});
|
981 |
+
|
982 |
+
// تنزيل التقرير بصيغة Word (ملف HTML مع امتداد .doc)
|
983 |
+
document.getElementById('downloadWordBtn').addEventListener('click', () => {
|
984 |
+
const data = getReportData();
|
985 |
+
const reportHTML = `
|
986 |
+
<html>
|
987 |
+
<head>
|
988 |
+
<meta charset="UTF-8">
|
989 |
+
<title>تقرير التحليل</title>
|
990 |
+
<style>
|
991 |
+
body { font-family: Arial, sans-serif; direction: rtl; }
|
992 |
+
h1 { text-align: center; }
|
993 |
+
pre { white-space: pre-wrap; word-wrap: break-word; background: #f4f4f4; padding: 10px; }
|
994 |
+
</style>
|
995 |
+
</head>
|
996 |
+
<body>
|
997 |
+
<h1>تقرير التحليل</h1>
|
998 |
+
<h2>النص المصدر</h2>
|
999 |
+
<pre>${data.sourceText}</pre>
|
1000 |
+
<h2>النص الهدف</h2>
|
1001 |
+
<pre>${data.targetText}</pre>
|
1002 |
+
<h2>تحليل النصوص</h2>
|
1003 |
+
<pre>${data.fullAnalysisText}</pre>
|
1004 |
+
<h2>قاعدة المصطلحات المستخدمة</h2>
|
1005 |
+
<p>${data.terminologyUsed}</p>
|
1006 |
+
</body>
|
1007 |
+
</html>`;
|
1008 |
+
const blob = new Blob([reportHTML], { type: 'application/msword' });
|
1009 |
+
const url = URL.createObjectURL(blob);
|
1010 |
+
const link = document.createElement('a');
|
1011 |
+
link.href = url;
|
1012 |
+
link.download = 'تقرير_التحليل.doc';
|
1013 |
+
document.body.appendChild(link);
|
1014 |
+
link.click();
|
1015 |
+
document.body.removeChild(link);
|
1016 |
+
URL.revokeObjectURL(url);
|
1017 |
+
});
|
1018 |
+
</script>
|
1019 |
+
</body>
|
1020 |
+
</html>
|