dehezhang2 commited on
Commit
12a053e
·
verified ·
1 Parent(s): 649dbdb

deploy rater (Docker/FastAPI): registration + completeness gate + /api/submit → dataset

Browse files
Files changed (2) hide show
  1. static/index.html +72 -1
  2. static/mobile.html +56 -3
static/index.html CHANGED
@@ -118,6 +118,9 @@
118
  padding: 12px 14px; line-height: 1.6; font-size: 14px; flex: 1; min-width: 280px; }
119
  .prompt-box .label { font-size: 10px; text-transform: uppercase; color: var(--muted);
120
  letter-spacing: 0.5px; margin-bottom: 4px; }
 
 
 
121
  .ref-img { max-height: 140px; max-width: 220px; border-radius: 6px;
122
  border: 1px solid var(--border); display: block; }
123
 
@@ -1390,6 +1393,70 @@ function escapeHtml(s) {
1390
  ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'})[c]);
1391
  }
1392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1393
  function showToast(msg, isError = false) {
1394
  const t = document.getElementById("toast");
1395
  t.textContent = msg;
@@ -1750,7 +1817,11 @@ function renderCaseHeader(c) {
1750
  const promptBox = el("div", { class: "prompt-box" });
1751
  promptBox.appendChild(el("div", { class: "label" }, t("prompt_label")));
1752
  const localized = (c.prompt_i18n && c.prompt_i18n[LANG]) || c.prompt;
1753
- promptBox.appendChild(el("div", {}, localized || t("no_prompt")));
 
 
 
 
1754
  wrap.appendChild(promptBox);
1755
 
1756
  if (c.reference_image) {
 
118
  padding: 12px 14px; line-height: 1.6; font-size: 14px; flex: 1; min-width: 280px; }
119
  .prompt-box .label { font-size: 10px; text-transform: uppercase; color: var(--muted);
120
  letter-spacing: 0.5px; margin-bottom: 4px; }
121
+ /* Highlight imperative verbs + control directives (Add / Use / Make ...) so
122
+ raters can spot what controllability they should be scoring against. */
123
+ .ctrl { color: var(--bad); font-weight: 700; }
124
  .ref-img { max-height: 140px; max-width: 220px; border-radius: 6px;
125
  border: 1px solid var(--border); display: block; }
126
 
 
1393
  ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'})[c]);
1394
  }
1395
 
1396
+ /* Patterns flagging controllability cues — imperative verbs and the
1397
+ * directive phrases that follow. Returned matches are wrapped in a
1398
+ * <span class="ctrl"> so the rater can immediately see what the prompt
1399
+ * actually controls (subjects, identities, sound design, subtitles, BGM).
1400
+ * Per-language because the imperative forms differ. */
1401
+ const CTRL_PATTERNS = {
1402
+ en: [
1403
+ // "Add ambient sounds: ..." / "Add a XXX BGM." / "Add Chinese subtitles ..."
1404
+ /\bAdd\b[^.]*\./g,
1405
+ // "Use this uploaded photo as the look of the cultivation male lead."
1406
+ /\bUse this[^.]*\./g,
1407
+ // Leading "Make a <genre> animated short drama" up to the em-dash.
1408
+ /Make a[^—–]*?animated short drama/g,
1409
+ ],
1410
+ zh: [
1411
+ /制作一部[^—–]*?短剧/g,
1412
+ /请?添加[^。]*。/g,
1413
+ /请使用上传的[^。]*。/g,
1414
+ /配以[^。]*。/g,
1415
+ /环境音[::][^。]*。/g,
1416
+ ],
1417
+ bg: [
1418
+ /Създайте[^—–]*?анимационна кратка драма/g,
1419
+ /Добавете[^.]*\./g,
1420
+ /Използвайте качената[^.]*\./g,
1421
+ ],
1422
+ };
1423
+
1424
+ function highlightControllability(text, lang) {
1425
+ // Operate on the escaped string so the wrap-spans we inject stay the only
1426
+ // un-escaped HTML in the output.
1427
+ let html = escapeHtml(text);
1428
+ const patterns = CTRL_PATTERNS[lang] || CTRL_PATTERNS.en;
1429
+ // Collect non-overlapping match ranges first so two patterns can't both
1430
+ // wrap the same substring (which would double-wrap and look ugly).
1431
+ const ranges = [];
1432
+ for (const re of patterns) {
1433
+ re.lastIndex = 0;
1434
+ let m;
1435
+ while ((m = re.exec(html)) !== null) {
1436
+ ranges.push([m.index, m.index + m[0].length]);
1437
+ if (m[0].length === 0) re.lastIndex++; // safety vs zero-width
1438
+ }
1439
+ }
1440
+ if (!ranges.length) return html;
1441
+ // Merge overlapping / adjacent ranges
1442
+ ranges.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
1443
+ const merged = [ranges[0].slice()];
1444
+ for (let i = 1; i < ranges.length; i++) {
1445
+ const top = merged[merged.length - 1];
1446
+ if (ranges[i][0] <= top[1]) top[1] = Math.max(top[1], ranges[i][1]);
1447
+ else merged.push(ranges[i].slice());
1448
+ }
1449
+ // Splice in spans from right to left so earlier indices stay valid.
1450
+ let out = html;
1451
+ for (let i = merged.length - 1; i >= 0; i--) {
1452
+ const [s, e] = merged[i];
1453
+ out = out.slice(0, s)
1454
+ + '<span class="ctrl">' + out.slice(s, e) + '</span>'
1455
+ + out.slice(e);
1456
+ }
1457
+ return out;
1458
+ }
1459
+
1460
  function showToast(msg, isError = false) {
1461
  const t = document.getElementById("toast");
1462
  t.textContent = msg;
 
1817
  const promptBox = el("div", { class: "prompt-box" });
1818
  promptBox.appendChild(el("div", { class: "label" }, t("prompt_label")));
1819
  const localized = (c.prompt_i18n && c.prompt_i18n[LANG]) || c.prompt;
1820
+ // Highlight controllability cues (imperative verbs + directive phrases) so
1821
+ // the rater knows what to evaluate against the videos.
1822
+ const promptText = el("div", {});
1823
+ promptText.innerHTML = highlightControllability(localized || t("no_prompt"), LANG);
1824
+ promptBox.appendChild(promptText);
1825
  wrap.appendChild(promptBox);
1826
 
1827
  if (c.reference_image) {
static/mobile.html CHANGED
@@ -90,6 +90,8 @@
90
  .prompt-card details[open] summary { margin-bottom: 6px; }
91
  .prompt-card .ref-img { max-width: 100%; max-height: 200px; border-radius: 6px;
92
  border: 1px solid var(--border); display: block; margin-top: 8px; }
 
 
93
 
94
  /* videos */
95
  .video-stack { display: flex; flex-direction: column; gap: 10px;
@@ -620,6 +622,54 @@ function isAdmin(){ return ADMIN_NAMES.has((RATER.name||"").trim().toLowerCase()
620
  const EMAIL_RE = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
621
  function hashStr(s){ let h=2166136261>>>0; for(let i=0;i<s.length;i++){h^=s.charCodeAt(i);h=(h*16777619)>>>0;} return h; }
622
  function escapeHtml(s){return String(s).replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'})[c]);}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  function showToast(msg, isErr=false){
624
  const tt = document.getElementById("toast");
625
  tt.textContent = msg;
@@ -901,12 +951,15 @@ function renderPromptCard(c){
901
  wrap.className = "prompt-card";
902
  const localized = (c.prompt_i18n && c.prompt_i18n[LANG]) || c.prompt || t("no_prompt");
903
  const isLong = (localized||"").length > 160;
 
 
 
904
  wrap.innerHTML = isLong
905
  ? `<div class="label">${escapeHtml(t("prompt_label"))}</div>
906
- <details><summary>${escapeHtml(localized.slice(0,150)+"…")} <span style="color:var(--accent)">(${t("expand_prompt")})</span></summary>
907
- <div style="margin-top:6px">${escapeHtml(localized)}</div></details>`
908
  : `<div class="label">${escapeHtml(t("prompt_label"))}</div>
909
- <div>${escapeHtml(localized)}</div>`;
910
  if (c.reference_image){
911
  const img = document.createElement("img");
912
  img.src = c.reference_image; img.className = "ref-img";
 
90
  .prompt-card details[open] summary { margin-bottom: 6px; }
91
  .prompt-card .ref-img { max-width: 100%; max-height: 200px; border-radius: 6px;
92
  border: 1px solid var(--border); display: block; margin-top: 8px; }
93
+ /* Bold-red highlight on controllability cues in the prompt. */
94
+ .ctrl { color: var(--bad); font-weight: 700; }
95
 
96
  /* videos */
97
  .video-stack { display: flex; flex-direction: column; gap: 10px;
 
622
  const EMAIL_RE = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
623
  function hashStr(s){ let h=2166136261>>>0; for(let i=0;i<s.length;i++){h^=s.charCodeAt(i);h=(h*16777619)>>>0;} return h; }
624
  function escapeHtml(s){return String(s).replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'})[c]);}
625
+
626
+ // Controllability highlighter — wraps imperative verbs + directive phrases
627
+ // in <span class="ctrl"> so raters see what the prompt actually controls.
628
+ const CTRL_PATTERNS = {
629
+ en: [
630
+ /\bAdd\b[^.]*\./g,
631
+ /\bUse this[^.]*\./g,
632
+ /Make a[^—–]*?animated short drama/g,
633
+ ],
634
+ zh: [
635
+ /制作一部[^—–]*?短剧/g,
636
+ /请?添加[^。]*。/g,
637
+ /请使用上传的[^。]*。/g,
638
+ /配以[^。]*。/g,
639
+ /环境音[::][^。]*。/g,
640
+ ],
641
+ bg: [
642
+ /Създайте[^—–]*?анимационна кратка драма/g,
643
+ /Добавете[^.]*\./g,
644
+ /Използвайте качената[^.]*\./g,
645
+ ],
646
+ };
647
+ function highlightControllability(text, lang) {
648
+ let html = escapeHtml(text);
649
+ const patterns = CTRL_PATTERNS[lang] || CTRL_PATTERNS.en;
650
+ const ranges = [];
651
+ for (const re of patterns) {
652
+ re.lastIndex = 0; let m;
653
+ while ((m = re.exec(html)) !== null) {
654
+ ranges.push([m.index, m.index + m[0].length]);
655
+ if (m[0].length === 0) re.lastIndex++;
656
+ }
657
+ }
658
+ if (!ranges.length) return html;
659
+ ranges.sort((a,b)=>a[0]-b[0]||a[1]-b[1]);
660
+ const merged = [ranges[0].slice()];
661
+ for (let i=1;i<ranges.length;i++){
662
+ const top = merged[merged.length-1];
663
+ if (ranges[i][0]<=top[1]) top[1] = Math.max(top[1], ranges[i][1]);
664
+ else merged.push(ranges[i].slice());
665
+ }
666
+ let out = html;
667
+ for (let i=merged.length-1;i>=0;i--){
668
+ const [s,e] = merged[i];
669
+ out = out.slice(0,s) + '<span class="ctrl">' + out.slice(s,e) + '</span>' + out.slice(e);
670
+ }
671
+ return out;
672
+ }
673
  function showToast(msg, isErr=false){
674
  const tt = document.getElementById("toast");
675
  tt.textContent = msg;
 
951
  wrap.className = "prompt-card";
952
  const localized = (c.prompt_i18n && c.prompt_i18n[LANG]) || c.prompt || t("no_prompt");
953
  const isLong = (localized||"").length > 160;
954
+ const highlightedFull = highlightControllability(localized, LANG);
955
+ // For the collapsed teaser we still highlight, but on the truncated text.
956
+ const teaser = highlightControllability(localized.slice(0,150)+"…", LANG);
957
  wrap.innerHTML = isLong
958
  ? `<div class="label">${escapeHtml(t("prompt_label"))}</div>
959
+ <details><summary>${teaser} <span style="color:var(--accent)">(${escapeHtml(t("expand_prompt"))})</span></summary>
960
+ <div style="margin-top:6px">${highlightedFull}</div></details>`
961
  : `<div class="label">${escapeHtml(t("prompt_label"))}</div>
962
+ <div>${highlightedFull}</div>`;
963
  if (c.reference_image){
964
  const img = document.createElement("img");
965
  img.src = c.reference_image; img.className = "ref-img";