Importing RDF

From WandoraWiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
Wandora reads RDF(S) and N3 files. Import starts with '''File > Import > Simple RDF(S) Import...''' or '''File > Import > Simple N3 Import...'''. Wandora converts imported RDF triplets to topics, associations and occurrences. Convert schema is very simple and pays no attention to semantics of RDF for example. Lets see the conversion process more detailed.
 
Wandora reads RDF(S) and N3 files. Import starts with '''File > Import > Simple RDF(S) Import...''' or '''File > Import > Simple N3 Import...'''. Wandora converts imported RDF triplets to topics, associations and occurrences. Convert schema is very simple and pays no attention to semantics of RDF for example. Lets see the conversion process more detailed.
  
A topic is created for RDF '''subject''', '''predicate''' and object '''object'''. A binary association is created for each triplet. '''Predicate''' is set association's type while '''subject''' and '''object''' are set players. RDF does not support association roles and '''subject''''s and '''object''''s roles are set to predefined topics of Wandora.
+
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 topic created with the '''subject'''. Occurrences type is topic created for the '''predicate'''.
 +
 +
If '''object''' is not RDF literal a topic is created for the '''object''' and the topic is associated with the topic created for the '''subject'''. Association's type is set the topic created for the '''predicate'''. Both roles are Wandora's predefined topics. Object topic is typed with Wandora's predefined type topic.
  
<nowiki>
 
 
     public void handleStatement(Statement stmt,TopicMap map,Topic subjectType,Topic predicateType,Topic objectType) throws TopicMapException {
 
     public void handleStatement(Statement stmt,TopicMap map,Topic subjectType,Topic predicateType,Topic objectType) throws TopicMapException {
 
         Resource subject  = stmt.getSubject();    // get the subject
 
         Resource subject  = stmt.getSubject();    // get the subject
Line 32: Line 34:
 
         }         
 
         }         
 
     }
 
     }
 
</nowiki>
 

Revision as of 14:58, 13 October 2006

Wandora reads RDF(S) and N3 files. Import starts with File > Import > Simple RDF(S) Import... or File > Import > Simple N3 Import.... Wandora converts imported RDF triplets to topics, associations and occurrences. Convert schema is very simple and pays no attention to semantics of RDF for example. 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 topic created with the subject. Occurrences type is topic created for the predicate.

If object is not RDF literal a topic is created for the object and the topic is associated with the topic created for the subject. Association's type is set the topic created for the predicate. Both roles are Wandora's predefined topics. Object topic is typed with Wandora's predefined type topic.

   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!");
       }        
   }
Personal tools