script to create preflabel by language

8 views
Skip to first unread message

Luis Enrique Ramos García

unread,
Nov 13, 2024, 4:15:36 AM11/13/24
to topbrai...@googlegroups.com
Dear All,

I have a spreadsheet with two columns of labels in different languages.

I have been able to create a prefLabel for a specific language, 
but when I try to add a preflabel it seems the previous one is overwritten.

As I know I should be able to create a preflabel per language, 
and as many labels in a language as I want.
Thus, I wonder which method I should use to get the expected result?

Below is the code I have done till now:

let s = IO.uploadedFile(file).asSpreadsheet();
//graph.uploadedFile(file).asSpreadsheet()
//s.row(0)['label 1']
s.rows().forEach(row => {
    let concept = skos.createConcept({
        uri: 'http://example.com/'+ row['id'],
        notation: row.id
    })

//creating label in english, if any
let prefLabelEN =    graph.langString(row['label 1'],'en')
//creating label in german, if any
let prefLabelDE =    graph.langString(row['label 2'],'de')
//adding english label, if any?
concept.prefLabel= prefLabelEN
//ading german label, if any
concept.prefLabel= prefLabelDE


})



Best regards


Luis Ramos



Holger Knublauch

unread,
Nov 13, 2024, 4:17:51 AM11/13/24
to 'Luis Enrique Ramos García' via TopBraid Suite Users
This would overwrite the prefLabel each time.

Instead try

concept.add(skos.prefLabel, prefLabelEN);
concept.add(skos.prefLabel, prefLabelDE);

HTH
Holger




})



Best regards


Luis Ramos




--
The topics of this mailing list include TopBraid EDG and related technologies such as SHACL.
To post to this group, send email to topbrai...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/topbraid-users/CABy94XkffkRu9cz3_q_6ARFM%2BO8xPP1rYgBY_Tic20Jhn2vBTw%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages