-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
空白の違い、強調の有無やコードブロックの引用符の有無などの違いを無視して適用するようにする。
diff-match-patchを使うといいらしい (ってgeminiが言ってた)
const DiffMatchPatch = require('diff-match-patch');
const dmp = new DiffMatchPatch();
// match_threshold: 0.0は完全一致、1.0は全く無関係でもマッチ
dmp.Match_Threshold = 0.5;
// match_distance: どのくらい離れた場所まで探しに行くか
dmp.Match_Distance = 1000;
const originalText = "明日の会議は、**10時**から開始します。";
const searchBlock = "明日の会議は、10時から開始"; // ** が抜けている
const pos = dmp.match_main(originalText, searchBlock, 0);
if (pos !== -1) {
console.log(`マッチした開始位置: ${pos}`);
// ここで置換処理を行う
}Reactions are currently unavailable