File size: 2,128 Bytes
7ca47a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const controls = ["rules", "checkpoint", "suite", "patch"].map(id => document.getElementById(id));
const [rules, checkpoint, suite, patch] = controls;
const ratio = document.getElementById("ratio");
const patchResult = document.getElementById("patch-result");
const changes = document.getElementById("changes");

async function loadEvidence() {
  const response = await fetch("evidence.json");
  if (!response.ok) throw new Error("Evidence could not be loaded");
  const evidence = await response.json();
  const matrix = document.getElementById("matrix");
  for (const [version, ...suites] of evidence.matrix) {
    const row = matrix.insertRow();
    const heading = document.createElement("th");
    heading.scope = "row";
    heading.textContent = version;
    row.append(heading);
    for (const value of suites) row.insertCell().textContent = value;
  }
  function render() {
    const pair = evidence.paired[rules.value];
    const value = pair.agent.verbosity.mean / pair.human.verbosity.mean;
    ratio.textContent = value.toFixed(2) + "×";
    const record = evidence.ablation.find(item => item.checkpoint === Number(checkpoint.value)
      && item.suite === Number(suite.value) && item.patch === patch.value);
    patchResult.textContent = `${record.passed}/${record.total} passed · ${record.recovered.length} recovered · ${record.regressed.length} regressions`;
    changes.replaceChildren();
    const results = [
      ...record.regressed.map(id => ["Regression", id]),
      ...record.recovered.map(id => ["Recovered", id]),
    ];
    for (const [status, id] of results) {
      const item = document.createElement("li");
      item.textContent = `${status} · ${id}`;
      changes.append(item);
    }
    if (!results.length) {
      const item = document.createElement("li");
      item.textContent = "No changed test cases.";
      changes.append(item);
    }
  }
  render();
  for (const control of controls) control.addEventListener("change", render);
}

loadEvidence().catch(() => {
  document.getElementById("load-error").hidden = false;
  for (const control of controls) control.disabled = true;
});