Spaces:
Running
Running
Theme switch, A/B labels, negative-score wording, new example, footer links
Browse filesFiles changed (2)
- demo.js+34-10
- index.html+57-18
28 unmodified lines29303132333479 unmodified lines11411511611711811912012181 unmodified lines20320420520620720820921021121221321421521 unmodified lines23723823924024124224324424524624724824925025125225333 unmodified lines28728828929029129229328 unmodified lines["Complexification","The doctor told the patient not to exercise hard for a few weeks.","The physician recommended that the patient refrain from strenuous physical activity for several weeks.", ""],["Compare two candidates","Due to the inclement weather conditions, the municipal authorities decided to postpone the outdoor festival indefinitely.","Because of the bad weather, the city put off the outdoor festival.",79 unmodified linesfunction verdict(mu) {if (mu >= 0.5) return "Successful simplification";if (mu >= 0.15) return "Partial simplification";if (mu > -0.15) return "Close to a copy of the source";return "Unsuccessful: complexification, or degenerate text";}function confidence(sigma) {81 unmodified linesband.style.width = `calc(${pos(res.mu + res.sigma)} - ${pos(res.mu - res.sigma)})`;}function card(which, label, res) {const el = $(`card-${which}`);el.classList.remove("hidden");el.innerHTML = "";const title = document.createElement("div");title.className = "small muted";title.textContent = label;const big = document.createElement("div");big.className = "big";big.textContent = `μ = ${res.mu >= 0 ? "+" : "−"}${Math.abs(res.mu).toFixed(3)}`;21 unmodified linesconst resA = await scorePair(source, a);const resB = b ? await scorePair(source, b) : null;$("result").style.display = "block";$("marker-b").querySelector("span").textContent = "B";$("marker-a").querySelector("span").textContent = resB ? "A" : "μ";place("a", resA);place("b", resB);card("a", resB ? "Simplification A" : "Simplification", resA);if (resB) {card("b", "Simplification B", resB);const p = phi((resA.mu - resB.mu) / Math.sqrt(resA.sigma ** 2 + resB.sigma ** 2));$("pref").classList.remove("hidden");const pct = p > 0.999 ? "> 99.9%" : p < 0.001 ? "< 0.1%" : `${(100 * p).toFixed(1)}%`;$("pref").textContent = `Probability that A is the better simplification: ${pct} ` +"(Thurstone's model on the two scores and their uncertainties).";} else {$("card-b").classList.add("hidden");33 unmodified lines}}async function init() {setupExamples();$("score").addEventListener("click", onScore);$("forget").addEventListener("click", async () => {28 unmodified lines29303132333435363779 unmodified lines11711811912012112212312481 unmodified lines20620720820921021121221321421521621721821922022122221 unmodified lines24424524624724824925025125225325425525625725833 unmodified lines29229329429529629729829930030130230330430530630730830931031131231331431531631728 unmodified lines["Complexification","The doctor told the patient not to exercise hard for a few weeks.","The physician recommended that the patient refrain from strenuous physical activity for several weeks.", ""],["Core meaning stripped","After three weeks of tense negotiations, the city council voted seven to two on Tuesday evening to approve a 4.5 million dollar plan to repair the old stone bridge over the river, which has been closed to traffic since a flood damaged its foundations last spring.","Three weeks, Tuesday evening, the river, last spring.", ""],["Compare two candidates","Due to the inclement weather conditions, the municipal authorities decided to postpone the outdoor festival indefinitely.","Because of the bad weather, the city put off the outdoor festival.",79 unmodified linesfunction verdict(mu) {if (mu >= 0.5) return "Successful simplification";if (mu >= 0.15) return "Partial simplification";if (mu >= 0) return "Close to a copy of the source";return "Unrelated, degenerate text or complexification";}function confidence(sigma) {81 unmodified linesband.style.width = `calc(${pos(res.mu + res.sigma)} - ${pos(res.mu - res.sigma)})`;}function card(which, res) {const letter = which.toUpperCase();const el = $(`card-${which}`);el.classList.remove("hidden");el.innerHTML = "";const title = document.createElement("div");title.className = "title";const badge = document.createElement("span");badge.className = `badge badge-${which}`;badge.textContent = letter;title.append(badge, `Simplification ${letter}`);const big = document.createElement("div");big.className = "big";big.textContent = `μ = ${res.mu >= 0 ? "+" : "−"}${Math.abs(res.mu).toFixed(3)}`;21 unmodified linesconst resA = await scorePair(source, a);const resB = b ? await scorePair(source, b) : null;$("result").style.display = "block";place("a", resA);place("b", resB);card("a", resA);if (resB) {card("b", resB);const p = phi((resA.mu - resB.mu) / Math.sqrt(resA.sigma ** 2 + resB.sigma ** 2));$("pref").classList.remove("hidden");const pct = p > 0.999 ? "> 99.9%" : p < 0.001 ? "< 0.1%" : `${(100 * p).toFixed(1)}%`;$("pref").textContent = `Probability that A is a better simplification than B: ${pct} ` +"(Thurstone's model on the two scores and their uncertainties).";} else {$("card-b").classList.add("hidden");33 unmodified lines}}function setupTheme() {const buttons = document.querySelectorAll("[data-theme-choice]");const show = (choice) => buttons.forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.themeChoice === choice)));let current = "auto";try { current = localStorage.getItem("simple-theme") || "auto"; } catch { /* no storage */ }show(current);buttons.forEach((b) => b.addEventListener("click", () => {const choice = b.dataset.themeChoice;if (choice === "auto") delete document.documentElement.dataset.theme;else document.documentElement.dataset.theme = choice;try {if (choice === "auto") localStorage.removeItem("simple-theme");else localStorage.setItem("simple-theme", choice);} catch { /* no storage: the choice lasts for this visit */ }show(choice);}));}async function init() {setupTheme();setupExamples();$("score").addEventListener("click", onScore);$("forget").addEventListener("click", async () => {
5 unmodified lines678910118 unmodified lines2021222324252611 unmodified lines383940414243442 unmodified lines474849505152531 unmodified line555657585960617 unmodified lines69707172737475767778798081827 unmodified lines909192939495969798991001011021031041051061071081091104 unmodified lines1151161171181191201212 unmodified lines12412512612712812913021 unmodified lines15215315415515615715815916016142 unmodified lines2042052062072082092105 unmodified lines<title>SIMPLE metric</title><link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%232457c5'/%3E%3Cpath d='M8 21h16M8 15h11M8 9h16' stroke='white' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E"><meta name="description" content="SIMPLE: a reference-free metric for sentence simplification that also reports its own uncertainty. Try it in your browser."><style>:root {color-scheme: light;8 unmodified lines--good: #1f8a4c;--bad: #c2412d;--neutral: #8a8d93;--band: rgba(36, 87, 197, 0.18);--code-bg: #f0f0eb;--focus: #2457c5;}11 unmodified lines--good: #4cc27f;--bad: #f0806c;--neutral: #8f939a;--band: rgba(122, 162, 255, 0.22);--code-bg: #25262a;--focus: #7aa2ff;}2 unmodified linescolor-scheme: dark;--bg: #141517; --surface: #1c1d20; --surface-2: #25262a; --text: #ececea; --muted: #a2a5ab;--border: #34363b; --accent: #7aa2ff; --accent-text: #0e1220; --good: #4cc27f; --bad: #f0806c;--neutral: #8f939a; --band: rgba(122, 162, 255, 0.22); --code-bg: #25262a; --focus: #7aa2ff;}* { box-sizing: border-box; }html { -webkit-text-size-adjust: 100%; }1 unmodified linemargin: 0; background: var(--bg); color: var(--text);font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;}main { max-width: 780px; margin: 0 auto; padding: 40px 16px 64px; }h1 { font-size: 2.1rem; line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.01em; }h2 { font-size: 1.2rem; margin: 0 0 12px; }p { margin: 0 0 12px; }7 unmodified linespre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 0 0 12px; }pre code { background: none; padding: 0; }/* score scale */.scale { position: relative; height: 14px; border-radius: 7px; margin: 18px 0 6px;background: linear-gradient(90deg, var(--bad), var(--neutral) 50%, var(--good)); }.scale .band { position: absolute; top: -4px; bottom: -4px; background: var(--band); border-radius: 4px; display: none; }.scale .marker { position: absolute; top: -7px; width: 4px; height: 28px; margin-left: -2px; border-radius: 2px;background: var(--text); display: none; }.scale .marker span { position: absolute; top: -22px; left: 50%; transform: translateX(-50%);font-size: 0.75rem; font-weight: 600; white-space: nowrap; }.scale-labels { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); gap: 8px; }.scale-labels span:nth-child(2) { text-align: center; }.scale-labels span:last-child { text-align: right; }7 unmodified lines.linklike { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: 0.875rem; }.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 12px 0 6px; }.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }label { display: block; font-weight: 600; margin: 14px 0 6px; }label .muted { font-weight: 400; }textarea { width: 100%; min-height: 76px; resize: vertical; font: inherit; color: var(--text); background: var(--bg);border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }.examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }.examples button { padding: 5px 10px; font-size: 0.85rem; border-radius: 999px; }.result { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); display: none; }.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }.score-card { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }.score-card .big { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }.score-card .verdict { font-weight: 600; }.error { color: var(--bad); font-weight: 600; }.hidden { display: none !important; }footer { color: var(--muted); font-size: 0.85rem; text-align: center; margin-top: 28px; }@media (max-width: 520px) {h1 { font-size: 1.7rem; }section { padding: 16px; }4 unmodified lines<body><main><header><h1>SIMPLE</h1><p class="lead">A reference-free metric for sentence simplification that also says how sure it is.Give it a sentence and a simplification of it; no reference simplification needed.</p></header>2 unmodified lines<h2 id="read-title">Reading the score</h2><p>SIMPLE returns a score <strong>μ</strong> between −1 and +1 for each (source, simplification) pair:</p><div class="scale" aria-hidden="true"></div><div class="scale-labels"><span>−1 unrelated or degenerate text</span><span>0 copy of the source</span><span>+1 successful simplification</span></div><p class="small muted" style="margin-top:12px">Negative scores flag unsuccessful simplifications, includingcomplexifications. Each score comes with <strong>σ</strong>, the model's own uncertainty: most predictions sitnear the minimum of 0.05; a larger σ means the model is less sure, and the example deserves a human look.</p>21 unmodified lines<div id="demo" class="hidden"><label for="source">Source sentence</label><textarea id="source" maxlength="2000" placeholder="The original, complex sentence"></textarea><label for="cand-a">Simplification</label><textarea id="cand-a" maxlength="2000" placeholder="A simplified version of the source"></textarea><label for="cand-b">Second simplification <span class="muted">(optional, to compare two candidates)</span></label><textarea id="cand-b" maxlength="2000" placeholder="Leave empty to score a single simplification"></textarea><p class="small muted" style="margin:12px 0 4px">Examples:</p><div class="examples" id="examples"></div>42 unmodified linesPaper: <em>Rethinking Text Simplification Evaluation as Preference Learning</em> (link coming soon).</p></section><footer>SIMPLE · MIT License</footer></main><script type="module" src="demo.js"></script></body>5 unmodified lines67891011121314151617188 unmodified lines272829303132333435363711 unmodified lines49505152535455565758592 unmodified lines62636465666768691 unmodified line71727374757677787 unmodified lines86878889909192939495969798991001011021031041057 unmodified lines1131141151161171181191201211221231241251261271281291301311321331341351361371381391404 unmodified lines1451461471481491501511521531541551561571582 unmodified lines16116216316416516616721 unmodified lines18919019119219319419519619719842 unmodified lines2412422432442452462472482495 unmodified lines<title>SIMPLE metric</title><link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%232457c5'/%3E%3Cpath d='M8 21h16M8 15h11M8 9h16' stroke='white' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E"><meta name="description" content="SIMPLE: a reference-free metric for sentence simplification that also reports its own uncertainty. Try it in your browser."><script>// Apply the saved theme before the page is drawn (no flash of the wrong theme).try {const t = localStorage.getItem("simple-theme");if (t === "light" || t === "dark") document.documentElement.dataset.theme = t;} catch { /* storage unavailable: follow the system setting */ }</script><style>:root {color-scheme: light;8 unmodified lines--good: #1f8a4c;--bad: #c2412d;--neutral: #8a8d93;--a: #2457c5;--a-band: rgba(36, 87, 197, 0.2);--b: #b4580a;--b-band: rgba(180, 88, 10, 0.2);--badge-text: #ffffff;--code-bg: #f0f0eb;--focus: #2457c5;}11 unmodified lines--good: #4cc27f;--bad: #f0806c;--neutral: #8f939a;--a: #7aa2ff;--a-band: rgba(122, 162, 255, 0.25);--b: #f2a65a;--b-band: rgba(242, 166, 90, 0.25);--badge-text: #141517;--code-bg: #25262a;--focus: #7aa2ff;}2 unmodified linescolor-scheme: dark;--bg: #141517; --surface: #1c1d20; --surface-2: #25262a; --text: #ececea; --muted: #a2a5ab;--border: #34363b; --accent: #7aa2ff; --accent-text: #0e1220; --good: #4cc27f; --bad: #f0806c;--neutral: #8f939a; --a: #7aa2ff; --a-band: rgba(122, 162, 255, 0.25); --b: #f2a65a;--b-band: rgba(242, 166, 90, 0.25); --badge-text: #141517; --code-bg: #25262a; --focus: #7aa2ff;}* { box-sizing: border-box; }html { -webkit-text-size-adjust: 100%; }1 unmodified linemargin: 0; background: var(--bg); color: var(--text);font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;}main { max-width: 780px; margin: 0 auto; padding: 32px 16px 56px; }header .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }h1 { font-size: 2.1rem; line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.01em; }h2 { font-size: 1.2rem; margin: 0 0 12px; }p { margin: 0 0 12px; }7 unmodified linespre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 0 0 12px; }pre code { background: none; padding: 0; }/* theme switch */.theme { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--surface); }.theme button { border: none; background: none; padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; color: var(--muted); }.theme button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }/* score scale */.scale { position: relative; height: 14px; border-radius: 7px; margin: 18px 0 6px;background: linear-gradient(90deg, var(--bad), var(--neutral) 50%, var(--good)); }.scale .band { position: absolute; top: -4px; bottom: -4px; border-radius: 4px; display: none; }.scale .marker { position: absolute; top: -7px; width: 4px; height: 28px; margin-left: -2px; border-radius: 2px; display: none; }.scale .marker span { position: absolute; top: -24px; left: 50%; transform: translateX(-50%); font-size: 0.75rem;font-weight: 700; white-space: nowrap; border-radius: 4px; padding: 0 5px; color: var(--badge-text); }#band-a { background: var(--a-band); } #band-b { background: var(--b-band); }#marker-a, #marker-a span { background: var(--a); } #marker-b, #marker-b span { background: var(--b); }.scale-labels { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); gap: 8px; }.scale-labels span:nth-child(2) { text-align: center; }.scale-labels span:last-child { text-align: right; }7 unmodified lines.linklike { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: 0.875rem; }.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 12px 0 6px; }.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; margin: 14px 0 6px; }label .muted { font-weight: 400; }.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;border-radius: 6px; font-size: 0.8rem; font-weight: 700; color: var(--badge-text); }.badge-a { background: var(--a); } .badge-b { background: var(--b); }textarea { width: 100%; min-height: 76px; resize: vertical; font: inherit; color: var(--text); background: var(--bg);border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }#cand-a { border-left: 4px solid var(--a); } #cand-b { border-left: 4px solid var(--b); }.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }.examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }.examples button { padding: 5px 10px; font-size: 0.85rem; border-radius: 999px; }.result { margin-top: 18px; padding-top: 22px; border-top: 1px solid var(--border); display: none; }.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }.score-card { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; border-left: 4px solid var(--a); }#card-b { border-left-color: var(--b); }.score-card .title { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--muted); }.score-card .big { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }.score-card .verdict { font-weight: 600; }.error { color: var(--bad); font-weight: 600; }.hidden { display: none !important; }footer { color: var(--muted); font-size: 0.85rem; text-align: center; margin-top: 28px; }footer a { color: var(--muted); }@media (max-width: 520px) {h1 { font-size: 1.7rem; }section { padding: 16px; }4 unmodified lines<body><main><header><div class="top"><h1>SIMPLE</h1><div class="theme" role="group" aria-label="Colour theme"><button type="button" data-theme-choice="auto">Auto</button><button type="button" data-theme-choice="light">Light</button><button type="button" data-theme-choice="dark">Dark</button></div></div><p class="lead">A reference-free metric for sentence simplification that also says how sure it is.Give it a sentence and a simplification of it; no reference simplification needed.</p></header>2 unmodified lines<h2 id="read-title">Reading the score</h2><p>SIMPLE returns a score <strong>μ</strong> between −1 and +1 for each (source, simplification) pair:</p><div class="scale" aria-hidden="true"></div><div class="scale-labels"><span>−1 unrelated, degenerate text or complexification</span><span>0 copy of the source</span><span>+1 successful simplification</span></div><p class="small muted" style="margin-top:12px">Negative scores flag unsuccessful simplifications, includingcomplexifications. Each score comes with <strong>σ</strong>, the model's own uncertainty: most predictions sitnear the minimum of 0.05; a larger σ means the model is less sure, and the example deserves a human look.</p>21 unmodified lines<div id="demo" class="hidden"><label for="source">Source sentence</label><textarea id="source" maxlength="2000" placeholder="The original, complex sentence"></textarea><label for="cand-a"><span class="badge badge-a">A</span> Simplification A</label><textarea id="cand-a" maxlength="2000" placeholder="A simplified version of the source"></textarea><label for="cand-b"><span class="badge badge-b">B</span> Simplification B <span class="muted">(optional, to compare with A)</span></label><textarea id="cand-b" maxlength="2000" placeholder="Leave empty to score simplification A on its own"></textarea><p class="small muted" style="margin:12px 0 4px">Examples:</p><div class="examples" id="examples"></div>42 unmodified linesPaper: <em>Rethinking Text Simplification Evaluation as Preference Learning</em> (link coming soon).</p></section><footer>SIMPLE · MIT License ·<a href="http://www.italianlp.it/" target="_blank" rel="noopener noreferrer">ItaliaNLP Lab @ CNR-ILC</a> ·<a href="https://michelepapucci.github.io/" target="_blank" rel="noopener noreferrer">Michele Papucci</a></footer></main><script type="module" src="demo.js"></script></body>
demo.js+34-10
index.html+57-18