guidocecilio / neologism

Automatically exported from code.google.com/p/neologism
3 stars 1 forks source link

Follow rdfs:isDefinedBy links when importing vocabularies #192

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. import http://data.ordnancesurvey.co.uk/ontology/admingeo/

What is the expected output? What do you see instead?

Expected ontology to be imported. However, while the namespace is
as above, the linked data publishing of this URI does not return any properties 
or classes. Instead, it informs you that the concepts for this namespace are 
rdfs:isDefinedBy an .owl file elsewhere

Currently as no properties or classes are found, a somewhat baffling error is 
returned -- 'Internal error: evoc_processed_vocabulary is not present'

Please provide any additional information below.

I've hacked a work-around to this issue, by adding the following immediately
before the return line in function evoc_get_from_web of
./sites/all/modules/evoc/evoc.load_vocab.inc

  // if there are rdfs:isDefinedBy statements, include that file as well
  foreach($triples as $t) {
    if ($t['s'] == $schema_url && $t['p'] == 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy') {
      $additionalContent = _evoc_fetch_from_web($t['o']);
      $parser = _evoc_parse_rdfxml($t['o'], $additionalContent);
      list($newTriples, $newNamespaces) = _evoc_parse_rdfxml($t['o'], $additionalContent);
      $triples = array_merge($triples, $newTriples);
      $namespaces = array_merge($namespaces, $newNamespaces);
    }
  }
  // if there are rdfs:isDefinedBy statements, include that file as well
  foreach($triples as $t) {
    if ($t['s'] == $schema_url && $t['p'] == 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy') {
      $additionalContent = _evoc_fetch_from_web($t['o']);
      $parser = _evoc_parse_rdfxml($t['o'], $additionalContent);
      list($newTriples, $newNamespaces) = _evoc_parse_rdfxml($t['o'], $additionalContent);
      $triples = array_merge($triples, $newTriples);
      $namespaces = array_merge($namespaces, $newNamespaces);
    }
  }

This is probably not the right place, I've not hacked around in drupal before, 
though it does seem to work for me in this instance!

Original issue reported on code.google.com by icm...@googlemail.com on 15 Apr 2011 at 11:47

GoogleCodeExporter commented 8 years ago
oops, seems I inadvertently pasted the code snippet twice...

Original comment by icm...@googlemail.com on 15 Apr 2011 at 12:20

GoogleCodeExporter commented 8 years ago
I'm changing the summary to better reflect the requested behaviour.

A better way of handling this would be: If parsing the file returned from the 
namespace URI does not return any classes or properties, but contains an 
rdfs:isDefinedBy triple, then try fetching and parsing that file. Don't merge 
anything.

The unhelpful error message is a separate problem. I created Issue 194 for that.

Original comment by richard....@gmail.com on 9 May 2011 at 6:46