Spaces:
Running
Running
File size: 18,283 Bytes
b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b c984bb8 0976351 b05807b 0976351 b05807b 0976351 b05807b 0976351 b05807b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>نظام المقارنة والترجمة المتقدم</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
<style>
@keyframes gradient {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.animate-gradient {
background-size: 200% 200%;
animation: gradient 15s ease infinite;
}
.transition-all {
transition: all 0.3s ease-in-out;
}
.animate-scale {
transition: transform 0.2s ease-in-out;
}
.animate-scale:hover {
transform: scale(1.02);
}
</style>
</head>
<body class="bg-gradient-to-br from-gray-50 via-blue-50 to-indigo-50">
<div class="min-h-screen pb-12">
<!-- Header -->
<header class="bg-gradient-to-r from-blue-600 via-indigo-600 to-purple-600 animate-gradient text-white py-10 mb-10 shadow-xl">
<div class="max-w-6xl mx-auto px-4">
<h1 class="text-5xl font-bold text-center mb-4 animate-scale">نظام المقارنة والترجمة المتقدم</h1>
<p class="text-center text-xl text-blue-100 opacity-90">مقارنة وتحليل النصوص العربية والإنجليزية بذكاء</p>
<div class="flex justify-center mt-6 space-x-4">
<div class="bg-white bg-opacity-20 rounded-lg px-4 py-2 backdrop-blur-sm">
<span class="text-sm">دقة عالية</span>
</div>
<div class="bg-white bg-opacity-20 rounded-lg px-4 py-2 backdrop-blur-sm">
<span class="text-sm">تحليل ذكي</span>
</div>
<div class="bg-white bg-opacity-20 rounded-lg px-4 py-2 backdrop-blur-sm">
<span class="text-sm">سهولة الاستخدام</span>
</div>
</div>
</div>
</header>
<main class="max-w-6xl mx-auto px-4">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<!-- Input Section -->
<div class="space-y-6">
<!-- File Upload Card -->
<div class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100 hover:shadow-xl transition-all animate-scale">
<h2 class="text-2xl font-bold mb-6 text-gray-800 flex items-center">
<svg class="w-6 h-6 mr-2 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"/>
</svg>
تحميل الملفات
</h2>
<div class="space-y-6">
<!-- Word Upload -->
<div class="group border-3 border-dashed border-blue-200 rounded-xl p-8 text-center hover:border-blue-500 transition-colors duration-300 bg-blue-50 hover:bg-blue-100">
<label class="cursor-pointer block">
<input type="file" id="docxFile" accept=".docx" class="hidden">
<svg class="w-12 h-12 mx-auto mb-4 text-blue-500 group-hover:text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
<span class="text-lg text-blue-600 group-hover:text-blue-700">اختر ملف Word أو اسحبه هنا</span>
</label>
</div>
<!-- PDF Upload -->
<div class="group border-3 border-dashed border-purple-200 rounded-xl p-8 text-center hover:border-purple-500 transition-colors duration-300 bg-purple-50 hover:bg-purple-100">
<label class="cursor-pointer block">
<input type="file" id="pdfFile" accept=".pdf" class="hidden">
<svg class="w-12 h-12 mx-auto mb-4 text-purple-500 group-hover:text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"/>
</svg>
<span class="text-lg text-purple-600 group-hover:text-purple-700">اختر ملف PDF أو اسحبه هنا</span>
</label>
</div>
<!-- Processing Status -->
<div id="processStatus" class="hidden">
<div class="flex items-center justify-center space-x-3 bg-blue-100 rounded-xl p-4">
<div class="animate-spin h-8 w-8 border-4 border-blue-600 rounded-full border-t-transparent"></div>
<span class="text-lg text-blue-700">جاري معالجة الملف...</span>
</div>
</div>
</div>
</div>
<!-- Text Input Card -->
<div class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100 hover:shadow-xl transition-all animate-scale">
<div class="space-y-6">
<!-- Arabic Input -->
<div class="group">
<label class="block text-lg font-bold text-gray-700 mb-3 flex items-center">
<svg class="w-5 h-5 mr-2 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5h12M9 3v2m1.048 9.5A18.022 18.022 0 016.412 9m6.088 9h7M11 21l5-10 5 10M12.751 5C11.783 10.77 8.07 15.61 3 18.129"/>
</svg>
النص العربي
</label>
<textarea id="arabicText" dir="rtl"
class="w-full px-6 py-4 border-2 border-gray-200 rounded-xl focus:ring-4 focus:ring-blue-200 focus:border-blue-400 transition-all resize-none text-lg"
rows="6"
placeholder="اكتب النص العربي هنا..."></textarea>
</div>
<!-- English Input -->
<div class="group">
<label class="block text-lg font-bold text-gray-700 mb-3 flex items-center">
<svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5h12M9 3v2m1.048 9.5A18.022 18.022 0 016.412 9m6.088 9h7M11 21l5-10 5 10M12.751 5C11.783 10.77 8.07 15.61 3 18.129"/>
</svg>
English Text
</label>
<textarea id="englishText" dir="ltr"
class="w-full px-6 py-4 border-2 border-gray-200 rounded-xl focus:ring-4 focus:ring-purple-200 focus:border-purple-400 transition-all resize-none text-lg"
rows="6"
placeholder="Enter English text here..."></textarea>
</div>
</div>
</div>
<!-- Submit Button -->
<button id="submitBtn"
class="w-full bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 text-white font-bold py-5 px-8 rounded-xl transition-all transform hover:scale-105 focus:ring-4 focus:ring-blue-200 text-xl shadow-lg hover:shadow-xl">
<div class="flex items-center justify-center">
<svg class="w-6 h-6 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
</svg>
تحليل النصوص
</div>
</button>
</div>
<!-- Review Section -->
<div class="bg-white rounded-2xl shadow-lg p-8 border border-gray-100 hover:shadow-xl transition-all animate-scale">
<h2 class="text-2xl font-bold mb-6 text-gray-800 flex items-center">
<svg class="w-6 h-6 mr-2 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
مراجعة وتحليل النصوص
</h2>
<!-- Original Text Review -->
<div class="mb-8">
<h3 class="text-lg font-bold text-gray-700 mb-3 flex items-center">
<svg class="w-5 h-5 mr-2 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
</svg>
النص الأصلي
</h3>
<div id="originalTextReview" class="bg-blue-50 rounded-xl p-6 min-h-[200px] border-2 border-blue-100"></div>
</div>
<!-- Translation Review -->
<div class="mb-8">
<h3 class="text-lg font-bold text-gray-700 mb-3 flex items-center">
<svg class="w-5 h-5 mr-2 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
</svg>
النص المترجم
</h3>
<div id="translatedTextReview" class="bg-gray-50 rounded-xl p-6 min-h-[200px]"></div>
</div>
<!-- Errors List -->
<div class="border-t pt-6">
<h3 class="text-lg font-medium text-gray-700 mb-3">الأخطاء والملاحظات</h3>
<div id="errorsList" class="space-y-3"></div>
</div>
</div>
</div>
</main>
</div>
<script>
// Same JavaScript code as before
const ANALYSIS_PROMPT = `قم بمقارنة النصوص بين النسختين العربية والإنجليزية. إذا وُجدت نصوص مفقودة في النسخة الإنجليزية، أو كانت الأرقام غير صحيحة أو تحتوي على أخطاء إملائية، فاعرضها. تأكد أيضًا من إظهار أي نص عربي موجود في النسخة الأصلية ولم يُترجم بالكامل. إذا لم يتم العثور على أي مشاكل، فأجب برسالة واحدة تفيد بأن النص سليم.`;
document.getElementById('docxFile').addEventListener('change', async (event) => {
const file = event.target.files[0];
if (!file) return;
const processStatus = document.getElementById('processStatus');
processStatus.classList.remove('hidden');
try {
const arrayBuffer = await file.arrayBuffer();
const result = await mammoth.extractRawText({ arrayBuffer });
const text = result.value;
if (/[\u0600-\u06FF]/.test(text)) {
document.getElementById('arabicText').value = text;
} else {
document.getElementById('englishText').value = text;
}
} catch (error) {
console.error('DOCX processing error:', error);
addError('خطأ في معالجة ملف Word');
} finally {
processStatus.classList.add('hidden');
}
});
document.getElementById('pdfFile').addEventListener('change', async (event) => {
const file = event.target.files[0];
if (!file) return;
const processStatus = document.getElementById('processStatus');
processStatus.classList.remove('hidden');
try {
const form = new FormData();
form.append('image', file);
const response = await fetch('https://demo.api4ai.cloud/ocr/v1/results', {
method: 'POST',
body: form,
headers: { 'A4A-CLIENT-APP-ID': 'sample' }
});
const data = await response.json();
const text = data.results[0].entities[0].objects[0].entities[0].text;
if (/[\u0600-\u06FF]/.test(text)) {
document.getElementById('arabicText').value = text;
} else {
document.getElementById('englishText').value = text;
}
} catch (error) {
console.error('PDF processing error:', error);
addError('خطأ في معالجة ملف PDF');
} finally {
processStatus.classList.add('hidden');
}
});
function addError(message, type = 'error') {
const errorsList = document.getElementById('errorsList');
const errorDiv = document.createElement('div');
errorDiv.className = `p-4 rounded-xl ${type === 'error' ? 'bg-red-50 text-red-700' : 'bg-yellow-50 text-yellow-700'}`;
errorDiv.textContent = message;
errorsList.appendChild(errorDiv);
}
function highlightDifferences(originalText, translatedText, container) {
container.innerHTML = '';
const textElement = document.createElement('div');
textElement.className = 'text-gray-800 leading-relaxed';
const words = originalText.split(' ');
words.forEach(word => {
const span = document.createElement('span');
span.textContent = word + ' ';
if (!translatedText.includes(word)) {
span.className = 'bg-yellow-200 px-1 rounded';
}
textElement.appendChild(span);
});
container.appendChild(textElement);
}
document.getElementById('submitBtn').addEventListener('click', async () => {
const arabicText = document.getElementById('arabicText').value;
const englishText = document.getElementById('englishText').value;
document.getElementById('errorsList').innerHTML = '';
highlightDifferences(arabicText, englishText, document.getElementById('originalTextReview'));
highlightDifferences(englishText, arabicText, document.getElementById('translatedTextReview'));
try {
const response = await fetch('https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
message: `Arabic: ${arabicText}\nEnglish: ${englishText}\nAnalysis: ${ANALYSIS_PROMPT}`,
history: []
})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
const analysisResults = data.response;
addError(analysisResults, 'warning');
} catch (error) {
addError(`خطأ في التحليل: ${error.message}`);
}
});
</script>
</body>
</html> |