跳至內容
Astera Technology

核對草稿是否按指定方式保留名稱

按已訂大小寫核指定名稱,字面相符與草稿整體質素分開。

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

訂明本例驗收任務

假設櫃位指示須包含指定完整字樣,大小寫也要相同,前後可有其他文字。近義詞或改大小寫都不接;目標空白無效。本項只查用字,不混同資料準確或語句質素。

  1. 保存確切指定字樣
  2. 不改大小寫核對草稿
  3. 字面要求另列結果

指定字樣空白,先修驗收要求。

使用已填個案

原創假設輸入及確切答案鍵
個案已提供輸入預期結構化結果判斷及原因
櫃位名稱完全相同{"term":"North Desk","draft":"Ask North Desk for the folder."}{"matched":true}草稿出現完整指定字樣。
改成小寫{"term":"North Desk","draft":"Ask north desk for the folder."}{"matched":false}本例分大小寫,小寫不通過。
只用了近義說法{"term":"North Desk","draft":"Ask the northern counter."}{"matched":false}意思近似也不是指定名稱字樣。
下載可編輯 CSV ↓

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

查看參考答案

{"matched":false}。意思近似也不是指定名稱字樣。

執行完整本機驗算

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

function evaluate(x){return x.term.length?{matched:x.draft.includes(x.term)}:{error:'empty-term'};}

const cases = [
  {
    "id": "literal-name",
    "input": {
      "term": "North Desk",
      "draft": "Ask North Desk for the folder."
    },
    "expected": {
      "matched": true
    }
  },
  {
    "id": "case-variant",
    "input": {
      "term": "North Desk",
      "draft": "Ask north desk for the folder."
    },
    "expected": {
      "matched": false
    }
  },
  {
    "id": "synonym-only",
    "input": {
      "term": "North Desk",
      "draft": "Ask the northern counter."
    },
    "expected": {
      "matched": 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)}));
下載可執行例子 ↓

若要字詞邊界或全欄相等,另訂準則;本例是包含完整字樣。此項通過不代表整份草稿獲批。

相關資源