자막 '화면 정가운데 아래' 채점 방식 변경

This commit is contained in:
2025-02-17 17:21:16 +09:00
parent cfc91cef69
commit 6937b34bbc
24 changed files with 467 additions and 54 deletions

View File

@@ -9,16 +9,18 @@ const { DOMParser } = require('xmldom');
const findSimilarString = require('./findSimilarString');
// --------------------------------------------------------
const scoringJson = require('./DIC_2521A.json');
// const scoringJson = require('./DIC_2521A.json');
// const scoringJson = require('./DIC_2521B.json');
// const scoringJson = require('./DIC_2521C.json');
// const scoringJson = require('./DIC_2521D.json');
const scoringJson = require('./DIC_2521D.json');
// TEST
// const scoringJson = require('./DIC_2521A_TEST.json');
// --------------------------------------------------------
const answerFilesDir = './output/A/DIC';
// const answerFilesDir = './output/A/DIC';
// const answerFilesDir = './output/B/DIC';
// const answerFilesDir = './output/C/DIC';
// const answerFilesDir = './output/D/DIC';
const answerFilesDir = './output/D/DIC';
// TEST
// const answerFilesDir = './output/A/TEST';
@@ -26,10 +28,10 @@ const answerFilesDir = './output/A/DIC';
// const answerFilesDir = './output/D/TEST';
// --------------------------------------------------------
const outputExcelFile = './DIC_2521A_result.xlsx';
// const outputExcelFile = './DIC_2521A_result.xlsx';
// const outputExcelFile = './DIC_2521B_result.xlsx';
// const outputExcelFile = './DIC_2521C_result.xlsx';
// const outputExcelFile = './DIC_2521D_result.xlsx';
const outputExcelFile = './DIC_2521D_result.xlsx';
// TEST
// const outputExcelFile = './DIC_2521A_TEST.xlsx';
@@ -148,20 +150,15 @@ function getGmepScore(gmepData, scoringJson, index) {
* CRCUnitArr태그 Name속성 찾는 구문으로 변환
* > 멀티라인 텍스트 유사도 판별하기 어려움
*/
if (search !== undefined) {
let result = findSimilarString(gmepXmlDoc, search, 0.2)
console.log("🚀 ~ getGmepScore ~ result:", result)
ele = ele.replace(/{search}/g, result);
console.log("🚀 ~ getGmepScore ~ ele:", ele)
if ( existEle !== undefined ){
existEle = existEle.replace(/{search}/g, result);
}
}
console.log(`example number: ${key}`)
// xpath
if (ele === 'none') {
scoringResult[key] = "확인필요";
@@ -268,6 +265,48 @@ function getGmepScore(gmepData, scoringJson, index) {
scoringResult[key] = result.length > 0 && rightAnswer === result[0].value ? point : 0;
}
// [3-9]문제 : 자막 화면 정가운데 아래
// 자막의 글자 갯수, 글자 크기, 폰트에 따라 위치가 유동적으로 바뀌어서
// 예상되는 최소 좌표부터 최대 좌표를 미리 입력하고 (JSON파일 start/end 속성)
// 수험자가 입력한 자막의 좌표값이 범위 안에 들어가면 정답으로 채점
else if (type == "range") {
const start = scoringData[key].start;
const end = scoringData[key].end;
try{
const result = xpath.select(ele, gmepXmlDoc);
if (result.length == 0) {
scoringResult[key] = 0;
continue;
}
// 수험자 자막 좌표 (x,y)
const x = parseFloat(result[0].value);
const y = parseFloat(result[1].value);
// 최소 좌표 (x1, y1)
const x1 = parseFloat(start[0]);
const y1 = parseFloat(start[1]);
// 최대 좌표 (x2, y2)
const x2 = parseFloat(end[0]);
const y2 = parseFloat(end[1]);
// (x1,y1) <= (x,y) <= (x2,y2) 이면 true
const isPointInRange = (x, y, x1, y1, x2, y2) =>
(x >= x1 && x <= x2) && (y >= y1 && y <= y2);
if (isPointInRange(x, y, x1, y1, x2, y2) === true ) {
totalScore += point;
scoringResult[key] = point;
}
else
scoringResult[key] = 0;
}
catch (e) {
console.log('err :', e);
scoringResult[key] = 0;
}
}
else if (type == "multi") {
try {
const result = xpath.select(ele, gmepXmlDoc);