곰픽 [4-3][4-4] 채점시 레이어 이름을 검색할 경우 유사도 옵션 추가

This commit is contained in:
2025-06-27 17:52:33 +09:00
parent afe8b02625
commit 9aa1425d81
8 changed files with 640 additions and 447 deletions

View File

@@ -11,16 +11,24 @@ const stringSimilarity = require("string-similarity");
*/
function findSimilarString(xmlDoc, targetString, threshold = 0.8) {
// XML 내부의 비교 대상 텍스트 리스트 찾기
function getTextNodes(xmlDoc, stringList = []) {
const stringNodes = xpath.select("//CRCUnitArr/@Name", xmlDoc);
stringNodes.forEach(stringNode => {
stringList.push(stringNode.value);
function getTextNodes(xmlDoc, paths = ["//CRCUnitArr/@Name"]) {
const stringList = [];
paths.forEach(path => {
const nodes = xpath.select(path, xmlDoc);
nodes.forEach(node => {
stringList.push(node.value);
});
});
return stringList;
}
// XML에서 모든 텍스트 추출
const stringList = getTextNodes(xmlDoc);
const stringList = getTextNodes(xmlDoc, [
"//CRCUnitArr/@Name",
"//Layer/Name/@value",
]);
// 유사도 비교하여 가장 유사한 문자열 찾기
let bestMatch = null;