Importing RDF

From WandoraWiki
(Difference between revisions)
Jump to: navigation, search
(Post-processing the imported RDF(S))
(Post-processing the imported RDF(S))
Line 52: Line 52:
 
Second step is to clean up base names. You can use '''Topics > Base names > Regex replace...''' to filter out undesired parts of the base names.
 
Second step is to clean up base names. You can use '''Topics > Base names > Regex replace...''' to filter out undesired parts of the base names.
  
Third step is to change roles of RDF(S) originated associations. By default these roles are http://www.wandora.net/core/rdf-subject and http://www.wandora.net/core/rdf-object. You can not just edit these two role topics as all players share the role topics. Instead you need to modify associations with '''Change associations > Change association role...''' tool found in context menu association table. Depending on the original RDF(S) structure changing roles may be a big task.
+
Third step is to change roles of RDF(S) originated associations. By default these roles are http://www.wandora.net/core/rdf-subject and http://www.wandora.net/core/rdf-object. You can not just edit these two role topics as all players share role topics. Instead you need to modify associations with '''Change associations > Change association role...''' tool found in context menu association table. Depending on the original RDF(S) structure changing roles may be a big task.

Revision as of 17:52, 12 February 2007

Wandora reads RDF(S) and N3 files. Import starts with File > Import > Simple RDF(S) Import... or File > Import > Simple N3 Import.... Optionally you can drag and drop RDF(S) files to layer stack. Layer stack automatically imports dropped RDF(S) file and creates a new layer for the file. Wandora converts imported RDF triplets to topics, associations and occurrences. Convert schema is very simple and pays no attention to semantics of RDF(S) file. Lets see the conversion process more detailed.

  • A topic is always created for RDF subject and predicate. Topics created for the subject and predicate are typed with Wandora's predefined type topics.
  • If object is RDF literal an occurrence (text data) is created for the subject topic. Occurrence's type is the predicate topic and occurrence's value the RDF literal.
  • If object is not RDF literal a topic is created for the object and the topic is associated with the subject topic. Association's type is the predicate topic. Both roles are Wandora's predefined topics. Object topic is typed with Wandora's predefined type topic.

Created topics contain no base name or variant names. Created topics inherit one subject identifier from equivalent RDF resource. Subject identifier is the URI of equivalent RDF resource. Wandora employs Jena RDF framework to read RDF(S) files. Below is the Java code snippet used to handle RDF statements in Wandora.


   public void handleStatement(Statement stmt, TopicMap map,
                               Topic subjectType,
                               Topic predicateType,
                               Topic objectType) throws TopicMapException {
       
       Resource subject   = stmt.getSubject();     // get the subject
       Property predicate = stmt.getPredicate();   // get the predicate
       RDFNode object     = stmt.getObject();      // get the object
       
       Topic subjectTopic = getOrCreateTopic(map, subject.toString());
       Topic predicateTopic = getOrCreateTopic(map, predicate.toString());
       
       subjectTopic.addType(subjectType);
       predicateTopic.addType(predicateType);
      
       if(object.isLiteral()) {
           subjectTopic.setData(predicateTopic,
                                getOrCreateTopic(map, occurrenceScopeSI),
                                                 ((Literal) object).getString());
       }
       else if(object.isResource()) {
           Topic objectTopic = getOrCreateTopic(map, object.toString());
           Association association = map.createAssociation(predicateTopic);
           association.addPlayer(subjectTopic, subjectType);
           association.addPlayer(objectTopic, objectType);
           objectTopic.addType(objectType);
       }
       else if(object.isURIResource()) {
           log("URIResource found but not handled!");
       }        
   }


Post-processing the imported RDF(S)

To make the imported RDF(S) more topic mappish you may want to modify it after import. This chapter discusses about the post-processing techniques to make the RDF-imported topic map more convenient.

First step is to add base names to the topics. All RDF(S) originated topics contain no base name and only one subject identifier. You can create base name with topic's subject identifier using Make base name with SI tool found in topic table's context menu under Topics > Base names. Base name is automatically constructed using filename and anchor of the subject identifier URLs. If your topic map contains subject identifiers with identical filenames you should take extra care of these topics to prevent automatic merge of topics.

Second step is to clean up base names. You can use Topics > Base names > Regex replace... to filter out undesired parts of the base names.

Third step is to change roles of RDF(S) originated associations. By default these roles are http://www.wandora.net/core/rdf-subject and http://www.wandora.net/core/rdf-object. You can not just edit these two role topics as all players share role topics. Instead you need to modify associations with Change associations > Change association role... tool found in context menu association table. Depending on the original RDF(S) structure changing roles may be a big task.

Personal tools