From f58d6c2ebd68c774c86fea37ae586e232dc427ee Mon Sep 17 00:00:00 2001 From: Jakob Voss Date: Tue, 30 Nov 2021 12:32:55 +0100 Subject: [PATCH] Mark last element of complete analysis as atomic The last element of a complete analysis is always atomic. Example: 787.219. --- lib/pica.js | 3 +-- src/components/Analyze.vue | 6 +++--- test/pica-tests.json | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/pica.js b/lib/pica.js index 61d31c9..dde5e9d 100644 --- a/lib/pica.js +++ b/lib/pica.js @@ -44,8 +44,7 @@ export function picaFromDDC(concept) { continue } - // TODO: letztes member könnte auch atomic sein!! - if (isMemberParentOf(members[i-1], members[i]) && !isMemberParentOf(members[i], members[i+1])) { + if (i == members.length-1 || (isMemberParentOf(members[i-1], members[i]) && !isMemberParentOf(members[i], members[i+1]))) { const [ table, number ] = notation.split("--") const id = subfields[table] if (id) { // notation from table diff --git a/src/components/Analyze.vue b/src/components/Analyze.vue index 676d5c7..d4b11f7 100644 --- a/src/components/Analyze.vue +++ b/src/components/Analyze.vue @@ -68,18 +68,18 @@ v-html="notationWithHighlight(result, hovered)" />
diff --git a/test/pica-tests.json b/test/pica-tests.json index 08ca7f8..402a7b0 100644 --- a/test/pica-tests.json +++ b/test/pica-tests.json @@ -54,5 +54,19 @@ { "notation": [ "T2--7471", "---.-------7471" ] } ], "pica": "045H/20 $eDDC23ger$a700.90440747471$c7$f09044$f074$g7471$Acoli-ana" + }, + { + "notation": ["787.219"], + "memberList": [ + {"notation":["7","7------"]}, + {"notation":["78","78-----"]}, + {"notation":["787","787----"]}, + {"notation":["787.2","787.2--"]}, + {"notation":["787.219","787.219"]}, + {"notation":["784-788:1","---.-1-"]}, + {"notation":["784-788:18-19","---.-19"]}, + {"notation":["784.19","---.--9"]} + ], + "pica": "045H/20 $eDDC23ger$a787.219$c787.2$d784-788:18-19$d784.19$Acoli-ana" } ]