Update index.html
Browse files- index.html +33 -27
index.html
CHANGED
@@ -226,29 +226,38 @@
|
|
226 |
(function() {
|
227 |
"use strict";
|
228 |
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
const ANALYSIS_PROMPT = `أنت خبير لغوي وتقني متخصص في مراجعة الترجمة التقنية وتحليل النصوص بدقة.
|
231 |
مهمتك مقارنة النص المصدر والنص الهدف واستخراج الاختلافات التالية:
|
232 |
-
1. **النصوص المفقودة:** الكلمات أو العبارات التي لم تُترجم من النص
|
233 |
2. **الأرقام والتواريخ:** التي لا تتطابق بين النص المصدر والنص الهدف.
|
234 |
-
3. **اختلاف المعنى:** في حال وجود اختلاف في معنى
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
239 |
|
240 |
النص المصدر:
|
241 |
{source}
|
242 |
|
243 |
النص الهدف:
|
244 |
{target}`;
|
245 |
-
|
246 |
-
// إعداد المتغيرات للـ API
|
247 |
-
const API_URL = 'https://api.deepseek.com/chat/completions';
|
248 |
-
const API_KEY = 'sk-15606736ed9e4aea8b7cc11a195d2b01';
|
249 |
|
250 |
/* -------------------------------
|
251 |
-
|
252 |
------------------------------- */
|
253 |
const countWords = text =>
|
254 |
text.trim().split(/\s+/).filter(word => word !== "").length;
|
@@ -256,26 +265,23 @@
|
|
256 |
const escapeRegExp = string =>
|
257 |
string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
258 |
|
259 |
-
// تقسيم النص إلى فقرات
|
260 |
const splitIntoLines = text =>
|
261 |
text.split(/\n+/).map((line, i) => {
|
262 |
line = line.trim();
|
263 |
-
if(line &&
|
264 |
return `<div class="line-item"><span class="line-number">${i+1}:</span><span class="line-text">${line}</span></div>`;
|
265 |
}).join('');
|
266 |
|
267 |
-
// الحصول على رقم السطر الذي يحتوي على
|
268 |
const getLineNumber = (text, substring) => {
|
269 |
-
const
|
270 |
-
|
271 |
-
|
272 |
-
if (regex.test(lines[i])) return i + 1;
|
273 |
-
}
|
274 |
-
return "غير محدد";
|
275 |
};
|
276 |
|
277 |
/* -------------------------------
|
278 |
-
دوال تظليل
|
279 |
------------------------------- */
|
280 |
const applyHighlights = (originalText, analysisOutput) => {
|
281 |
let highlightedText = originalText;
|
@@ -286,7 +292,7 @@
|
|
286 |
const phrase = match[1].trim();
|
287 |
if (phrase) {
|
288 |
const replacement = `<span class="highlight-missing">${phrase}</span>`;
|
289 |
-
const phraseRegex = new RegExp(escapeRegExp(phrase), '
|
290 |
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
291 |
}
|
292 |
}
|
@@ -296,7 +302,7 @@
|
|
296 |
const phrase = match[1].trim();
|
297 |
if (phrase) {
|
298 |
const replacement = `<span class="highlight-number">${phrase}</span>`;
|
299 |
-
const phraseRegex = new RegExp(escapeRegExp(phrase), '
|
300 |
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
301 |
}
|
302 |
}
|
@@ -306,14 +312,14 @@
|
|
306 |
const phrase = match[1].trim();
|
307 |
if (phrase) {
|
308 |
const replacement = `<span class="highlight-meaning">${phrase}</span>`;
|
309 |
-
const phraseRegex = new RegExp(escapeRegExp(phrase), '
|
310 |
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
311 |
}
|
312 |
}
|
313 |
return highlightedText;
|
314 |
};
|
315 |
|
316 |
-
// توليد شرح تفصيلي للاختلافات مع أيقونات
|
317 |
const generateExplanation = (sourceText, analysisOutput) => {
|
318 |
let steps = [];
|
319 |
let match;
|
@@ -348,7 +354,7 @@
|
|
348 |
}
|
349 |
}
|
350 |
if (steps.length === 0) {
|
351 |
-
return `<p><i class="fas fa-check-circle mr-2"></i>
|
352 |
}
|
353 |
return `<ol class="list-decimal ml-6 space-y-2">${steps.join('')}</ol>`;
|
354 |
};
|
|
|
226 |
(function() {
|
227 |
"use strict";
|
228 |
|
229 |
+
/* تحسين البرومت:
|
230 |
+
- مهمتك: مقارنة النص المصدر والنص الهدف واستخراج الاختلافات التالية:
|
231 |
+
1. النصوص المفقودة: الكلمات أو العبارات التي لم تُترجم من المصدر (لا يوجد لها مقابل في الهدف).
|
232 |
+
2. الأرقام والتواريخ: التي لا تتطابق بين المصدر والهدف.
|
233 |
+
3. اختلاف المعنى: في حال وجود اختلاف واضح في معنى النص.
|
234 |
+
- يُرجى تمييز:
|
235 |
+
• النصوص المفقودة بوضعها بين علامتي __ و __.
|
236 |
+
• الأرقام والتواريخ بوضعها بين علامتي < و >.
|
237 |
+
• اختلاف المعنى بوضعها بين [MEANING] و [/MEANING].
|
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 |
+
- اختلاف المعنى بوضعها بين [MEANING] و [/MEANING].
|
251 |
+
قدم الناتج في شكل قائمة تفصيلية مع شرح مختصر لكل اختلاف مع ذكر رقم السطر إن أمكن.
|
252 |
|
253 |
النص المصدر:
|
254 |
{source}
|
255 |
|
256 |
النص الهدف:
|
257 |
{target}`;
|
|
|
|
|
|
|
|
|
258 |
|
259 |
/* -------------------------------
|
260 |
+
دوال مساعدة عامة
|
261 |
------------------------------- */
|
262 |
const countWords = text =>
|
263 |
text.trim().split(/\s+/).filter(word => word !== "").length;
|
|
|
265 |
const escapeRegExp = string =>
|
266 |
string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
267 |
|
268 |
+
// تقسيم النص إلى فقرات مرقمة
|
269 |
const splitIntoLines = text =>
|
270 |
text.split(/\n+/).map((line, i) => {
|
271 |
line = line.trim();
|
272 |
+
if(line && !line.endsWith('.')) { line += '.'; }
|
273 |
return `<div class="line-item"><span class="line-number">${i+1}:</span><span class="line-text">${line}</span></div>`;
|
274 |
}).join('');
|
275 |
|
276 |
+
// الحصول على رقم السطر الذي يحتوي على عبارة معينة
|
277 |
const getLineNumber = (text, substring) => {
|
278 |
+
const index = text.indexOf(substring);
|
279 |
+
if (index === -1) return "غير محدد";
|
280 |
+
return text.substring(0, index).split("\n").length;
|
|
|
|
|
|
|
281 |
};
|
282 |
|
283 |
/* -------------------------------
|
284 |
+
دوال تظليل الاختلا��ات (استخدام العلامات المستخرجة من البرومت)
|
285 |
------------------------------- */
|
286 |
const applyHighlights = (originalText, analysisOutput) => {
|
287 |
let highlightedText = originalText;
|
|
|
292 |
const phrase = match[1].trim();
|
293 |
if (phrase) {
|
294 |
const replacement = `<span class="highlight-missing">${phrase}</span>`;
|
295 |
+
const phraseRegex = new RegExp(escapeRegExp(phrase), 'g');
|
296 |
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
297 |
}
|
298 |
}
|
|
|
302 |
const phrase = match[1].trim();
|
303 |
if (phrase) {
|
304 |
const replacement = `<span class="highlight-number">${phrase}</span>`;
|
305 |
+
const phraseRegex = new RegExp(escapeRegExp(phrase), 'g');
|
306 |
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
307 |
}
|
308 |
}
|
|
|
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 steps = [];
|
325 |
let match;
|
|
|
354 |
}
|
355 |
}
|
356 |
if (steps.length === 0) {
|
357 |
+
return `<p><i class="fas fa-check-circle mr-2"></i> لا توجد اختلافات ملحوظة بين النصين.</p>`;
|
358 |
}
|
359 |
return `<ol class="list-decimal ml-6 space-y-2">${steps.join('')}</ol>`;
|
360 |
};
|