곰픽 일부 수정

This commit is contained in:
2025-03-24 17:24:25 +09:00
parent 6fe41f783e
commit b52d9b7dd9
3 changed files with 108 additions and 11 deletions

View File

@@ -24,6 +24,7 @@ function parseColorToHex(colorString) {
}
module.exports = getGpdpScore;
/**
* /Document/Layers/Layer/Shapes/Shape/draw_type 속성값
* > Interior: 내부 채우기 / Outline: 외곽선
@@ -35,8 +36,6 @@ module.exports = getGpdpScore;
* @returns
*/
// xml 형식의 GPDP 파일을 읽어서 점수를 계산
// scoring.json 파일 내에 있는 ele 요소는 xpath 형식으로 접근하여 요소를 탐색하고 나오는 값을 value와 비교하여 점수를 계산
// scoring.json 파일 내에 있는 type은 비교할 값의 타입을 의미하며, boolean, array 등이 있음
@@ -61,6 +60,12 @@ function getGpdpScore(gpdpData, scoringJson, index) {
let type = scoringData[key].type;
let search = scoringData[key].search;
const layer = scoringData[key].layer;
const option = scoringData[key].option;
ele = typeof ele === 'string' ? ele.replace(/{layer}/g, layer) : ele;
ele = typeof ele === 'string' ? ele.replace(/{option}/g, option) : ele;
if (search !== undefined) {
let result = findSimilarString(gpdpXmlDoc, search, 0.8)
// xpath 내부 "(큰따옴표) 필터링
@@ -73,6 +78,9 @@ function getGpdpScore(gpdpData, scoringJson, index) {
}
}
console.log(`example number: ${key}`)
console.log("🚀 ~ getGpdpScore ~ ele:", ele)
if (type == "multiValue") {
if (Array.isArray(rightAnswer)) {
@@ -108,16 +116,20 @@ function getGpdpScore(gpdpData, scoringJson, index) {
}
else if (type == "isExist" ) {
const result = xpath.select(ele, gpdpXmlDoc);
result.forEach((v, i) => {
const isMatch = result.some( v => {
if ( v.value === rightAnswer ) {
totalScore += point;
scoringResult[key] = point;
console.log("🚀 ~ result.forEach ~ 정답 일치:", rightAnswer)
return;
} else {
scoringResult[key] = 0;
return true;
}
return false;
});
if (!isMatch) {
scoringResult[key] = 0;
console.log("🚀 ~ result.forEach ~ 오답:", rightAnswer)
}
}
else if (type == "exact") {