(3-13)~(3-21) xpath반환값이 여러개일경우 첫번째 태그의 결과를 사용하도록 구문 수정
This commit is contained in:
@@ -14,7 +14,6 @@ function findSimilarString(xmlDoc, targetString, threshold = 0.8) {
|
||||
function getTextNodes(xmlDoc, stringList = []) {
|
||||
const stringNodes = xpath.select("//CRCUnitArr/@Name", xmlDoc);
|
||||
stringNodes.forEach(stringNode => {
|
||||
console.log("🚀 ~ getTextNodes ~ stringNode:", stringNode.value);
|
||||
stringList.push(stringNode.value);
|
||||
});
|
||||
return stringList;
|
||||
@@ -29,12 +28,18 @@ function findSimilarString(xmlDoc, targetString, threshold = 0.8) {
|
||||
|
||||
stringList.forEach(text => {
|
||||
const similarity = stringSimilarity.compareTwoStrings(targetString, text);
|
||||
|
||||
console.log("🚀 ~ findSimilarString ~ text:", text)
|
||||
console.log("🚀 ~ findSimilarString ~ targetString:", targetString)
|
||||
console.log("🚀 ~ findSimilarString ~ similarity:", similarity)
|
||||
|
||||
if (similarity > highestSimilarity && similarity >= threshold) {
|
||||
highestSimilarity = similarity;
|
||||
console.log("🚀 ~ findSimilarString ~ highestSimilarity:", highestSimilarity)
|
||||
bestMatch = text;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return bestMatch;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user