Skip to content

conversion:keys

Tim L edited this page Aug 12, 2013 · 34 revisions

What is first

What we will cover

The page describes how to use the conversion:keys enhancement to constrain how conversion:links_via links to external Resources.

Let's get to it

Example 1 - input

The following example uses the same identifiers to refer to two different things. The distinguishing factor here is the type of thing being referenced. While "CA" is ambiguous, the "state CA" can be distinguished enough from the "company CA".

bash-3.2$ cat manual/test.csv contains:

name,state,company
susy,CA,CA
paul,MA,MA

Example 1 - links-via graph

The graph shown describes states and companies with the identifiers "CA" and "MA". We'll use this graph and the conversion:keys enhancement to refer to the correct thing when converting the strings "CA" and "MA" in different contexts.

bash-3.2$ cat manual/links-via.ttl contains:

@prefix dcterms: <http://purl.org/dc/terms/> .

<http://dbpedia.org/resource/M._A._Hanna_Company> 
   a <http://dbpedia.org/ontology/Company>;
   dcterms:identifier "MA";
.

<http://logd.tw.rpi.edu/id/us/state/Massachusetts> 
   a <http://dbpedia.org/class/yago/StatesOfTheUnitedStates>;
   dcterms:identifier "MA";
.

<http://dbpedia.org/resource/Computer_Associates> 
   a <http://dbpedia.org/ontology/Company>;
   dcterms:identifier "CA";
.

<http://logd.tw.rpi.edu/id/us/state/California> 
   a <http://dbpedia.org/class/yago/StatesOfTheUnitedStates>;
   dcterms:identifier "CA";
.

Example 1 - initial (undesired) output

If we use conversion:links_via without the owl:keys qualification, we get some undesirable owl:sameAs assertions since the URIs created for columns 2 and 3 are both owl:sameAs both the state and company.

value_of_state:CA              # The URI (for the state) created for column 2
   dcterms:identifier "CA" ;
   rdfs:label "CA" ;
   owl:sameAs dbpedia:Computer_Associates,                      # The company 
              <http://logd.tw.rpi.edu/id/us/state/California> . # AND the state!?

value_of_company:CA            # The URI (for the company) created for column 3
   dcterms:identifier "CA" ;
   rdfs:label "CA" ;
   owl:sameAs dbpedia:Computer_Associates,                      # The company
              <http://logd.tw.rpi.edu/id/us/state/California> . # AND the state!?

Example 1 - qualifying conversion:links_via with conversion:keys

The conversion:keys enhancement modifies the behavior of conversion:links_via by specifying additional properties that the target Resource must also exhibit in order to satisfy linking to it. In the example below, we indicate that in order for the URI from column 2 (value_of_state:CA) to link to a URI in the links-via graph, the Resource in the links-via graph must also have the property rdf:type with value http://dbpedia.org/class/yago/StatesOfTheUnitedStates. Similarly, we indicate that in order for the URI from column 3 (value_of_company:CA) to link to a URI in the links-via graph, the Resource in the links-via graph must also have the property rdf:type with value http://dbpedia.org/ontology/Company. Additional "property-value" conditions may be asserted as part of the conversion keys; the target Resource must exhibit all of those specified.

      conversion:enhance [
         ov:csvCol          2;
         ...
         conversion:links_via <links-via.ttl>;
         conversion:keys [
            # The resources that we try to link to MUST also be described with each predicate-object in this collection.
            dcterms:hasPart [
              conversion:predicate rdf:type;
              conversion:object <http://dbpedia.org/class/yago/StatesOfTheUnitedStates>;
            ]
         ];
      ];
      ...
      conversion:enhance [
         ov:csvCol          3;
         ...
         conversion:links_via <links-via.ttl>;
         conversion:keys [
            # The resources that we try to link to MUST also be described with each predicate-object in this collection.
            dcterms:hasPart [
              conversion:predicate rdf:type;
              conversion:object <http://dbpedia.org/ontology/Company>;
            ], [
              conversion:predicate geonames:parentFeature;
              conversion:object "http://logd.tw.rpi.edu/id/us/state/[#2]";
            ];
         ];
      ];

Example 1 - corrected output by applying conversion:keys

Applying the conversion:keys enhancement shown above prevents the unwanted owl:sameAs that would occur with only the conversion:links_via enhancement.

value_of_state:CA dcterms:identifier "CA" ;
   rdfs:label "CA" ;
   owl:sameAs <http://logd.tw.rpi.edu/id/us/state/California> .

value_of_company:CA dcterms:identifier "CA" ;
   rdfs:label "CA" ;
   owl:sameAs dbpedia:Computer_Associates . 
   
value_of_state:MA dcterms:identifier "MA" ;
   rdfs:label "MA" ;
   owl:sameAs <http://logd.tw.rpi.edu/id/us/state/Massachusetts> .

value_of_company:MA dcterms:identifier "MA" ;
   rdfs:label "MA" ;
   owl:sameAs <http://dbpedia.org/resource/M._A._Hanna_Company> .

Requiring the target Resource to exhibit more than one property

         conversion:keys [
            # The resources that we try to link to MUST also be described with each predicate-object in this collection.
            dcterms:hasPart [
              conversion:predicate rdf:type;
              conversion:object <http://dbpedia.org/ontology/Company>;
            ], [
              conversion:predicate geonames:parentFeature;
              conversion:object "http://logd.tw.rpi.edu/id/us/state/[#2]";
            ];
         ];

Transitive predicates

Note that this is not implemented. #359

         conversion:keys [
            # The resources that we try to link to MUST also be described with each predicate-object in this collection.
            dcterms:hasPart [
              conversion:predicate rdf:type;
              conversion:object <http://dbpedia.org/ontology/Company>;
            ], [
              a conversion:Transitive; # <--- walk geonames:parentFeature to find California.
              conversion:predicate geonames:parentFeature;
              conversion:object <http://logd.tw.rpi.edu/id/us/state/California>;
            ];
         ];

Using templates to specify the required predicate and objects

Note that this is not implemented. #360

Using template variables to construct new values

            # The resources that we try to link to MUST also be described with each predicate-object in this collection.
            dcterms:hasPart [
              conversion:predicate rdf:type;
              conversion:object <http://dbpedia.org/ontology/Company>;
            ], [
              conversion:predicate geonames:parentFeature;
              conversion:object "http://logd.tw.rpi.edu/id/us/state/[#2]";
            ];
         ];

What is next

Clone this wiki locally