Spaces:
Running
Running
Refine spellchecker highlights and controls
Browse files- README.md +2 -2
- static/index.html +22 -22
- static/style.css +14 -7
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: ✍️
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: gray
|
|
@@ -10,7 +10,7 @@ pinned: false
|
|
| 10 |
private: true
|
| 11 |
---
|
| 12 |
|
| 13 |
-
#
|
| 14 |
|
| 15 |
A focused grammar and spelling correction demo powered by [`LiquidAI/LFM2.5-Spellchecker-350M`](https://huggingface.co/LiquidAI/LFM2.5-Spellchecker-350M).
|
| 16 |
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Liquid spellchecker
|
| 3 |
emoji: ✍️
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: gray
|
|
|
|
| 10 |
private: true
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Liquid spellchecker
|
| 14 |
|
| 15 |
A focused grammar and spelling correction demo powered by [`LiquidAI/LFM2.5-Spellchecker-350M`](https://huggingface.co/LiquidAI/LFM2.5-Spellchecker-350M).
|
| 16 |
|
static/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 6 |
-
<title>
|
| 7 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 9 |
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
|
@@ -18,8 +18,8 @@
|
|
| 18 |
<body>
|
| 19 |
<div class="wrap">
|
| 20 |
<header class="site-intro">
|
| 21 |
-
<h1>
|
| 22 |
-
<p class="sub">Correct spelling and grammar with
|
| 23 |
</header>
|
| 24 |
|
| 25 |
<section class="model-strip is-loading" id="model-strip" aria-label="Model status">
|
|
@@ -41,8 +41,7 @@
|
|
| 41 |
<section class="spell-workspace" id="spell-workspace" aria-label="Spellchecker">
|
| 42 |
<article class="workspace-card input-panel">
|
| 43 |
<div class="panel-header">
|
| 44 |
-
<
|
| 45 |
-
<div class="activity-pill is-idle" id="activity"><span class="activity-dot" aria-hidden="true"></span><span id="activity-label">Ready</span></div>
|
| 46 |
</div>
|
| 47 |
|
| 48 |
<div class="editor-stage input-stage">
|
|
@@ -53,23 +52,26 @@
|
|
| 53 |
|
| 54 |
<div class="input-meta"><span id="count">0 characters</span><span>Checks after 650 ms</span></div>
|
| 55 |
|
| 56 |
-
<
|
| 57 |
-
<
|
| 58 |
-
|
| 59 |
-
<
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
<
|
| 64 |
-
<
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
| 68 |
</article>
|
| 69 |
|
| 70 |
<article class="workspace-card output-panel">
|
| 71 |
<div class="panel-header output-heading">
|
| 72 |
-
<
|
| 73 |
<button type="button" class="copy-button" id="copy" disabled>Copy</button>
|
| 74 |
</div>
|
| 75 |
|
|
@@ -84,7 +86,7 @@
|
|
| 84 |
</div>
|
| 85 |
|
| 86 |
<div class="stats-grid" id="stats" aria-live="polite">
|
| 87 |
-
<div class="
|
| 88 |
<div class="stat-card"><span>Edits</span><strong id="stat-edits">—</strong></div>
|
| 89 |
<div class="stat-card"><span>Latency</span><strong id="stat-latency">—</strong></div>
|
| 90 |
<div class="stat-card"><span>Characters</span><strong id="stat-characters">—</strong></div>
|
|
@@ -207,7 +209,6 @@ function resetResult() {
|
|
| 207 |
setActivity("idle", "Ready");
|
| 208 |
workspace.classList.remove("is-checking", "is-complete");
|
| 209 |
$("stats").classList.remove("has-result");
|
| 210 |
-
$("stat-result").textContent = "—";
|
| 211 |
$("stat-edits").textContent = "—";
|
| 212 |
$("stat-latency").textContent = "—";
|
| 213 |
$("stat-characters").textContent = "—";
|
|
@@ -246,8 +247,6 @@ async function correct() {
|
|
| 246 |
stats.classList.remove("has-result");
|
| 247 |
void stats.offsetWidth;
|
| 248 |
stats.classList.add("has-result");
|
| 249 |
-
$("stat-result").textContent = data.changed ? "Corrected" : "Clean";
|
| 250 |
-
$("stat-result").parentElement.classList.toggle("is-clean", !data.changed);
|
| 251 |
$("stat-edits").textContent = String(edits);
|
| 252 |
$("stat-latency").textContent = `${Math.round(latency)} ms`;
|
| 253 |
$("stat-characters").textContent = String(text.length);
|
|
@@ -271,6 +270,7 @@ for (const range of [$("mep"), $("mit")]) {
|
|
| 271 |
range.addEventListener("input", event => {
|
| 272 |
setRangeFill(event.target);
|
| 273 |
$(event.target.id === "mep" ? "mepv" : "mitv").textContent = event.target.id === "mep" ? (+event.target.value).toFixed(2) : event.target.value;
|
|
|
|
| 274 |
schedule(0);
|
| 275 |
});
|
| 276 |
}
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 6 |
+
<title>Liquid spellchecker</title>
|
| 7 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 9 |
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
|
|
|
| 18 |
<body>
|
| 19 |
<div class="wrap">
|
| 20 |
<header class="site-intro">
|
| 21 |
+
<h1>Liquid <em>spellchecker</em></h1>
|
| 22 |
+
<p class="sub">Correct English spelling and grammar privately with LFM2.5.</p>
|
| 23 |
</header>
|
| 24 |
|
| 25 |
<section class="model-strip is-loading" id="model-strip" aria-label="Model status">
|
|
|
|
| 41 |
<section class="spell-workspace" id="spell-workspace" aria-label="Spellchecker">
|
| 42 |
<article class="workspace-card input-panel">
|
| 43 |
<div class="panel-header">
|
| 44 |
+
<h2>Input</h2>
|
|
|
|
| 45 |
</div>
|
| 46 |
|
| 47 |
<div class="editor-stage input-stage">
|
|
|
|
| 52 |
|
| 53 |
<div class="input-meta"><span id="count">0 characters</span><span>Checks after 650 ms</span></div>
|
| 54 |
|
| 55 |
+
<details class="settings-menu">
|
| 56 |
+
<summary><span>Correction settings</span><span class="settings-value" id="settings-value">0.00 threshold · 3 passes</span></summary>
|
| 57 |
+
<div class="settings-grid" aria-label="Correction settings">
|
| 58 |
+
<label class="setting-card" for="mep">
|
| 59 |
+
<span class="setting-copy"><span>Confidence threshold</span><output id="mepv" for="mep">0.00</output></span>
|
| 60 |
+
<input type="range" id="mep" min="0" max="1" step="0.05" value="0">
|
| 61 |
+
<span class="setting-scale"><span>More corrections</span><span>More precise</span></span>
|
| 62 |
+
</label>
|
| 63 |
+
<label class="setting-card" for="mit">
|
| 64 |
+
<span class="setting-copy"><span>Correction passes</span><output id="mitv" for="mit">3</output></span>
|
| 65 |
+
<input type="range" id="mit" min="1" max="5" step="1" value="3">
|
| 66 |
+
<span class="setting-scale"><span>1 pass</span><span>5 passes</span></span>
|
| 67 |
+
</label>
|
| 68 |
+
</div>
|
| 69 |
+
</details>
|
| 70 |
</article>
|
| 71 |
|
| 72 |
<article class="workspace-card output-panel">
|
| 73 |
<div class="panel-header output-heading">
|
| 74 |
+
<h2>Corrected</h2>
|
| 75 |
<button type="button" class="copy-button" id="copy" disabled>Copy</button>
|
| 76 |
</div>
|
| 77 |
|
|
|
|
| 86 |
</div>
|
| 87 |
|
| 88 |
<div class="stats-grid" id="stats" aria-live="polite">
|
| 89 |
+
<div class="result-slot"><div class="activity-pill is-idle" id="activity"><span class="activity-dot" aria-hidden="true"></span><span id="activity-label">Ready</span></div></div>
|
| 90 |
<div class="stat-card"><span>Edits</span><strong id="stat-edits">—</strong></div>
|
| 91 |
<div class="stat-card"><span>Latency</span><strong id="stat-latency">—</strong></div>
|
| 92 |
<div class="stat-card"><span>Characters</span><strong id="stat-characters">—</strong></div>
|
|
|
|
| 209 |
setActivity("idle", "Ready");
|
| 210 |
workspace.classList.remove("is-checking", "is-complete");
|
| 211 |
$("stats").classList.remove("has-result");
|
|
|
|
| 212 |
$("stat-edits").textContent = "—";
|
| 213 |
$("stat-latency").textContent = "—";
|
| 214 |
$("stat-characters").textContent = "—";
|
|
|
|
| 247 |
stats.classList.remove("has-result");
|
| 248 |
void stats.offsetWidth;
|
| 249 |
stats.classList.add("has-result");
|
|
|
|
|
|
|
| 250 |
$("stat-edits").textContent = String(edits);
|
| 251 |
$("stat-latency").textContent = `${Math.round(latency)} ms`;
|
| 252 |
$("stat-characters").textContent = String(text.length);
|
|
|
|
| 270 |
range.addEventListener("input", event => {
|
| 271 |
setRangeFill(event.target);
|
| 272 |
$(event.target.id === "mep" ? "mepv" : "mitv").textContent = event.target.id === "mep" ? (+event.target.value).toFixed(2) : event.target.value;
|
| 273 |
+
$("settings-value").textContent = `${(+$('mep').value).toFixed(2)} threshold · ${$('mit').value} ${$('mit').value === '1' ? 'pass' : 'passes'}`;
|
| 274 |
schedule(0);
|
| 275 |
});
|
| 276 |
}
|
static/style.css
CHANGED
|
@@ -106,9 +106,8 @@ main { display:flex; min-height:0; flex:0 0 auto; flex-direction:column; margin-
|
|
| 106 |
.spell-workspace { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:stretch; gap:18px; }
|
| 107 |
.workspace-card { position:relative; min-width:0; padding:20px; overflow:hidden; border:1px solid var(--border); border-radius:12px; background:var(--paper); }
|
| 108 |
.input-panel,.output-panel { display:flex; flex-direction:column; }
|
| 109 |
-
.panel-header { display:flex; align-items:
|
| 110 |
-
.panel-header h2 { margin:0
|
| 111 |
-
.panel-header p { margin:0; color:var(--neutral-500); font-size:13px; line-height:1.4; }
|
| 112 |
|
| 113 |
.activity-pill { display:flex; align-items:center; gap:8px; flex:none; padding:7px 10px; border:1px solid var(--border); border-radius:999px; background:var(--neutral-50); color:var(--neutral-500); font-size:12px; font-weight:600; white-space:nowrap; transition:all .2s ease; }
|
| 114 |
.activity-dot { width:8px; height:8px; flex:none; border-radius:50%; background:var(--neutral-300); }
|
|
@@ -133,7 +132,15 @@ main { display:flex; min-height:0; flex:0 0 auto; flex-direction:column; margin-
|
|
| 133 |
.is-complete .output-stage { animation:editor-complete .62s ease both; }
|
| 134 |
|
| 135 |
.input-meta { display:flex; justify-content:space-between; gap:14px; margin:8px 2px 0; color:var(--neutral-300); font:500 10px/1.3 var(--mono); }
|
| 136 |
-
.settings-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
.setting-card { display:block; min-width:0; padding:12px 13px 9px; border:1px solid var(--border); border-radius:10px; background:var(--neutral-50); }
|
| 138 |
.setting-copy { display:flex; align-items:baseline; justify-content:space-between; gap:10px; color:var(--neutral-500); font:600 10px/1.25 var(--mono); letter-spacing:.055em; text-transform:uppercase; }
|
| 139 |
.setting-copy output { color:var(--purple); font:700 12px/1 var(--mono); letter-spacing:0; font-variant-numeric:tabular-nums; }
|
|
@@ -151,7 +158,7 @@ input[type=range]::-moz-range-thumb { width:11px; height:11px; border:3px solid
|
|
| 151 |
.copy-button.copied { border-color:rgba(45,189,112,.2); background:rgba(45,189,112,.055); color:#188e50; animation:copy-pop .36s ease; }
|
| 152 |
|
| 153 |
mark { position:relative; z-index:0; display:inline-block; padding:0 .045em; background:transparent; color:inherit; isolation:isolate; }
|
| 154 |
-
mark::before { content:""; position:absolute; z-index:-1; right:-.08em; bottom:.08em; left:-.08em;
|
| 155 |
mark::after { content:""; position:absolute; z-index:-1; top:18%; bottom:12%; left:-12%; width:24%; opacity:0; background:linear-gradient(90deg,transparent,rgba(255,255,255,.72),transparent); filter:blur(2px); transform:skewX(-12deg); animation:marker-glint .62s ease-out both; animation-delay:calc(var(--edit-index)*55ms); }
|
| 156 |
.deleted { display:inline-block; padding:0 .08em; border-radius:4px; background:rgba(228,84,84,.075); color:#b83a3a; text-decoration:line-through; text-decoration-color:var(--red); text-decoration-thickness:2px; animation:deleted-in .42s cubic-bezier(.2,.8,.2,1) both; animation-delay:calc(var(--edit-index)*55ms); }
|
| 157 |
|
|
@@ -164,8 +171,8 @@ mark::after { content:""; position:absolute; z-index:-1; top:18%; bottom:12%; le
|
|
| 164 |
.stat-card { min-width:0; padding:10px 12px; border:1px solid var(--border); border-radius:9px; background:var(--paper); }
|
| 165 |
.stat-card span { display:block; margin-bottom:5px; color:var(--neutral-500); font:600 9px/1 var(--mono); letter-spacing:.08em; text-transform:uppercase; }
|
| 166 |
.stat-card strong { display:block; overflow:hidden; color:var(--neutral-700); font:650 14px/1.25 var(--sans); text-overflow:ellipsis; white-space:nowrap; font-variant-numeric:tabular-nums; }
|
| 167 |
-
.
|
| 168 |
-
.
|
| 169 |
.stats-grid.has-result .stat-card { animation:stat-rise .42s cubic-bezier(.2,.8,.2,1) both; }
|
| 170 |
.stats-grid.has-result .stat-card:nth-child(2) { animation-delay:35ms; }
|
| 171 |
.stats-grid.has-result .stat-card:nth-child(3) { animation-delay:70ms; }
|
|
|
|
| 106 |
.spell-workspace { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:stretch; gap:18px; }
|
| 107 |
.workspace-card { position:relative; min-width:0; padding:20px; overflow:hidden; border:1px solid var(--border); border-radius:12px; background:var(--paper); }
|
| 108 |
.input-panel,.output-panel { display:flex; flex-direction:column; }
|
| 109 |
+
.panel-header { display:flex; min-height:31px; align-items:center; justify-content:space-between; gap:16px; margin-bottom:12px; }
|
| 110 |
+
.panel-header h2 { margin:0; color:var(--neutral-500); font:600 12px/1.25 var(--mono); letter-spacing:.08em; text-transform:uppercase; }
|
|
|
|
| 111 |
|
| 112 |
.activity-pill { display:flex; align-items:center; gap:8px; flex:none; padding:7px 10px; border:1px solid var(--border); border-radius:999px; background:var(--neutral-50); color:var(--neutral-500); font-size:12px; font-weight:600; white-space:nowrap; transition:all .2s ease; }
|
| 113 |
.activity-dot { width:8px; height:8px; flex:none; border-radius:50%; background:var(--neutral-300); }
|
|
|
|
| 132 |
.is-complete .output-stage { animation:editor-complete .62s ease both; }
|
| 133 |
|
| 134 |
.input-meta { display:flex; justify-content:space-between; gap:14px; margin:8px 2px 0; color:var(--neutral-300); font:500 10px/1.3 var(--mono); }
|
| 135 |
+
.settings-menu { margin-top:12px; }
|
| 136 |
+
.settings-menu > summary { display:flex; align-items:center; justify-content:space-between; gap:14px; min-height:44px; padding:11px 13px; border:1px solid var(--border); border-radius:10px; background:var(--neutral-50); color:var(--neutral-500); font:600 10px/1.25 var(--mono); letter-spacing:.055em; text-transform:uppercase; cursor:pointer; list-style:none; transition:border-color .16s,background .16s,color .16s; }
|
| 137 |
+
.settings-menu > summary::-webkit-details-marker { display:none; }
|
| 138 |
+
.settings-menu > summary::after { content:"⌄"; flex:none; color:var(--purple); font-size:16px; line-height:1; transition:transform .2s ease; }
|
| 139 |
+
.settings-menu > summary:hover { border-color:rgba(108,79,224,.28); background:rgba(108,79,224,.025); color:var(--neutral-700); }
|
| 140 |
+
.settings-menu[open] > summary { border-radius:10px 10px 0 0; color:var(--neutral-700); }
|
| 141 |
+
.settings-menu[open] > summary::after { transform:rotate(180deg); }
|
| 142 |
+
.settings-value { margin-left:auto; color:var(--purple); font-size:9px; letter-spacing:0; text-transform:none; font-variant-numeric:tabular-nums; }
|
| 143 |
+
.settings-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; padding:8px; border:1px solid var(--border); border-top:0; border-radius:0 0 10px 10px; background:var(--neutral-50); }
|
| 144 |
.setting-card { display:block; min-width:0; padding:12px 13px 9px; border:1px solid var(--border); border-radius:10px; background:var(--neutral-50); }
|
| 145 |
.setting-copy { display:flex; align-items:baseline; justify-content:space-between; gap:10px; color:var(--neutral-500); font:600 10px/1.25 var(--mono); letter-spacing:.055em; text-transform:uppercase; }
|
| 146 |
.setting-copy output { color:var(--purple); font:700 12px/1 var(--mono); letter-spacing:0; font-variant-numeric:tabular-nums; }
|
|
|
|
| 158 |
.copy-button.copied { border-color:rgba(45,189,112,.2); background:rgba(45,189,112,.055); color:#188e50; animation:copy-pop .36s ease; }
|
| 159 |
|
| 160 |
mark { position:relative; z-index:0; display:inline-block; padding:0 .045em; background:transparent; color:inherit; isolation:isolate; }
|
| 161 |
+
mark::before { content:""; position:absolute; z-index:-1; top:.12em; right:-.08em; bottom:.08em; left:-.08em; border-radius:2px 5px 3px 2px; background:radial-gradient(ellipse at 18% 42%,rgba(255,255,255,.32) 0 8%,transparent 9% 100%),repeating-linear-gradient(176deg,rgba(205,130,240,.46) 0 2px,rgba(177,111,229,.38) 2px 5px,rgba(213,151,241,.48) 5px 8px); box-shadow:inset 0 1px rgba(255,255,255,.32); clip-path:polygon(0 8%,3% 2%,28% 6%,52% 1%,78% 5%,100% 0,98% 94%,72% 98%,42% 95%,17% 100%,1% 94%); mix-blend-mode:multiply; transform:scaleX(0) rotate(-.35deg); transform-origin:left center; animation:marker-stroke .62s cubic-bezier(.18,.72,.18,1) both; animation-delay:calc(var(--edit-index)*55ms); }
|
| 162 |
mark::after { content:""; position:absolute; z-index:-1; top:18%; bottom:12%; left:-12%; width:24%; opacity:0; background:linear-gradient(90deg,transparent,rgba(255,255,255,.72),transparent); filter:blur(2px); transform:skewX(-12deg); animation:marker-glint .62s ease-out both; animation-delay:calc(var(--edit-index)*55ms); }
|
| 163 |
.deleted { display:inline-block; padding:0 .08em; border-radius:4px; background:rgba(228,84,84,.075); color:#b83a3a; text-decoration:line-through; text-decoration-color:var(--red); text-decoration-thickness:2px; animation:deleted-in .42s cubic-bezier(.2,.8,.2,1) both; animation-delay:calc(var(--edit-index)*55ms); }
|
| 164 |
|
|
|
|
| 171 |
.stat-card { min-width:0; padding:10px 12px; border:1px solid var(--border); border-radius:9px; background:var(--paper); }
|
| 172 |
.stat-card span { display:block; margin-bottom:5px; color:var(--neutral-500); font:600 9px/1 var(--mono); letter-spacing:.08em; text-transform:uppercase; }
|
| 173 |
.stat-card strong { display:block; overflow:hidden; color:var(--neutral-700); font:650 14px/1.25 var(--sans); text-overflow:ellipsis; white-space:nowrap; font-variant-numeric:tabular-nums; }
|
| 174 |
+
.result-slot { display:flex; min-width:0; align-items:stretch; }
|
| 175 |
+
.result-slot .activity-pill { width:100%; justify-content:center; border-radius:9px; }
|
| 176 |
.stats-grid.has-result .stat-card { animation:stat-rise .42s cubic-bezier(.2,.8,.2,1) both; }
|
| 177 |
.stats-grid.has-result .stat-card:nth-child(2) { animation-delay:35ms; }
|
| 178 |
.stats-grid.has-result .stat-card:nth-child(3) { animation-delay:70ms; }
|