跳至內容
Astera Technology

核對搜尋改寫有否保留比較對象

把原問法與改寫的比較對象雙向核對,分開列欠項及多項。

下載完整個案資料及參考答案 ↓

訂明本例驗收任務

假設搜尋改寫先由同事標出比較對象的固定編號。改寫須保留全部原對象,不能加入新對象;欠項與新增項分開列。本例只核對已標出的清單,不聲稱可自動理解任意文字。

  1. 保存原對象編號清單
  2. 雙向核對改寫對象
  3. 修正欠項或額外範圍

對象未能標明,先由同事確認。

使用已填個案

原創假設輸入及確切答案鍵
個案已提供輸入預期結構化結果判斷及原因
漏一個比較對象{"original":["induction","refresher"],"rewritten":["induction"]}{"missing":["refresher"],"added":[],"preserved":false}改寫後沒有問重溫程序。
對象相同而次序不同{"original":["induction","refresher"],"rewritten":["refresher","induction"]}{"missing":[],"added":[],"preserved":true}本例對象用無序集合,兩個仍齊備。
加入無關對象{"original":["induction"],"rewritten":["induction","payroll"]}{"missing":[],"added":["payroll"],"preserved":false}保留入職程序也不夠;新增 payroll 改了搜尋範圍。
下載可編輯 CSV ↓

逐步處理 new-target 個案,須得到甚麼結果?原因是甚麼?

查看參考答案

{"missing":[],"added":["payroll"],"preserved":false}。保留入職程序也不夠;新增 payroll 改了搜尋範圍。

執行完整本機驗算

另存為 .mjs,以 Node.js 執行;只驗提供的個案
import assert from 'node:assert/strict';

function evaluate(x){
 const a=[...new Set(x.original)].sort(),b=[...new Set(x.rewritten)].sort();
 const missing=a.filter(id=>!b.includes(id)),added=b.filter(id=>!a.includes(id));return {missing,added,preserved:missing.length+added.length===0};
}

const cases = [
  {
    "id": "lost-comparison",
    "input": {
      "original": [
        "induction",
        "refresher"
      ],
      "rewritten": [
        "induction"
      ]
    },
    "expected": {
      "missing": [
        "refresher"
      ],
      "added": [],
      "preserved": false
    }
  },
  {
    "id": "reordered-targets",
    "input": {
      "original": [
        "induction",
        "refresher"
      ],
      "rewritten": [
        "refresher",
        "induction"
      ]
    },
    "expected": {
      "missing": [],
      "added": [],
      "preserved": true
    }
  },
  {
    "id": "new-target",
    "input": {
      "original": [
        "induction"
      ],
      "rewritten": [
        "induction",
        "payroll"
      ]
    },
    "expected": {
      "missing": [],
      "added": [
        "payroll"
      ],
      "preserved": false
    }
  }
];
for (const c of cases) assert.deepEqual(evaluate(c.input), c.expected, c.id);
console.log(JSON.stringify({checked:cases.length,caseIds:cases.map(c=>c.id)}));
下載可執行例子 ↓

原問法與比較對象標籤跟改寫一併保留。集合通過只確認這些對象仍在,沒有驗證整句自然語言。

相關資源