Value must be an instance of skos:Concept

21 views
Skip to first unread message

Luis Enrique Ramos García

unread,
Nov 18, 2024, 5:07:42 AM11/18/24
to topbrai...@googlegroups.com
Dear All,

I am receiving this error message in the execution of an script:

Value must be an instance of skos:Concept

Value: http:sampleuri.com/id
Suggestion: Set type of  http:sampleuri.com/id to Concept

However, in the output of statements  I get:

<http:sampleuri.com/id>
  a skos:Concept ;
  skos:broader <http:sampleuri.com/anotherid> ;

Where I can see that http:sampleuri.com/id is a skos:Concept,

thus I wonder why I am recieving this message?.

this is the part of the script I use to create the concepts:


let concept = skos.createConcept({
            uri: 'http:sampleuri.com/'+ row['id'],
            notation: row.id
        })
 
Best regards


Luis Ramos


Holger Knublauch

unread,
Nov 18, 2024, 5:34:04 AM11/18/24
to 'Luis Enrique Ramos García' via TopBraid Suite Users
From the information provided I don't see anything wrong. But there may be other steps in your script. For example, you may change other resources that are not correctly typed and thus the sh:class constraint fails.

Could you paste the whole script?

Holger


--
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/CABy94XnQXBo2R-sO3m0GeNpwRt%3DAGOYvnKV7g3ADP0yT0YNDBw%40mail.gmail.com.

Luis Enrique Ramos García

unread,
Nov 18, 2024, 5:38:36 AM11/18/24
to topbrai...@googlegroups.com
sure:

let s = IO.uploadedFile(file).asSpreadsheet();
machine_prefix_en= 'Machine for '
machine_prefix_de= 'Maschine für '


s.rows().forEach(row =>{
        let concept = skos.createConcept({
            uri: ' http:sampleuri.com/id /'+ row['id'],
            notation: row.id
        })
         //adding the current row to a taxon
        //concept.topConceptOf= graph.namedNode(' http:sampleuri.com/conceptschema1')

        graph.addTriples

        try{
            prefLabelwithLang(concept,machine_prefix_en+row['label en'],'en')
            prefLabelwithLang(concept,machine_prefix_de+row['label de'],'de')
            let conceptLangEn =    graph.langString(row['concept en'],'en')
            concept.add(skos.definition, conceptLangEn);
            let conceptLangDe =    graph.langString(row['concept de'],'de')
            concept.add(skos.definition, conceptLangDe);
            //first level of clasification
            firstLevelTaxon(concept, row['id'])
        }
        catch{
            console.log()
        }
    }//end row
)//end forEach

//working with german


function splitStringAtParentheses(input) {
  // Use a regular expression to match the content between parentheses
  const match = input.match(/^(.*?)\s*\(([^)]+)\)$/);
 
  // If a match is found, return an array with both parts, otherwise return null
  if (match) {
    return [match[1].trim(), match[2].trim()];
  } else {
    return null;
  }
}



function prefLabelwithLang(my_concept,my_label,my_lang){
    let prefLabelLang =    graph.langString(my_label,my_lang)
    my_concept.add(skos.prefLabel, prefLabelLang);
}

function altLabelwithLang(my_concept,my_label,my_lang){
    let altLabelLang =    graph.langString(my_label,my_lang)
    my_concept.add(skos.altLabel, altLabelLang);
}

function firstLevelTaxon(my_concept, id){
    const taxonLevel1 =["1.17.03.01.00.00","1.17.03.02.00.00","1.17.03.03.00.00","1.17.03.04.00.00","1.17.03.05.00.00","1.17.03.06.00.00"]
    if (taxonLevel1.includes(id)){
        my_concept.broader =  graph.namedNode(' http:sampleuri.com//1.17.03.00.00.00')
    }//if not first level
   
    else{
        const idArray = id.split(".");
        //evaluating the taxon
        if (idArray[-1] !== '00'){
            broaded_id = ' http:sampleuri.com//1.17.03.'+idArray[3]+'.'+idArray[4]+'.00'
            my_concept.broader =  graph.namedNode(broaded_id)
        }
    }//elnd else first level
   
    //console.log()
}//firstLevelTaxon

function prefLabelwithLang(my_concept,my_label,my_lang){
    let prefLabelLang =    graph.langString(my_label,my_lang)
    my_concept.add(skos.prefLabel, prefLabelLang);
}

