Update index.html
Browse files- index.html +19 -43
index.html
CHANGED
@@ -98,7 +98,7 @@
|
|
98 |
منصة مراجعة النصوص والترجمات <i class="fas fa-chart-line icon"></i>
|
99 |
</h1>
|
100 |
<p class="text-2xl opacity-90">
|
101 |
-
تحليل دقيق
|
102 |
</p>
|
103 |
</div>
|
104 |
</header>
|
@@ -255,30 +255,21 @@
|
|
255 |
(function() {
|
256 |
"use strict";
|
257 |
|
258 |
-
/*
|
259 |
-
|
260 |
-
|
261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
*/
|
263 |
-
const ANALYSIS_PROMPT = `أنت
|
264 |
-
|
265 |
-
إذا كانت النصوص
|
266 |
-
|
267 |
-
1. النصوص المفقودة: الكلمات أو العبارات الموجودة في النص المصدر وغير موجودة في النص الهدف.
|
268 |
-
2. الأرقام والتواريخ: يجب مقارنة الأرقام مع تجاهل الفواصل والترقيم إذا كانت القيمة نفسها (مثال: "3,000" و"3000" و"٣٠٠٠")، وفي حال وجود اختلاف في القيمة أو الصيغة يتم الإشارة إليه.
|
269 |
-
3. اختلاف المعنى: إذا كانت الترجمة تحمل معنى مختلفاً عن النص المصدر.
|
270 |
-
4. الاختصارات: يجب فهمها وتحليلها بدقة؛ على سبيل المثال، يجب اعتبار "EGP" و"جنيه مصري" متطابقتين، وكذلك اختصارات الدول والعملات الشائعة (مثل "USD" و"دولار أمريكي"، "EUR" و"يورو").
|
271 |
-
|
272 |
-
استخدم العلامات التالية لتعليم النص المصدر فقط:
|
273 |
-
- النصوص المفقودة بين علامتي __ و __.
|
274 |
-
- الأرقام والتواريخ بين علامتي < و >.
|
275 |
-
- اختلاف المعنى بين علامتي [MEANING] و [/MEANING].
|
276 |
-
- الاختصارات بين علامتي {ABBR} و {/ABBR}.
|
277 |
-
|
278 |
-
إذا تمكنت من استخراج كافة الاختلافات المطلوبة بدقة، أرجو إرجاع الناتج مع الرسالة "مكافأة: لقد نجحت في التحدي!".
|
279 |
-
أما إذا أخفقت في استخراج الاختلافات أو أدرجت أخطاء غير موجودة، أرجو إرجاع الناتج مع الرسالة "عقوبة: فشلت في التحدي!".
|
280 |
-
|
281 |
-
قدم الناتج في شكل قائمة مفصلة مع شرح مختصر لكل اختلاف وذكر رقم السطر إن أمكن.
|
282 |
|
283 |
النص المصدر:
|
284 |
{source}
|
@@ -391,7 +382,6 @@
|
|
391 |
}
|
392 |
}
|
393 |
|
394 |
-
// التحقق من استخدام المصادر الخارجية (في حال تم استخدامها)
|
395 |
const usedSource = analysisOutput.includes('[USED_SOURCE]');
|
396 |
let sourceNote = usedSource ? `<p><i class="fas fa-book-reader mr-1"></i> تم استخدام مصادر خارجية لشرح الاختصارات والمصطلحات.</p>`
|
397 |
: `<p><i class="fas fa-book mr-1"></i> لم يتم استخدام مصادر خارجية.</p>`;
|
@@ -407,7 +397,6 @@
|
|
407 |
let text = "";
|
408 |
try {
|
409 |
if (file.type === 'application/pdf') {
|
410 |
-
// استخدام OCR لـ PDF
|
411 |
const form = new FormData();
|
412 |
form.append('image', file);
|
413 |
const response = await fetch('https://demo.api4ai.cloud/ocr/v1/results', {
|
@@ -418,12 +407,10 @@
|
|
418 |
const data = await response.json();
|
419 |
text = data.results?.[0]?.entities?.[0]?.objects?.[0]?.entities?.[0]?.text || "";
|
420 |
} else if (file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
|
421 |
-
// معالجة ملفات DOCX
|
422 |
const arrayBuffer = await file.arrayBuffer();
|
423 |
const result = await mammoth.extractRawText({ arrayBuffer });
|
424 |
text = result.value;
|
425 |
} else if (file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type === 'application/vnd.ms-excel') {
|
426 |
-
// معالجة ملفات Excel باستخدام SheetJS
|
427 |
const arrayBuffer = await file.arrayBuffer();
|
428 |
const workbook = XLSX.read(arrayBuffer, { type: 'array' });
|
429 |
let sheetData = [];
|
@@ -478,27 +465,20 @@
|
|
478 |
errorsList.appendChild(errorDiv);
|
479 |
};
|
480 |
|
481 |
-
// وظيفة تنزيل التقرير بصيغة PDF
|
482 |
const downloadReportPDF = () => {
|
483 |
const { jsPDF } = window.jspdf;
|
484 |
-
const doc = new jsPDF({
|
485 |
-
orientation: 'p',
|
486 |
-
unit: 'pt',
|
487 |
-
format: 'a4'
|
488 |
-
});
|
489 |
-
// ضبط الخط إلى Arial (قد تحتاج إلى تضمين خط عربي مناسب)
|
490 |
doc.setFont('Arial');
|
491 |
doc.setFontSize(12);
|
492 |
-
// إعداد التقرير مع دعم العربية والإنجليزية
|
493 |
const translatorInfo = `اسم المترجم/الكود: ${document.getElementById('translatorName').value}\nالتقييم: ${document.getElementById('translatorRating').value}`;
|
494 |
const errorsText = document.getElementById('explanationText').innerText;
|
495 |
const report = `تقرير الأخطاء:\n\n${errorsText}\n\n${translatorInfo}`;
|
496 |
-
// لمحاذاة النص لليمين (قد تحتاج إلى ضبط إضافي حسب الخط المستخدم)
|
497 |
doc.text(report, 10, 30, { align: 'right' });
|
498 |
doc.save("تقرير_المراجعة.pdf");
|
499 |
};
|
500 |
|
501 |
-
// وظيفة تنزيل التقرير بصيغة Word
|
502 |
const downloadReportWord = () => {
|
503 |
const translatorInfo = `اسم المترجم/الكود: ${document.getElementById('translatorName').value}\nالتقييم: ${document.getElementById('translatorRating').value}\n\n`;
|
504 |
const errorsText = document.getElementById('explanationText').innerText;
|
@@ -554,7 +534,7 @@
|
|
554 |
const payload = {
|
555 |
model: "deepseek-chat",
|
556 |
messages: [
|
557 |
-
{ role: "system", content: "أنت خبير في تحليل ومراجعة النصوص بدقة عالية،
|
558 |
{ role: "user", content: prompt }
|
559 |
],
|
560 |
temperature: 0.3,
|
@@ -578,7 +558,6 @@
|
|
578 |
const analysisOutput = data.choices[0].message.content.trim();
|
579 |
progressDiv.remove();
|
580 |
|
581 |
-
// إذا كانت النصوص متطابقة تماماً
|
582 |
if (analysisOutput.includes('[MATCH]')) {
|
583 |
const checkDiv = document.createElement('div');
|
584 |
checkDiv.className = "p-4 rounded-xl bg-green-50 text-green-700 flex items-center";
|
@@ -588,16 +567,13 @@
|
|
588 |
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetText);
|
589 |
document.getElementById('explanationText').innerHTML = `<p class="text-xl">النصوص متطابقة ولا يوجد اختلاف يجب الإشارة إليه.</p>`;
|
590 |
} else {
|
591 |
-
// تطبيق التظليل على النص المصدر فقط
|
592 |
const sourceHighlighted = applyHighlights(sourceText, analysisOutput);
|
593 |
document.getElementById('sourceTextReview').innerHTML = splitIntoLines(sourceHighlighted);
|
594 |
-
// عرض النص الهدف بدون تعليم
|
595 |
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetText);
|
596 |
const explanationHTML = generateExplanation(sourceText, analysisOutput);
|
597 |
document.getElementById('explanationText').innerHTML = explanationHTML;
|
598 |
}
|
599 |
|
600 |
-
// إظهار قسم التقرير وإدخال بيانات المترجم بعد التحليل
|
601 |
document.getElementById('reportSection').classList.remove('hidden');
|
602 |
|
603 |
} catch (error) {
|
|
|
98 |
منصة مراجعة النصوص والترجمات <i class="fas fa-chart-line icon"></i>
|
99 |
</h1>
|
100 |
<p class="text-2xl opacity-90">
|
101 |
+
تحليل دقيق لاستخراج النصوص المفقودة فقط عبر ترجمة النص الهدف إلى لغة المصدر
|
102 |
</p>
|
103 |
</div>
|
104 |
</header>
|
|
|
255 |
(function() {
|
256 |
"use strict";
|
257 |
|
258 |
+
/* برومت مختصر:
|
259 |
+
قم بترجمة النص الهدف إلى لغة النص المصدر، ثم قارن بين النص المصدر والنص الهدف المترجم واخرج النصوص المفقودة فقط.
|
260 |
+
إذا كانت النصوص متطابقة، اكتب [MATCH].
|
261 |
+
أضف رسالة مكافأة "مكافأة: لقد نجحت في التحدي!" إذا كانت النتيجة دقيقة، أو رسالة عقوبة "عقوبة: فشلت في التحدي!" إذا كانت هناك أخطاء.
|
262 |
+
|
263 |
+
النص المصدر:
|
264 |
+
{source}
|
265 |
+
|
266 |
+
النص الهدف:
|
267 |
+
{target}
|
268 |
*/
|
269 |
+
const ANALYSIS_PROMPT = `أنت نموذج DeepSeek.
|
270 |
+
قم بترجمة النص الهدف إلى لغة النص المصدر، ثم قارن بين النص المصدر والنص الهدف المترجم واخرج النصوص المفقودة فقط.
|
271 |
+
إذا كانت النصوص متطابقة، اكتب [MATCH].
|
272 |
+
أضف "مكافأة: لقد نجحت في التحدي!" إذا كانت النتائج دقيقة، أو "عقوبة: فشلت في التحدي!" إذا كانت هناك أخطاء.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
|
274 |
النص المصدر:
|
275 |
{source}
|
|
|
382 |
}
|
383 |
}
|
384 |
|
|
|
385 |
const usedSource = analysisOutput.includes('[USED_SOURCE]');
|
386 |
let sourceNote = usedSource ? `<p><i class="fas fa-book-reader mr-1"></i> تم استخدام مصادر خارجية لشرح الاختصارات والمصطلحات.</p>`
|
387 |
: `<p><i class="fas fa-book mr-1"></i> لم يتم استخدام مصادر خارجية.</p>`;
|
|
|
397 |
let text = "";
|
398 |
try {
|
399 |
if (file.type === 'application/pdf') {
|
|
|
400 |
const form = new FormData();
|
401 |
form.append('image', file);
|
402 |
const response = await fetch('https://demo.api4ai.cloud/ocr/v1/results', {
|
|
|
407 |
const data = await response.json();
|
408 |
text = data.results?.[0]?.entities?.[0]?.objects?.[0]?.entities?.[0]?.text || "";
|
409 |
} else if (file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
|
|
|
410 |
const arrayBuffer = await file.arrayBuffer();
|
411 |
const result = await mammoth.extractRawText({ arrayBuffer });
|
412 |
text = result.value;
|
413 |
} else if (file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type === 'application/vnd.ms-excel') {
|
|
|
414 |
const arrayBuffer = await file.arrayBuffer();
|
415 |
const workbook = XLSX.read(arrayBuffer, { type: 'array' });
|
416 |
let sheetData = [];
|
|
|
465 |
errorsList.appendChild(errorDiv);
|
466 |
};
|
467 |
|
468 |
+
// وظيفة تنزيل التقرير بصيغة PDF
|
469 |
const downloadReportPDF = () => {
|
470 |
const { jsPDF } = window.jspdf;
|
471 |
+
const doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' });
|
|
|
|
|
|
|
|
|
|
|
472 |
doc.setFont('Arial');
|
473 |
doc.setFontSize(12);
|
|
|
474 |
const translatorInfo = `اسم المترجم/الكود: ${document.getElementById('translatorName').value}\nالتقييم: ${document.getElementById('translatorRating').value}`;
|
475 |
const errorsText = document.getElementById('explanationText').innerText;
|
476 |
const report = `تقرير الأخطاء:\n\n${errorsText}\n\n${translatorInfo}`;
|
|
|
477 |
doc.text(report, 10, 30, { align: 'right' });
|
478 |
doc.save("تقرير_المراجعة.pdf");
|
479 |
};
|
480 |
|
481 |
+
// وظيفة تنزيل التقرير بصيغة Word
|
482 |
const downloadReportWord = () => {
|
483 |
const translatorInfo = `اسم المترجم/الكود: ${document.getElementById('translatorName').value}\nالتقييم: ${document.getElementById('translatorRating').value}\n\n`;
|
484 |
const errorsText = document.getElementById('explanationText').innerText;
|
|
|
534 |
const payload = {
|
535 |
model: "deepseek-chat",
|
536 |
messages: [
|
537 |
+
{ role: "system", content: "أنت خبير في تحليل ومراجعة النصوص بدقة عالية، وتعرف كيفية ترجمة النص الهدف إلى لغة النص المصدر قبل المقارنة." },
|
538 |
{ role: "user", content: prompt }
|
539 |
],
|
540 |
temperature: 0.3,
|
|
|
558 |
const analysisOutput = data.choices[0].message.content.trim();
|
559 |
progressDiv.remove();
|
560 |
|
|
|
561 |
if (analysisOutput.includes('[MATCH]')) {
|
562 |
const checkDiv = document.createElement('div');
|
563 |
checkDiv.className = "p-4 rounded-xl bg-green-50 text-green-700 flex items-center";
|
|
|
567 |
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetText);
|
568 |
document.getElementById('explanationText').innerHTML = `<p class="text-xl">النصوص متطابقة ولا يوجد اختلاف يجب الإشارة إليه.</p>`;
|
569 |
} else {
|
|
|
570 |
const sourceHighlighted = applyHighlights(sourceText, analysisOutput);
|
571 |
document.getElementById('sourceTextReview').innerHTML = splitIntoLines(sourceHighlighted);
|
|
|
572 |
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetText);
|
573 |
const explanationHTML = generateExplanation(sourceText, analysisOutput);
|
574 |
document.getElementById('explanationText').innerHTML = explanationHTML;
|
575 |
}
|
576 |
|
|
|
577 |
document.getElementById('reportSection').classList.remove('hidden');
|
578 |
|
579 |
} catch (error) {
|