곰픽 [4-3][4-4] 채점시 레이어 이름을 검색할 경우 유사도 옵션 추가
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user