Update index.html
Browse files- index.html +55 -68
index.html
CHANGED
@@ -49,13 +49,6 @@
|
|
49 |
border-radius: 3px;
|
50 |
font-weight: bold;
|
51 |
}
|
52 |
-
.highlight-meaning {
|
53 |
-
background-color: #60a5fa; /* أزرق */
|
54 |
-
color: #fff;
|
55 |
-
padding: 0 4px;
|
56 |
-
border-radius: 3px;
|
57 |
-
font-weight: bold;
|
58 |
-
}
|
59 |
|
60 |
/* -------------------------------
|
61 |
تنسيق الفقرات وترقيمها
|
@@ -86,7 +79,14 @@
|
|
86 |
box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2);
|
87 |
transform: translateY(-3px);
|
88 |
}
|
89 |
-
.icon { margin-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
</style>
|
91 |
</head>
|
92 |
<body class="bg-gradient-to-br from-gray-100 via-blue-100 to-indigo-100 min-h-screen">
|
@@ -95,10 +95,11 @@
|
|
95 |
<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">
|
96 |
<div class="max-w-6xl mx-auto px-4 text-center">
|
97 |
<h1 class="text-5xl font-bold mb-4 animate-scale">
|
98 |
-
|
|
|
99 |
</h1>
|
100 |
<p class="text-xl opacity-90">
|
101 |
-
|
102 |
</p>
|
103 |
</div>
|
104 |
</header>
|
@@ -113,25 +114,25 @@
|
|
113 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
114 |
<!-- ملف المصدر -->
|
115 |
<div class="group border-2 border-dashed border-indigo-300 rounded-xl p-8 text-center bg-indigo-50 hover:bg-indigo-100 transition-colors duration-300">
|
116 |
-
<label class="cursor-pointer block">
|
117 |
<input type="file" id="sourceFile" accept=".docx,.pdf" class="hidden">
|
118 |
-
<i class="fas fa-upload text-5xl text-indigo-500 mb-4"></i>
|
119 |
<span class="text-lg text-indigo-600 group-hover:text-indigo-700">ملف المصدر</span>
|
|
|
120 |
</label>
|
121 |
</div>
|
122 |
<!-- ملف الهدف -->
|
123 |
<div class="group border-2 border-dashed border-pink-300 rounded-xl p-8 text-center bg-pink-50 hover:bg-pink-100 transition-colors duration-300">
|
124 |
-
<label class="cursor-pointer block">
|
125 |
<input type="file" id="targetFile" accept=".docx,.pdf" class="hidden">
|
126 |
-
<i class="fas fa-download text-5xl text-pink-500 mb-4"></i>
|
127 |
<span class="text-lg text-pink-600 group-hover:text-pink-700">ملف الهدف</span>
|
|
|
128 |
</label>
|
129 |
</div>
|
130 |
</div>
|
131 |
<div id="processStatus" class="hidden mt-4">
|
132 |
-
<div class="flex items-center justify-
|
133 |
-
<div class="animate-spin h-8 w-8 border-4 border-indigo-600 rounded-full border-t-transparent"></div>
|
134 |
<span class="text-lg text-indigo-700">جارٍ معالجة الملف...</span>
|
|
|
135 |
</div>
|
136 |
</div>
|
137 |
</div>
|
@@ -164,10 +165,10 @@
|
|
164 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
165 |
<!-- رفع ملف المصادر الإضافية -->
|
166 |
<div class="group border-2 border-dashed border-green-300 rounded-xl p-8 text-center bg-green-50 hover:bg-green-100 transition-colors duration-300">
|
167 |
-
<label class="cursor-pointer block">
|
168 |
<input type="file" id="sourceExtraFile" accept=".docx,.pdf" class="hidden">
|
169 |
-
<i class="fas fa-upload text-5xl text-green-500 mb-4"></i>
|
170 |
<span class="text-lg text-green-600 group-hover:text-green-700">تحميل ملف المصدر</span>
|
|
|
171 |
</label>
|
172 |
</div>
|
173 |
<!-- إدخال المصادر يدويًا -->
|
@@ -183,7 +184,8 @@
|
|
183 |
<!-- زر التحليل والمراجعة -->
|
184 |
<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 pulse-animation">
|
185 |
<div class="flex items-center justify-center">
|
186 |
-
<
|
|
|
187 |
</div>
|
188 |
</button>
|
189 |
|
@@ -202,7 +204,7 @@
|
|
202 |
</div>
|
203 |
<div>
|
204 |
<h4 class="text-lg font-bold text-gray-700 mb-3">
|
205 |
-
<i class="fas fa-file-alt icon text-pink-600"></i> النص الهدف (
|
206 |
</h4>
|
207 |
<div id="targetTextReview" class="bg-gray-50 rounded-xl p-6 min-h-[200px] border-2 border-gray-200 text-comparison"></div>
|
208 |
</div>
|
@@ -228,34 +230,34 @@
|
|
228 |
|
229 |
/* تحسين البرومت:
|
230 |
- مهمتك: مقارنة النص المصدر والنص الهدف واستخراج الاختلافات التالية:
|
231 |
-
1.
|
232 |
-
2.
|
233 |
-
3. اختلاف المعنى: في حال وجود اختلاف واضح في معنى النص.
|
234 |
- يُرجى تمييز:
|
235 |
• النصوص المفقودة بوضعها بين علامتي __ و __.
|
236 |
• الأرقام والتواريخ بوضعها بين علامتي < و >.
|
237 |
-
|
238 |
-
-
|
|
|
239 |
*/
|
240 |
const API_URL = 'https://api.deepseek.com/chat/completions';
|
241 |
const API_KEY = 'sk-15606736ed9e4aea8b7cc11a195d2b01';
|
242 |
const ANALYSIS_PROMPT = `أنت خبير لغوي وتقني متخصص في مراجعة الترجمة التقنية وتحليل النصوص بدقة.
|
243 |
مهمتك مقارنة النص المصدر والنص الهدف واستخراج الاختلافات التالية:
|
244 |
-
1.
|
245 |
-
2.
|
246 |
-
3. **اختلاف المعنى:** في حال وجود اختلاف واضح في معنى النص.
|
247 |
يُرجى تمييز:
|
248 |
-
- النصوص المفقودة بوضعها بين علامتي __
|
249 |
-
- الأرقام والتواريخ بوضعها بين علامتي <
|
250 |
-
|
251 |
-
|
|
|
252 |
|
253 |
النص المصدر:
|
254 |
{source}
|
255 |
|
256 |
النص الهدف:
|
257 |
{target}`;
|
258 |
-
|
259 |
/* -------------------------------
|
260 |
دوال مساعدة عامة
|
261 |
------------------------------- */
|
@@ -281,7 +283,7 @@
|
|
281 |
};
|
282 |
|
283 |
/* -------------------------------
|
284 |
-
دوال تظليل الاختلافات (
|
285 |
------------------------------- */
|
286 |
const applyHighlights = (originalText, analysisOutput) => {
|
287 |
let highlightedText = originalText;
|
@@ -306,57 +308,41 @@
|
|
306 |
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
307 |
}
|
308 |
}
|
309 |
-
// تظليل اختلاف المعنى
|
310 |
-
const meaningRegex = /\[MEANING\](.*?)\[\/MEANING\]/g;
|
311 |
-
while ((match = meaningRegex.exec(analysisOutput)) !== null) {
|
312 |
-
const phrase = match[1].trim();
|
313 |
-
if (phrase) {
|
314 |
-
const replacement = `<span class="highlight-meaning">${phrase}</span>`;
|
315 |
-
const phraseRegex = new RegExp(escapeRegExp(phrase), 'g');
|
316 |
-
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
317 |
-
}
|
318 |
-
}
|
319 |
return highlightedText;
|
320 |
};
|
321 |
|
322 |
-
// توليد شرح تفصيلي للاختلافات مع أيقونات بسيطة
|
323 |
const generateExplanation = (sourceText, analysisOutput) => {
|
324 |
-
let
|
325 |
-
let match;
|
326 |
const iconMissing = `<i class="fas fa-exclamation-triangle mr-1"></i>`;
|
327 |
const iconNumber = `<i class="fas fa-hashtag mr-1"></i>`;
|
328 |
-
|
329 |
-
// النصوص المفقودة
|
330 |
const missingRegex = /__(.*?)__/g;
|
|
|
331 |
while ((match = missingRegex.exec(analysisOutput)) !== null) {
|
332 |
const phrase = match[1].trim();
|
333 |
if (phrase) {
|
334 |
const lineNum = getLineNumber(sourceText, phrase);
|
335 |
-
|
336 |
}
|
337 |
}
|
338 |
-
// الأرقام والتواريخ
|
339 |
const numberRegex = /<([^<>]+)>/g;
|
340 |
while ((match = numberRegex.exec(analysisOutput)) !== null) {
|
341 |
const phrase = match[1].trim();
|
342 |
if (phrase) {
|
343 |
const lineNum = getLineNumber(sourceText, phrase);
|
344 |
-
|
345 |
}
|
346 |
}
|
347 |
-
//
|
348 |
-
const
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
steps.push(`<li>${iconMeaning} في السطر ${lineNum}، اختلاف المعنى: <span class="highlight-meaning">${phrase}</span></li>`);
|
354 |
-
}
|
355 |
-
}
|
356 |
-
if (steps.length === 0) {
|
357 |
-
return `<p><i class="fas fa-check-circle mr-2"></i> لا توجد اختلافات ملحوظة بين النصين.</p>`;
|
358 |
}
|
359 |
-
return
|
360 |
};
|
361 |
|
362 |
/* -------------------------------
|
@@ -452,9 +438,9 @@
|
|
452 |
try {
|
453 |
const progressDiv = document.createElement('div');
|
454 |
progressDiv.className = "bg-indigo-100 p-4 rounded-xl mb-4";
|
455 |
-
progressDiv.innerHTML = `<div class="flex items-center">
|
456 |
-
<div class="animate-spin h-6 w-6 border-4 border-indigo-600 rounded-full border-t-transparent mr-3"></div>
|
457 |
<span>جارٍ التحليل...</span>
|
|
|
458 |
</div>`;
|
459 |
document.getElementById('errorsList').appendChild(progressDiv);
|
460 |
|
@@ -499,10 +485,11 @@
|
|
499 |
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetText);
|
500 |
document.getElementById('explanationText').innerHTML = `<p>النصوص متطابقة ولا يوجد اختلاف يجب الإشارة إليه.</p>`;
|
501 |
} else {
|
|
|
502 |
const sourceHighlighted = applyHighlights(sourceText, analysisOutput);
|
503 |
-
const targetHighlighted = applyHighlights(targetText, analysisOutput);
|
504 |
document.getElementById('sourceTextReview').innerHTML = splitIntoLines(sourceHighlighted);
|
505 |
-
|
|
|
506 |
const explanationHTML = generateExplanation(sourceText, analysisOutput);
|
507 |
document.getElementById('explanationText').innerHTML = explanationHTML;
|
508 |
}
|
|
|
49 |
border-radius: 3px;
|
50 |
font-weight: bold;
|
51 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
/* -------------------------------
|
54 |
تنسيق الفقرات وترقيمها
|
|
|
79 |
box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2);
|
80 |
transform: translateY(-3px);
|
81 |
}
|
82 |
+
.icon { margin-left: 0.5rem; }
|
83 |
+
/* تعديل أيقونات التحميل لتكون على اليمين */
|
84 |
+
.upload-label {
|
85 |
+
display: flex;
|
86 |
+
flex-direction: row-reverse;
|
87 |
+
align-items: center;
|
88 |
+
justify-content: center;
|
89 |
+
}
|
90 |
</style>
|
91 |
</head>
|
92 |
<body class="bg-gradient-to-br from-gray-100 via-blue-100 to-indigo-100 min-h-screen">
|
|
|
95 |
<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">
|
96 |
<div class="max-w-6xl mx-auto px-4 text-center">
|
97 |
<h1 class="text-5xl font-bold mb-4 animate-scale">
|
98 |
+
نظام المقارنة والتحليل المتقدم
|
99 |
+
<i class="fas fa-chart-line icon"></i>
|
100 |
</h1>
|
101 |
<p class="text-xl opacity-90">
|
102 |
+
تحليل دقيق لاكتشاف النصوص المفقودة والأرقام/التواريخ المختلفة
|
103 |
</p>
|
104 |
</div>
|
105 |
</header>
|
|
|
114 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
115 |
<!-- ملف المصدر -->
|
116 |
<div class="group border-2 border-dashed border-indigo-300 rounded-xl p-8 text-center bg-indigo-50 hover:bg-indigo-100 transition-colors duration-300">
|
117 |
+
<label class="cursor-pointer block upload-label">
|
118 |
<input type="file" id="sourceFile" accept=".docx,.pdf" class="hidden">
|
|
|
119 |
<span class="text-lg text-indigo-600 group-hover:text-indigo-700">ملف المصدر</span>
|
120 |
+
<i class="fas fa-upload text-5xl text-indigo-500 mb-4"></i>
|
121 |
</label>
|
122 |
</div>
|
123 |
<!-- ملف الهدف -->
|
124 |
<div class="group border-2 border-dashed border-pink-300 rounded-xl p-8 text-center bg-pink-50 hover:bg-pink-100 transition-colors duration-300">
|
125 |
+
<label class="cursor-pointer block upload-label">
|
126 |
<input type="file" id="targetFile" accept=".docx,.pdf" class="hidden">
|
|
|
127 |
<span class="text-lg text-pink-600 group-hover:text-pink-700">ملف الهدف</span>
|
128 |
+
<i class="fas fa-download text-5xl text-pink-500 mb-4"></i>
|
129 |
</label>
|
130 |
</div>
|
131 |
</div>
|
132 |
<div id="processStatus" class="hidden mt-4">
|
133 |
+
<div class="flex items-center justify-end space-x-3 bg-indigo-100 rounded-xl p-4">
|
|
|
134 |
<span class="text-lg text-indigo-700">جارٍ معالجة الملف...</span>
|
135 |
+
<div class="animate-spin h-8 w-8 border-4 border-indigo-600 rounded-full border-t-transparent"></div>
|
136 |
</div>
|
137 |
</div>
|
138 |
</div>
|
|
|
165 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
166 |
<!-- رفع ملف المصادر الإضافية -->
|
167 |
<div class="group border-2 border-dashed border-green-300 rounded-xl p-8 text-center bg-green-50 hover:bg-green-100 transition-colors duration-300">
|
168 |
+
<label class="cursor-pointer block upload-label">
|
169 |
<input type="file" id="sourceExtraFile" accept=".docx,.pdf" class="hidden">
|
|
|
170 |
<span class="text-lg text-green-600 group-hover:text-green-700">تحميل ملف المصدر</span>
|
171 |
+
<i class="fas fa-upload text-5xl text-green-500 mb-4"></i>
|
172 |
</label>
|
173 |
</div>
|
174 |
<!-- إدخال المصادر يدويًا -->
|
|
|
184 |
<!-- زر التحليل والمراجعة -->
|
185 |
<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 pulse-animation">
|
186 |
<div class="flex items-center justify-center">
|
187 |
+
<span>تحليل ومراجعة النصوص</span>
|
188 |
+
<i class="fas fa-sync-alt icon mr-2"></i>
|
189 |
</div>
|
190 |
</button>
|
191 |
|
|
|
204 |
</div>
|
205 |
<div>
|
206 |
<h4 class="text-lg font-bold text-gray-700 mb-3">
|
207 |
+
<i class="fas fa-file-alt icon text-pink-600"></i> النص الهدف (بدون تعليم)
|
208 |
</h4>
|
209 |
<div id="targetTextReview" class="bg-gray-50 rounded-xl p-6 min-h-[200px] border-2 border-gray-200 text-comparison"></div>
|
210 |
</div>
|
|
|
230 |
|
231 |
/* تحسين البرومت:
|
232 |
- مهمتك: مقارنة النص المصدر والنص الهدف واستخراج الاختلافات التالية:
|
233 |
+
1. **النصوص المفقودة:** الكلمات أو العبارات التي لم تُترجم من النص المصدر.
|
234 |
+
2. **الأرقام والتواريخ:** التي لا تتطابق بين النص المصدر والنص الهدف.
|
|
|
235 |
- يُرجى تمييز:
|
236 |
• النصوص المفقودة بوضعها بين علامتي __ و __.
|
237 |
• الأرقام والتواريخ بوضعها بين علامتي < و >.
|
238 |
+
- قم بالتحليل فقرة بفقرة، مع شرح مختصر لكل اختلاف وذكر رقم السطر إن أمكن.
|
239 |
+
- إذا تم استخدام مصادر خارجية لشرح المصطلحات أو الاختصارات، ضع علامة [USED_SOURCE] في نهاية التحليل.
|
240 |
+
- التزم بالتحليل الدقيق للإشارة فقط إلى الأخطاء دون تعليم عشوائي.
|
241 |
*/
|
242 |
const API_URL = 'https://api.deepseek.com/chat/completions';
|
243 |
const API_KEY = 'sk-15606736ed9e4aea8b7cc11a195d2b01';
|
244 |
const ANALYSIS_PROMPT = `أنت خبير لغوي وتقني متخصص في مراجعة الترجمة التقنية وتحليل النصوص بدقة.
|
245 |
مهمتك مقارنة النص المصدر والنص الهدف واستخراج الاختلافات التالية:
|
246 |
+
1. النصوص المفقودة: الكلمات أو العبارات التي لم تُترجم من النص المصدر.
|
247 |
+
2. الأرقام والتواريخ: التي لا تتطابق بين النص المصدر والنص الهدف.
|
|
|
248 |
يُرجى تمييز:
|
249 |
+
- النصوص المفقودة بوضعها بين علامتي __ و __.
|
250 |
+
- الأرقام والتواريخ بوضعها بين علامتي < و >.
|
251 |
+
قم بالتحليل فقرة بفقرة، مع شرح مختصر لكل اختلاف وذكر رقم السطر إن أمكن.
|
252 |
+
إذا تم استخدام مصادر خارجية لشرح المصطلحات أو الاختصارات، ضع علامة [USED_SOURCE] في نهاية التحليل.
|
253 |
+
التزم بالتحليل الدقيق للإشارة فقط إلى الأخطاء دون تعليم عشوائي.
|
254 |
|
255 |
النص المصدر:
|
256 |
{source}
|
257 |
|
258 |
النص الهدف:
|
259 |
{target}`;
|
260 |
+
|
261 |
/* -------------------------------
|
262 |
دوال مساعدة عامة
|
263 |
------------------------------- */
|
|
|
283 |
};
|
284 |
|
285 |
/* -------------------------------
|
286 |
+
دوال تظليل الاختلافات (التركيز على النصوص المفقودة والأرقام فقط)
|
287 |
------------------------------- */
|
288 |
const applyHighlights = (originalText, analysisOutput) => {
|
289 |
let highlightedText = originalText;
|
|
|
308 |
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
309 |
}
|
310 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
return highlightedText;
|
312 |
};
|
313 |
|
314 |
+
// توليد شرح تفصيلي للاختلافات فقرة بفقرة مع أيقونات بسيطة
|
315 |
const generateExplanation = (sourceText, analysisOutput) => {
|
316 |
+
let explanations = [];
|
|
|
317 |
const iconMissing = `<i class="fas fa-exclamation-triangle mr-1"></i>`;
|
318 |
const iconNumber = `<i class="fas fa-hashtag mr-1"></i>`;
|
319 |
+
// تحليل النصوص المفقودة
|
|
|
320 |
const missingRegex = /__(.*?)__/g;
|
321 |
+
let match;
|
322 |
while ((match = missingRegex.exec(analysisOutput)) !== null) {
|
323 |
const phrase = match[1].trim();
|
324 |
if (phrase) {
|
325 |
const lineNum = getLineNumber(sourceText, phrase);
|
326 |
+
explanations.push(`<p>${iconMissing} في السطر ${lineNum}: النص المفقود <span class="highlight-missing">${phrase}</span></p>`);
|
327 |
}
|
328 |
}
|
329 |
+
// تحليل الأرقام والتواريخ
|
330 |
const numberRegex = /<([^<>]+)>/g;
|
331 |
while ((match = numberRegex.exec(analysisOutput)) !== null) {
|
332 |
const phrase = match[1].trim();
|
333 |
if (phrase) {
|
334 |
const lineNum = getLineNumber(sourceText, phrase);
|
335 |
+
explanations.push(`<p>${iconNumber} في السطر ${lineNum}: الرقم/التاريخ <span class="highlight-number">${phrase}</span></p>`);
|
336 |
}
|
337 |
}
|
338 |
+
// التحقق من استخدام المصادر
|
339 |
+
const usedSource = analysisOutput.includes('[USED_SOURCE]');
|
340 |
+
let sourceNote = usedSource ? `<p><i class="fas fa-book-reader mr-1"></i> تم استخدام مصادر خارجية لشرح المصطلحات.</p>`
|
341 |
+
: `<p><i class="fas fa-book mr-1"></i> لم يتم استخدام مصادر خارجية.</p>`;
|
342 |
+
if (explanations.length === 0) {
|
343 |
+
return `<p><i class="fas fa-check-circle mr-2"></i> لا توجد اختلافات ملحوظة بين النصين.</p>` + sourceNote;
|
|
|
|
|
|
|
|
|
|
|
344 |
}
|
345 |
+
return explanations.join('') + sourceNote;
|
346 |
};
|
347 |
|
348 |
/* -------------------------------
|
|
|
438 |
try {
|
439 |
const progressDiv = document.createElement('div');
|
440 |
progressDiv.className = "bg-indigo-100 p-4 rounded-xl mb-4";
|
441 |
+
progressDiv.innerHTML = `<div class="flex items-center justify-end">
|
|
|
442 |
<span>جارٍ التحليل...</span>
|
443 |
+
<div class="animate-spin h-6 w-6 border-4 border-indigo-600 rounded-full border-t-transparent ml-3"></div>
|
444 |
</div>`;
|
445 |
document.getElementById('errorsList').appendChild(progressDiv);
|
446 |
|
|
|
485 |
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetText);
|
486 |
document.getElementById('explanationText').innerHTML = `<p>النصوص متطابقة ولا يوجد اختلاف يجب الإشارة إليه.</p>`;
|
487 |
} else {
|
488 |
+
// تطبيق التعليم فقط على النص المصدر
|
489 |
const sourceHighlighted = applyHighlights(sourceText, analysisOutput);
|
|
|
490 |
document.getElementById('sourceTextReview').innerHTML = splitIntoLines(sourceHighlighted);
|
491 |
+
// عرض النص الهدف بدون تعليم
|
492 |
+
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetText);
|
493 |
const explanationHTML = generateExplanation(sourceText, analysisOutput);
|
494 |
document.getElementById('explanationText').innerHTML = explanationHTML;
|
495 |
}
|