MCPcopy
hub / github.com/CopyTranslator/CopyTranslator / compare

Function compare

src/renderer/comparator.ts:28–43  ·  view source on GitHub ↗
(anchorResult: SharedResult, targetResult: SharedResult)

Source from the content-addressed store, hash-verified

26}
27
28function compare(anchorResult: SharedResult, targetResult: SharedResult) {
29 let anchorParas = anchorResult.transPara;
30 let targetParas = targetResult.transPara;
31 let all_parts = [];
32 if (anchorParas.length != targetParas.length) {
33 anchorParas = [anchorResult.translation];
34 targetParas = [targetResult.translation];
35 }
36 const diffFunc = anchorResult.chineseStyle ? Diff.diffChars : Diff.diffWords; //chinese style的话,是逐个字符比较
37 for (let i = 0; i < anchorParas.length; i++) {
38 let diffParts = diffFunc(anchorParas[i], targetParas[i]);
39 diffParts = diffParts.filter((p: any) => !p.removed);
40 all_parts.push(diffParts);
41 }
42 return all_parts;
43}

Callers 1

compareAllFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected