Commit ·
20a34f1
1
Parent(s): 90d59e9
UI: nav logo, bayyinah hover, quran icon, hero autocomplete shadow, clean tooltip, fix punctuation dup + hamza كان
Browse files- src/app.py +15 -0
- src/css/components.css +34 -0
- src/index.html +5 -5
- src/js/editor.js +6 -21
- src/nlp/spelling/araspell_rules.py +15 -0
src/app.py
CHANGED
|
@@ -1711,6 +1711,21 @@ def analyze_text():
|
|
| 1711 |
f"'{d.get('original','')}' → '{d.get('correction','')}' — not a safe punctuation change"
|
| 1712 |
)
|
| 1713 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1714 |
ctx.add_patch(
|
| 1715 |
'punctuation', d['start'], d['end'],
|
| 1716 |
d['correction'], confidence=0.8
|
|
|
|
| 1711 |
f"'{d.get('original','')}' → '{d.get('correction','')}' — not a safe punctuation change"
|
| 1712 |
)
|
| 1713 |
continue
|
| 1714 |
+
# ── Duplicate punctuation guard ──
|
| 1715 |
+
# Reject corrections that just append punctuation to already-punctuated text
|
| 1716 |
+
# e.g. "الحديقة." → "الحديقة.." or "..." → "...."
|
| 1717 |
+
import re as _re2
|
| 1718 |
+
orig_txt = d.get('original', '')
|
| 1719 |
+
corr_txt = d.get('correction', '')
|
| 1720 |
+
_PUNC_CHARS = set('.,،؛:!?؟…。')
|
| 1721 |
+
if orig_txt and corr_txt and len(corr_txt) > len(orig_txt):
|
| 1722 |
+
suffix_added = corr_txt[len(orig_txt):]
|
| 1723 |
+
if all(c in _PUNC_CHARS for c in suffix_added) and orig_txt[-1] in _PUNC_CHARS:
|
| 1724 |
+
logger.info(
|
| 1725 |
+
f"[PUNC-DUP] Rejected duplicate punctuation [{d['start']}:{d['end']}] "
|
| 1726 |
+
f"'{orig_txt}' → '{corr_txt}' — already has punctuation"
|
| 1727 |
+
)
|
| 1728 |
+
continue
|
| 1729 |
ctx.add_patch(
|
| 1730 |
'punctuation', d['start'], d['end'],
|
| 1731 |
d['correction'], confidence=0.8
|
src/css/components.css
CHANGED
|
@@ -76,6 +76,40 @@
|
|
| 76 |
font-size: 0.9em;
|
| 77 |
}
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
.footer-external-link {
|
| 80 |
color: var(--color-text-secondary);
|
| 81 |
}
|
|
|
|
| 76 |
font-size: 0.9em;
|
| 77 |
}
|
| 78 |
|
| 79 |
+
.nav-bayyinah-link {
|
| 80 |
+
display: inline-flex;
|
| 81 |
+
align-items: center;
|
| 82 |
+
gap: 6px;
|
| 83 |
+
padding: 5px 14px;
|
| 84 |
+
border-radius: 20px;
|
| 85 |
+
font-size: 0.8rem;
|
| 86 |
+
font-weight: 600;
|
| 87 |
+
color: #14919b;
|
| 88 |
+
border: 1px solid rgba(20, 145, 155, 0.25);
|
| 89 |
+
background: rgba(20, 145, 155, 0.08);
|
| 90 |
+
text-decoration: none;
|
| 91 |
+
transition: all 0.25s ease;
|
| 92 |
+
white-space: nowrap;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.nav-bayyinah-link:hover {
|
| 96 |
+
background: rgba(20, 145, 155, 0.18);
|
| 97 |
+
border-color: rgba(20, 145, 155, 0.5);
|
| 98 |
+
box-shadow: 0 0 12px rgba(20, 145, 155, 0.2);
|
| 99 |
+
transform: translateY(-1px);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.nav-bayyinah-arrow {
|
| 103 |
+
opacity: 0.5;
|
| 104 |
+
transition: opacity 0.2s, transform 0.2s;
|
| 105 |
+
font-size: 0.85em;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.nav-bayyinah-link:hover .nav-bayyinah-arrow {
|
| 109 |
+
opacity: 1;
|
| 110 |
+
transform: translate(1px, -1px);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
.footer-external-link {
|
| 114 |
color: var(--color-text-secondary);
|
| 115 |
}
|
src/index.html
CHANGED
|
@@ -59,14 +59,14 @@
|
|
| 59 |
<button id="mobile-menu-btn" class="mobile-menu-btn md:hidden" aria-label="فتح القائمة" aria-expanded="false" aria-controls="mobile-drawer">
|
| 60 |
<svg width="22" height="22" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/></svg>
|
| 61 |
</button>
|
| 62 |
-
<button onclick="showPage('home')" class="flex items-center gap-3" style="background:none;border:none;cursor:pointer;" aria-label="الرئيسية"><span id="nav-brand" class="text-xl md:text-2xl font-bold text-gradient">بيان</span></button>
|
| 63 |
</div>
|
| 64 |
<div class="hidden md:flex items-center gap-8">
|
| 65 |
<button onclick="showPage('home')" class="nav-link active text-base font-medium" data-page="home">الرئيسية</button>
|
| 66 |
<button onclick="showPage('features')" class="nav-link text-base font-medium" data-page="features">الميزات</button>
|
| 67 |
<button onclick="showPage('editor')" class="nav-link text-base font-medium" data-page="editor">المحرر</button>
|
| 68 |
<button onclick="showPage('pricing')" class="nav-link text-base font-medium" data-page="pricing">الأسعار</button>
|
| 69 |
-
<a href="https://bayyinah-alpha.vercel.app/" class="nav-
|
| 70 |
</div>
|
| 71 |
<div class="flex items-center gap-2 md:gap-3">
|
| 72 |
<div id="auth-menu-wrap" class="auth-menu-wrap is-hidden">
|
|
@@ -205,9 +205,9 @@
|
|
| 205 |
<div class="w-20"></div>
|
| 206 |
</div><!-- Mock Editor Content -->
|
| 207 |
<div class="p-8 editor-content text-right text-lg" dir="rtl" style="background: var(--surface-color); color: var(--text-color); min-height: 300px;">
|
| 208 |
-
<p class="mb-4">تعتبر اللغة العربية من أجمل <span class="spelling-error">اللغاة</span> في العالم، وهي لغة <span class="spelling-error">القرأن</span> الكريم<span class="punctuation-suggestion">.</span></p>
|
| 209 |
<p class="mb-4">الطالبات <span class="grammar-error">ذهبوا</span> إلى المكتبة لأن <span class="spelling-error">الأمتحان</span> قريب جداً<span class="punctuation-suggestion">.</span></p>
|
| 210 |
-
<p>محرر بيان يساعدك على كتابة نصوص عربية <span class="spelling-error">صحيحه</span> بكل سهولة
|
| 211 |
</div><!-- Mock Stats Bar -->
|
| 212 |
<div class="flex items-center justify-between p-4 border-t" style="border-color: rgba(255, 255, 255, 0.1);">
|
| 213 |
<div class="flex items-center gap-6">
|
|
@@ -218,7 +218,7 @@
|
|
| 218 |
<div class="w-3 h-3 rounded-full" style="background: #fbbf24;"></div><span class="text-sm" style="color: var(--text-secondary);">١ نحوي</span>
|
| 219 |
</div>
|
| 220 |
<div class="flex items-center gap-2">
|
| 221 |
-
<div class="w-3 h-3 rounded-full" style="background: #22c55e;"></div><span class="text-sm" style="color: var(--text-secondary);">
|
| 222 |
</div>
|
| 223 |
</div>
|
| 224 |
<div class="flex items-center gap-2"><span class="text-2xl font-bold text-gradient">٧٥</span> <span class="text-sm" style="color: var(--text-secondary);">التقييم</span>
|
|
|
|
| 59 |
<button id="mobile-menu-btn" class="mobile-menu-btn md:hidden" aria-label="فتح القائمة" aria-expanded="false" aria-controls="mobile-drawer">
|
| 60 |
<svg width="22" height="22" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/></svg>
|
| 61 |
</button>
|
| 62 |
+
<button onclick="showPage('home')" class="flex items-center gap-3" style="background:none;border:none;cursor:pointer;" aria-label="الرئيسية"><svg width="22" height="22" fill="none" stroke="url(#navGrad)" viewBox="0 0 24 24" style="flex-shrink:0;"><defs><linearGradient id="navGrad" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color:var(--color-primary)"/><stop offset="100%" style="stop-color:var(--color-secondary)"/></linearGradient></defs><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/></svg><span id="nav-brand" class="text-xl md:text-2xl font-bold text-gradient">بيان</span></button>
|
| 63 |
</div>
|
| 64 |
<div class="hidden md:flex items-center gap-8">
|
| 65 |
<button onclick="showPage('home')" class="nav-link active text-base font-medium" data-page="home">الرئيسية</button>
|
| 66 |
<button onclick="showPage('features')" class="nav-link text-base font-medium" data-page="features">الميزات</button>
|
| 67 |
<button onclick="showPage('editor')" class="nav-link text-base font-medium" data-page="editor">المحرر</button>
|
| 68 |
<button onclick="showPage('pricing')" class="nav-link text-base font-medium" data-page="pricing">الأسعار</button>
|
| 69 |
+
<a href="https://bayyinah-alpha.vercel.app/" class="nav-bayyinah-link" target="_blank" rel="noopener noreferrer" aria-label="بَيِّنَة — مساعد ذكي للإجابة عن أسئلة القرآن والحديث وقصص الأنبياء"><svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24" style="flex-shrink:0;"><path d="M12 7v14"/><path d="M16 12h2"/><path d="M16 8h2"/><path d="M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"/><path d="M6 12h2"/><path d="M6 8h2"/></svg> بَيِّنَة <span class="nav-bayyinah-arrow">↗</span></a>
|
| 70 |
</div>
|
| 71 |
<div class="flex items-center gap-2 md:gap-3">
|
| 72 |
<div id="auth-menu-wrap" class="auth-menu-wrap is-hidden">
|
|
|
|
| 205 |
<div class="w-20"></div>
|
| 206 |
</div><!-- Mock Editor Content -->
|
| 207 |
<div class="p-8 editor-content text-right text-lg" dir="rtl" style="background: var(--surface-color); color: var(--text-color); min-height: 300px;">
|
| 208 |
+
<p class="mb-4">تعتبر اللغة العربية من أجمل <span class="spelling-error">اللغاة</span> في العالم<span class="punctuation-suggestion">،</span> وهي لغة <span class="spelling-error">القرأن</span> الكريم<span class="punctuation-suggestion">.</span></p>
|
| 209 |
<p class="mb-4">الطالبات <span class="grammar-error">ذهبوا</span> إلى المكتبة لأن <span class="spelling-error">الأمتحان</span> قريب جداً<span class="punctuation-suggestion">.</span></p>
|
| 210 |
+
<p>محرر بيان يساعدك على كتابة نصوص عربية <span class="spelling-error">صحيحه</span> بكل <span style="color: var(--text-secondary); opacity: 0.4; font-style: italic; border-bottom: 1px dashed rgba(107,163,224,0.3);">سهولة ويسر وإتقان</span></p>
|
| 211 |
</div><!-- Mock Stats Bar -->
|
| 212 |
<div class="flex items-center justify-between p-4 border-t" style="border-color: rgba(255, 255, 255, 0.1);">
|
| 213 |
<div class="flex items-center gap-6">
|
|
|
|
| 218 |
<div class="w-3 h-3 rounded-full" style="background: #fbbf24;"></div><span class="text-sm" style="color: var(--text-secondary);">١ نحوي</span>
|
| 219 |
</div>
|
| 220 |
<div class="flex items-center gap-2">
|
| 221 |
+
<div class="w-3 h-3 rounded-full" style="background: #22c55e;"></div><span class="text-sm" style="color: var(--text-secondary);">٣ ترقيم</span>
|
| 222 |
</div>
|
| 223 |
</div>
|
| 224 |
<div class="flex items-center gap-2"><span class="text-2xl font-bold text-gradient">٧٥</span> <span class="text-sm" style="color: var(--text-secondary);">التقييم</span>
|
src/js/editor.js
CHANGED
|
@@ -363,19 +363,19 @@ function showTooltip(element) {
|
|
| 363 |
const alternativesEl = document.getElementById('tooltip-alternatives');
|
| 364 |
|
| 365 |
const typeMap = {
|
| 366 |
-
spelling: { label: 'خطأ إملائي'
|
| 367 |
-
grammar: { label: 'خطأ نحوي'
|
| 368 |
-
punctuation: { label: 'علامات ترقيم'
|
| 369 |
};
|
| 370 |
|
| 371 |
if (typeEl) {
|
| 372 |
-
const typeInfo = typeMap[suggestion.type] || { label: suggestion.type
|
| 373 |
-
typeEl.innerHTML =
|
| 374 |
typeEl.className = `popover-type popover-type--${suggestion.type}`;
|
| 375 |
}
|
| 376 |
|
| 377 |
if (originalEl) {
|
| 378 |
-
originalEl.innerHTML = `<span class="popover-original-label">ال
|
| 379 |
}
|
| 380 |
|
| 381 |
// Render alternatives
|
|
@@ -397,12 +397,6 @@ function showTooltip(element) {
|
|
| 397 |
});
|
| 398 |
// Render keep button at end
|
| 399 |
html += `<button class="popover-alt-btn popover-alt-keep" data-alt-correction="${escapeHtml(suggestion.original)}" type="button">إبقاء كما هي</button>`;
|
| 400 |
-
// Render feedback buttons
|
| 401 |
-
html += `<div class="popover-feedback">
|
| 402 |
-
<span class="popover-feedback-label">هل الاقتراح مفيد؟</span>
|
| 403 |
-
<button class="popover-feedback-btn popover-feedback-yes" data-feedback="yes" type="button" title="مفيد">👍</button>
|
| 404 |
-
<button class="popover-feedback-btn popover-feedback-no" data-feedback="no" type="button" title="غير مفيد">👎</button>
|
| 405 |
-
</div>`;
|
| 406 |
alternativesEl.innerHTML = html;
|
| 407 |
|
| 408 |
// Bind click events for alternatives
|
|
@@ -416,15 +410,6 @@ function showTooltip(element) {
|
|
| 416 |
}
|
| 417 |
});
|
| 418 |
});
|
| 419 |
-
|
| 420 |
-
// Bind feedback buttons
|
| 421 |
-
alternativesEl.querySelectorAll('.popover-feedback-btn').forEach(btn => {
|
| 422 |
-
btn.addEventListener('click', () => {
|
| 423 |
-
const helpful = btn.dataset.feedback === 'yes';
|
| 424 |
-
_sendFeedback(suggestion, helpful);
|
| 425 |
-
btn.closest('.popover-feedback').innerHTML = '<span class="popover-feedback-thanks">شكراً لملاحظاتك! ✓</span>';
|
| 426 |
-
});
|
| 427 |
-
});
|
| 428 |
}
|
| 429 |
|
| 430 |
const rect = element.getBoundingClientRect();
|
|
|
|
| 363 |
const alternativesEl = document.getElementById('tooltip-alternatives');
|
| 364 |
|
| 365 |
const typeMap = {
|
| 366 |
+
spelling: { label: 'خطأ إملائي' },
|
| 367 |
+
grammar: { label: 'خطأ نحوي' },
|
| 368 |
+
punctuation: { label: 'علامات ترقيم' }
|
| 369 |
};
|
| 370 |
|
| 371 |
if (typeEl) {
|
| 372 |
+
const typeInfo = typeMap[suggestion.type] || { label: suggestion.type };
|
| 373 |
+
typeEl.innerHTML = typeInfo.label;
|
| 374 |
typeEl.className = `popover-type popover-type--${suggestion.type}`;
|
| 375 |
}
|
| 376 |
|
| 377 |
if (originalEl) {
|
| 378 |
+
originalEl.innerHTML = `<span class="popover-original-label">الكلمة:</span> <span class="popover-original-word">${escapeHtml(suggestion.original)}</span>`;
|
| 379 |
}
|
| 380 |
|
| 381 |
// Render alternatives
|
|
|
|
| 397 |
});
|
| 398 |
// Render keep button at end
|
| 399 |
html += `<button class="popover-alt-btn popover-alt-keep" data-alt-correction="${escapeHtml(suggestion.original)}" type="button">إبقاء كما هي</button>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
alternativesEl.innerHTML = html;
|
| 401 |
|
| 402 |
// Bind click events for alternatives
|
|
|
|
| 410 |
}
|
| 411 |
});
|
| 412 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
}
|
| 414 |
|
| 415 |
const rect = element.getBoundingClientRect();
|
src/nlp/spelling/araspell_rules.py
CHANGED
|
@@ -184,6 +184,16 @@ class AraSpellPostProcessor:
|
|
| 184 |
Also handles prefixed words: و/ف/ب/ك/ل + whitelist word.
|
| 185 |
e.g. واصدقائي → وأصدقائي, بالاسعار → بالأسعار
|
| 186 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
words = text.split()
|
| 188 |
result = []
|
| 189 |
for word in words:
|
|
@@ -192,6 +202,11 @@ class AraSpellPostProcessor:
|
|
| 192 |
result.append(AraSpellPostProcessor.HAMZA_WHITELIST[word])
|
| 193 |
continue
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
# Try stripping common prefixes and looking up the remainder
|
| 196 |
fixed = False
|
| 197 |
for prefix in AraSpellPostProcessor.HAMZA_PREFIXES:
|
|
|
|
| 184 |
Also handles prefixed words: و/ف/ب/ك/ل + whitelist word.
|
| 185 |
e.g. واصدقائي → وأصدقائي, بالاسعار → بالأسعار
|
| 186 |
"""
|
| 187 |
+
# Words that must NOT be decomposed by prefix stripping
|
| 188 |
+
# كان (was) ≠ ك+أن, بان (appeared) ≠ ب+أن, لان (softened) ≠ ل+أن, فان (van) ≠ ف+أن
|
| 189 |
+
HAMZA_PREFIX_BLACKLIST = {
|
| 190 |
+
'كان', 'كانت', 'كانوا', 'كانا',
|
| 191 |
+
'بان', 'بانت', 'بانوا',
|
| 192 |
+
'لان', 'لانت',
|
| 193 |
+
'فان', 'فانت',
|
| 194 |
+
'وان', 'وانت',
|
| 195 |
+
'كانه', 'كانها', 'كانهم',
|
| 196 |
+
}
|
| 197 |
words = text.split()
|
| 198 |
result = []
|
| 199 |
for word in words:
|
|
|
|
| 202 |
result.append(AraSpellPostProcessor.HAMZA_WHITELIST[word])
|
| 203 |
continue
|
| 204 |
|
| 205 |
+
# Skip words in the blacklist — they are valid as-is
|
| 206 |
+
if word in HAMZA_PREFIX_BLACKLIST:
|
| 207 |
+
result.append(word)
|
| 208 |
+
continue
|
| 209 |
+
|
| 210 |
# Try stripping common prefixes and looking up the remainder
|
| 211 |
fixed = False
|
| 212 |
for prefix in AraSpellPostProcessor.HAMZA_PREFIXES:
|