Skip to content

Commit

Permalink
Mark last element of complete analysis as atomic
Browse files Browse the repository at this point in the history
The last element of a complete analysis is always atomic. Example: 787.219.
  • Loading branch information
nichtich committed Nov 30, 2021
1 parent 83dae6f commit f58d6c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/pica.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/components/Analyze.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@
v-html="notationWithHighlight(result, hovered)" />
</div>
<div
v-for="(member, index) in result.memberList.filter(m => m != null)"
v-for="(member, i) in result.memberList.filter(m => m != null)"
:key="member.notation[1]"
:class="{
row: true,
'font-weight-bold': result.memberList[index - 1] && isMemberParentOf(result.memberList[index - 1], member) && !isMemberParentOf(member, result.memberList[index + 1]),
'font-weight-bold': (isComplete(result) && i == result.memberList.length-1) || (result.memberList[i - 1] && isMemberParentOf(result.memberList[i - 1], member) && !isMemberParentOf(member, result.memberList[i + 1])),
'row-highlight': mode === 'lookup' && notation.split('|').includes(member.notation[0]),
}"
@mouseover="hovered = { member, result }"
@mouseleave="hovered = {}">
<div class="hierarchy-info">
<tippy
v-if="isMemberParentOf(result.memberList[index - 1], member)"
v-if="isMemberParentOf(result.memberList[i - 1], member)"
content="This DDC class is a child of the previous class.">
</tippy>
Expand Down
14 changes: 14 additions & 0 deletions test/pica-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]

0 comments on commit f58d6c2

Please sign in to comment.