Monday 15 June 2015

java - Add basic value to Ontology individuals @Jena -



java - Add basic value to Ontology individuals @Jena -

i have ontology classes , setup run. way fill individuals , data?? in short one-way mapping database (as input) ontology.

public class main { static string source = "http://www.umingo.de/ontology/bento.owl"; static string ns = source+"#"; public static void main(string[] args) throws exception { ontmodel model = modelfactory.createontologymodel( ontmodelspec.owl_mem ); // read rdf/xml file model.read(source); ontologypreloader loader = new ontologypreloader(); model = loader.init(model); model.write(system.out,"rdf/xml"); } }

my preloader has method init goal re-create info database ontology. here excerpt.

public ontmodel init(ontmodel model) throws sqlexception{ resource r = model.getresource( main.ns + "tag" ); property tag_name = model.createproperty(main.ns + "tag_name"); ontclass tag = r.as( ontclass.class ); // statements allow issue sql queries database statement = connect.createstatement(); // resultset gets result of sql query resultset = statement .executequery("select * niuu.tags"); // resultset initialised before first info set while (resultset.next()) { // possible columns via name // possible columns via column number // starts @ 1 // e.g., resultset.getstring(2); string id = resultset.getstring("id"); string name = resultset.getstring("name"); individual tag_tmp = tag.createindividual(main.ns+"tag_"+id); tag_tmp.addproperty(tag_name,name); system.out.println("id: " + id); system.out.println("name: " + name); } homecoming model; }

everything working, sense unsure way preload ontologies. every individual should own id can match database @ later point. can define property id , add together every individual?

i thought adding id "thing" basic type in owl ontologies.

at first sight seems ok. 1 tip seek convert jena model rdf serialization , run through protégé more clear image on how ontology mapping looks like.

you can create own property describe id of every individual. beneath illustration on how can create similar property in turtle format.(i did not add together prefixes owl , rdfs since common) can add together in jena aswell if needed. (or load model in jena.)

@prefix you: <your domain> . you:dbidentificator owl:datatypeproperty . you:dbidentificator rdfs:label "<your database identifcator>"@en . you:dbidentificator rdfs:comment "<some valuable info if needed>"@en . you:dbidentificator rdfs:isdefinedby <your domain> . you:dbidentificator rdfs:domain owl:thing .

you add together owl:thing every resource, not best practice because vague definition of resource. around vocabularies defines more resource is. take @ goodrelations. defined vocabulary can describe info though not commercial use. check out classes there.

hope answered of question.

java mysql jena ontology preloading

No comments:

Post a Comment