joermd commited on
Commit
e75e1b2
·
verified ·
1 Parent(s): 89b3f72

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +24 -47
index.html CHANGED
@@ -36,20 +36,20 @@
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: #FECACA; /* أحمر للنصوص الناقصة */
46
  color: #B91C1C;
47
  padding: 0 4px;
48
  border-radius: 3px;
49
  font-style: italic;
50
  }
51
  .highlight-extra {
52
- background-color: #D1FAE5; /* أخضر للنصوص الزائدة */
53
  color: #065F46;
54
  padding: 0 4px;
55
  border-radius: 3px;
@@ -62,7 +62,7 @@
62
  font-weight: bold;
63
  }
64
  .highlight-doubt {
65
- background-color: #DBEAFE; /* أزرق لعلامات الشك */
66
  color: #1E3A8A;
67
  padding: 0 4px;
68
  border-radius: 3px;
@@ -85,7 +85,7 @@
85
  .line-text { display: inline-block; }
86
 
87
  /* ================================
88
- تحسين تصميم البطاقات والأيقونات
89
  ================================= */
90
  .card {
91
  background-color: #fff;
@@ -229,7 +229,7 @@
229
  <div id="explanationText" class="text-lg text-gray-700"></div>
230
  </div>
231
 
232
- <!-- قسم الكلمات المفقودة -->
233
  <div id="missingWordsSection" class="card hidden">
234
  <h2 class="text-2xl font-bold text-gray-800 border-b pb-3 mb-6">
235
  <i class="fas fa-exclamation-triangle icon text-red-500"></i> الكلمات المفقودة
@@ -246,7 +246,7 @@
246
  (function() {
247
  "use strict";
248
 
249
- // تنبيه: يجب عدم تضمين مفتاح API في الكود العام؛ يُفضل تخزينه على الخادم واستخدام واجهة وسيطة
250
  const API_URL = 'https://api.deepseek.com/chat/completions';
251
  const API_KEY = 'sk-15606736ed9e4aea8b7cc11a195d2b01';
252
  const ANALYSIS_PROMPT = `أنت خبير لغوي وتقني متخصص في مراجعة الترجمة التقنية وتحليل النصوص بدقة. مهمتك مقارنة النص المصدر والنص الهدف واستخراج الاختلافات مع تحسين التظليل والتعليم.
@@ -410,45 +410,22 @@
410
  return `<ol class="list-decimal ml-6 space-y-2">${steps.join('')}</ol>`;
411
  };
412
 
413
- /* ===============================
414
- دالة لاكتشاف الكلمات المفقودة باستخدام خوارزمية LCS
415
- =============================== */
 
 
416
  const detectMissingWords = (source, target) => {
417
- const sourceWords = source.split(/\s+/);
418
- const targetWords = target.split(/\s+/);
419
- const m = sourceWords.length, n = targetWords.length;
420
- const dp = Array(m + 1).fill(null).map(() => Array(n + 1).fill(0));
421
- for (let i = 1; i <= m; i++) {
422
- for (let j = 1; j <= n; j++) {
423
- if (sourceWords[i - 1] === targetWords[j - 1]) {
424
- dp[i][j] = dp[i - 1][j - 1] + 1;
425
- } else {
426
- dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
427
- }
428
- }
429
- }
430
- let i = m, j = n;
431
- const lcs = [];
432
- while (i > 0 && j > 0) {
433
- if (sourceWords[i - 1] === targetWords[j - 1]) {
434
- lcs.unshift(sourceWords[i - 1]);
435
- i--; j--;
436
- } else if (dp[i - 1][j] > dp[i][j - 1]) {
437
- i--;
438
- } else {
439
- j--;
440
- }
441
- }
442
- const missingWords = [];
443
- let lcsIndex = 0;
444
- for (let k = 0; k < sourceWords.length; k++) {
445
- if (lcsIndex < lcs.length && sourceWords[k] === lcs[lcsIndex]) {
446
- lcsIndex++;
447
- } else {
448
- missingWords.push(sourceWords[k]);
449
- }
450
- }
451
- return missingWords;
452
  };
453
 
454
  /* ===============================
@@ -500,7 +477,7 @@
500
  });
501
  };
502
 
503
- // التعامل مع رفع ملفات المصدر، الهدف والمصادر الإضافية
504
  processFileInput('sourceFile', 'sourceText', 'خطأ في معالجة ملف المصدر');
505
  processFileInput('targetFile', 'targetText', 'خطأ في معالجة ملف الهدف');
506
  processFileInput('sourceExtraFile', 'sourceExtraText', 'خطأ في معالجة ملف المصدر الإضافي');
@@ -598,7 +575,7 @@
598
  document.getElementById('explanationText').innerHTML = explanationHTML;
599
  }
600
 
601
- // الكشف عن الكلمات المفقودة باستخدام الدالة الجديدة
602
  const missingWords = detectMissingWords(sourceText, targetText);
603
  if (missingWords.length > 0) {
604
  const missingWordsSection = document.getElementById('missingWordsSection');
 
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: #FECACA;
46
  color: #B91C1C;
47
  padding: 0 4px;
48
  border-radius: 3px;
49
  font-style: italic;
50
  }
51
  .highlight-extra {
52
+ background-color: #D1FAE5;
53
  color: #065F46;
54
  padding: 0 4px;
55
  border-radius: 3px;
 
62
  font-weight: bold;
63
  }
64
  .highlight-doubt {
65
+ background-color: #DBEAFE;
66
  color: #1E3A8A;
67
  padding: 0 4px;
68
  border-radius: 3px;
 
85
  .line-text { display: inline-block; }
86
 
87
  /* ================================
88
+ تصميم البطاقات والأيقونات
89
  ================================= */
90
  .card {
91
  background-color: #fff;
 
229
  <div id="explanationText" class="text-lg text-gray-700"></div>
230
  </div>
231
 
232
+ <!-- قسم الكلمات المفقودة (الكلمات التي لم تُترجم) -->
233
  <div id="missingWordsSection" class="card hidden">
234
  <h2 class="text-2xl font-bold text-gray-800 border-b pb-3 mb-6">
235
  <i class="fas fa-exclamation-triangle icon text-red-500"></i> الكلمات المفقودة
 
246
  (function() {
247
  "use strict";
248
 
249
+ // تنبيه: يُفضل عدم تضمين مفتاح API في الكود العام بل تخزينه على الخادم
250
  const API_URL = 'https://api.deepseek.com/chat/completions';
251
  const API_KEY = 'sk-15606736ed9e4aea8b7cc11a195d2b01';
252
  const ANALYSIS_PROMPT = `أنت خبير لغوي وتقني متخصص في مراجعة الترجمة التقنية وتحليل النصوص بدقة. مهمتك مقارنة النص المصدر والنص الهدف واستخراج الاختلافات مع تحسين التظليل والتعليم.
 
410
  return `<ol class="list-decimal ml-6 space-y-2">${steps.join('')}</ol>`;
411
  };
412
 
413
+ /* =======================================
414
+ دالة اكتشاف الكلمات المفقودة (غير المُترجمة)
415
+ يتم التطبيع (إزالة علامات الترقيم وتحويل الأحرف لحروف صغيرة)
416
+ ثم مقارنة كلمات المصدر مع كلمات الهدف
417
+ ======================================= */
418
  const detectMissingWords = (source, target) => {
419
+ // دالة لتطبيع النص (إزالة علامات الترقيم وتحويل النص لحروف صغيرة)
420
+ const normalize = text =>
421
+ text.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()؟،؛"']/g, '').toLowerCase();
422
+ const sourceTokens = normalize(source).split(/\s+/).filter(word => word);
423
+ const targetTokens = normalize(target).split(/\s+/).filter(word => word);
424
+ const targetSet = new Set(targetTokens);
425
+ // الكلمات المفقودة هي التي تظهر في المصدر وغير موجودة في الهدف
426
+ const missing = sourceTokens.filter(word => !targetSet.has(word));
427
+ // إزالة التكرارات إن وُجدت
428
+ return [...new Set(missing)];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  };
430
 
431
  /* ===============================
 
477
  });
478
  };
479
 
480
+ // رفع ملفات المصدر، الهدف والمصادر الإضافية
481
  processFileInput('sourceFile', 'sourceText', 'خطأ في معالجة ملف المصدر');
482
  processFileInput('targetFile', 'targetText', 'خطأ في معالجة ملف الهدف');
483
  processFileInput('sourceExtraFile', 'sourceExtraText', 'خطأ في معالجة ملف المصدر الإضافي');
 
575
  document.getElementById('explanationText').innerHTML = explanationHTML;
576
  }
577
 
578
+ // اكتشاف الكلمات المفقودة التي لم تُترجم من المصدر (تظهر في المصدر وغير موجودة في الهدف)
579
  const missingWords = detectMissingWords(sourceText, targetText);
580
  if (missingWords.length > 0) {
581
  const missingWordsSection = document.getElementById('missingWordsSection');