function altLabelwithLang(my_concept,my_label,my_lang){
    let altLabelLang =    graph.langString(my_label,my_lang)
    my_concept.add(skos.altLabel, altLabelLang);
}

Holger Knublauch

unread,
Nov 18, 2024, 5:41:27 AM11/18/24
to 'Luis Enrique Ramos García' via TopBraid Suite Users
Ok thanks. When you run this in Preview mode from the Script Editor panel, can you see which resources are changed?

The system will perform constraint validation on those changed resources. Maybe some of them don't have rdf:type skos:Concept.

Holger


Luis Enrique Ramos García

unread,
Nov 18, 2024, 5:54:03 AM11/18/24
to topbrai...@googlegroups.com
possible, let me check.

But, I would like to try another way.

The usecase I have is that I want to upload concepts that are organized in categorized ids, e.g 1.0.0, 1.1.0, 1.0.2, 1.1.1, 1.1.2. (spreadsheet).

Thus, I want to reproduce it in my tree so:

1.1.1








Luis Enrique Ramos García

unread,
Nov 18, 2024, 5:55:35 AM11/18/24
to topbrai...@googlegroups.com
possible, let me check.

But, I would like to try another way.

The usecase I have is that I want to upload concepts that are organized in categorized ids, e.g 1.0.0, 1.1.0, 1.0.2, 1.1.1, 1.1.2. (spreadsheet).

Thus, I want to reproduce it in my tree so:

1.1.0
   1.1.1
   1.1.2

which should be the best way to do it?

script or importing spreadsheet?,

Luis











Holger Knublauch

unread,
Nov 18, 2024, 6:00:50 AM11/18/24
to topbrai...@googlegroups.com

On 18 Nov 2024, at 11:55 AM, 'Luis Enrique Ramos García' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

possible, let me check.

But, I would like to try another way.

The usecase I have is that I want to upload concepts that are organized in categorized ids, e.g 1.0.0, 1.1.0, 1.0.2, 1.1.1, 1.1.2. (spreadsheet).

Thus, I want to reproduce it in my tree so:

1.1.0
   1.1.1
   1.1.2

which should be the best way to do it?

script or importing spreadsheet?,

Not sure I understand the question. If you want to automate it, surely a script is the answer. If you don't need to automate it and the spreadsheet importers can handle everything, just use the latter.

Holger



Luis Enrique Ramos García

unread,
Nov 18, 2024, 7:50:19 AM11/18/24
to topbrai...@googlegroups.com
Well, let me elaborate it a little more.

First, regarding your comment: Maybe some of them don't have rdf:type skos:Concept.

There are more than 200 elements in the spreadsheet I am working on, and all of them present the same message.

Anyway, attached you will find a spreadsheet similar to my usecase.

I tried to upload a spreadsheet similar to this, but my first issue was that I could not upload the definition in both languages.
The importer tool did not provide a language tag, while the label did.

The second point I want to have is the uri including the id, like : http:sampleuri.com/2.0.1

Finally, I want to reproduce the hierarchical structure from the spreadsheet into my taxonomy:
image.png

Of course, in the real use case I have more that 1000 elements, so my requirement is to automate as many as possible.

Hope this very clarify the issues I am facing , and the requirement


Best regards



Luis Ramos









machines_example.xlsx

Holger Knublauch

unread,
Nov 18, 2024, 10:15:11 AM11/18/24
to 'Luis Enrique Ramos García' via TopBraid Suite Users
The spreadsheet mapping (with multiple languages) should work better with the newly implemented spreadsheet integration


but meanwhile it looks like you'll need an ADS script as it has more flexibility.

(I am not sure where this email thread leaves us, as I don't see how to help further and help with specific implementation tasks goes beyond what we can cover here)

Holger


On 18 Nov 2024, at 1:50 PM, 'Luis Enrique Ramos García' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

Well, let me elaborate it a little more.

First, regarding your comment: Maybe some of them don't have rdf:type skos:Concept.

There are more than 200 elements in the spreadsheet I am working on, and all of them present the same message.

Anyway, attached you will find a spreadsheet similar to my usecase.

I tried to upload a spreadsheet similar to this, but my first issue was that I could not upload the definition in both languages.
The importer tool did not provide a language tag, while the label did.

The second point I want to have is the uri including the id, like : http:sampleuri.com/2.0.1

Finally, I want to reproduce the hierarchical structure from the spreadsheet into my taxonomy:
Reply all
Reply to author
Forward
0 new messages