Close

September 7, 2019

The Sheet2RDF VocBench tool tutorial

Tutorial

In this section we see some use cases of Sheet2RDF and we give examples of spreadsheets and PEARL code. In each of the following tutorials we suppose we’re working on a SKOS/SKOSXL project. For a better understanding we recommend to read first PEARL documentation.

Working with subject and explicit IDs

This is maybe the simplest use case of Sheet2RDF. In case you want to manually specify the resource ID you can create a sheet with the first column dedicated to the subjects. Since we’re working on a SKOSXL project, the subject column should have skos:Concept as header. Let’s suppose we just want to assert the broader relation between two concepts: c_2 skos:broader c_1.

tutorial_1

Now let’s take a look to the PEARL code automatically generated, especially to the nodes section. With this code we’re instructing the system to generate subjectand col1_skos_broader/value by means of the default CODA converter (uri). This converter generates a URI concatenating the value (in this case skos_Concept/value, that is the concept ID, and skos_broader/value) to the end of the base URI.

		 
	prefix	: 	<http://baseuri.org#>
	prefix	coda: 	<http://art.uniroma2.it/coda/contracts>
	...

	rule it.uniroma2.art.Sheet2RDFAnnotation id:row {
		nodes = {
			subject	uri	col0_skos_Concept/value
			col1_skos_broader_value	uri	col1_skos_broader/value
			col2_skos_prefLabel_value literal@en col2_skos_prefLabel/value 
		}
		graph = {
			$subject rdf:type <http://www.w3.org/2004/02/skos/core#Concept> .
			$subject skos:inScheme <http://sheet2rdf#main> .
			OPTIONAL { $subject	skos:broader	$col1_skos_broader_value . }
			OPTIONAL { $subject	skos:prefLabel	$col2_skos_prefLabel_value . }
		}
	}
		

The execution of this code generate the following triples. We can note that usinge the default CODA converter, the concept URIs have the local name that is exactly the ID specified under the skos:Concept column.

tutorial_2

Working with subject and generated IDs

If we don’t want to specify manually the concepts IDs, we can instruct Sheet2RDF to generate them for us. To accomplish this we can define symbolic IDs under the subject column and refer to that from other cells. This IDs are not the same that will be added to the working project, but they will be used by the system to generate the effective random IDs in deterministic mode. As in the previous example, let’s create a broader relation between two concepts, but this time we don’t specify the effective IDs, we just use some cardinal IDs (1 and 2From Disposal Process See Figure A-9).

tutorial_3

In this case, we have to modify the previous PEARL code, so that the system will generate concepts with random IDs. To accomplish that, we use the randIdGenCODA converter. This converter generates a random URI and assigns it to the subject node. We use the same converter also to the col1_skos_broader_value node that is generated from the value under skos:broadercolumn. Since some values under this column refer to values under the column skos:Concept (e.g. the concept 2 refers to the concept 1 with the property skos:broader), we would like that the randomic IDs generated from both the columns values are generated in a deterministic way, namely 1 under skos:Conceptcolumn and 1 under skos:broader column, referring to the same resource, should generate the same URI. In order to accomplish this, we use the @Memoizedannotation that ensures that the convertion result is cached and reused when the converter is invoked on the same input.

		 
	...
	nodes = {
		@Memoized
		subject uri(coda:randIdGen('concept')) col0_skos_Concept/value .
		@Memoized
		col1_skos_broader_value uri(coda:randIdGen('concept')) col1_skos_broader/value .
		col2_skos_prefLabel_value literal@en col2_skos_prefLabel/value .
	}
	...
		

As you can see in the following figure, that shows the generated triples, the skos:broader reference points to the correct URI.

tutorial_4

Working without subject

Defining symbolic IDs could be a waste of time for someone. As alternative solution we can use the value of some property defined in the sheet as a start for creating the ID without explicit using any column. For example, we can use the label of the concepts and base the references on it. As you can see in this figure, the broader relation of dog points to the label of animalconcept.

tutorial_5

In this scenario the PEARL code should be modified as follow.

		 
	...
	nodes = {
		@Memoized
		subject uri(coda:randIdGen('concept')) col0_skos_prefLabel/value .
		col0_skos_prefLabel_value literal@en col0_skos_prefLabel/value .
		@Memoized
		col1_skos_broader_value uri(coda:randIdGen('concept')) col1_skos_broader/value .
	}
	...
		

This time, the subject is generated with randIdGenconverter in combination with the @Memoizedannotation (as in the previous case) but starting from the col0_skos_prefLabel_en/value. As already state in the previous example, if we want to make reference to that subject in other row, we have to use the same converter (as for col1_skos_broader/value).

As we expected, the references in the following generated triples are correct.

tutorial_6

If we are not interested to make references between resources, we could omit the @Memoized annotation and let the randomic converter generate a new random ID at each invocation. More about the available converters is here.

— Read on art.uniroma2.it/sheet2rdf/documentation/tutorial.jsf