java - Retrieving DBpedia ontology classes by label in a particular language? -



java - Retrieving DBpedia ontology classes by label in a particular language? -

i have dbpedia ontology downloaded http://wiki.dbpedia.org/downloads39. in ontology, have, example, situation:

class="lang-xml prettyprint-override"><owl:class rdf:about="http://dbpedia.org/ontology/basketballleague"> <rdfs:label xml:lang="el">Ομοσπονδία Καλαθοσφαίρισης</rdfs:label><rdfs:label xml:lang="fr">ligue de basketball</rdfs:label><rdfs:label xml:lang="en">basketball league</rdfs:label><rdfs:label xml:lang="it">lega di pallacanestro</rdfs:label><rdfs:label xml:lang="ja">バスケットボールリーグ</rdfs:label><rdfs:comment xml:lang="en">a grouping of sports teams compete against each other in basketball</rdfs:comment><rdfs:subclassof rdf:resource="http://dbpedia.org/ontology/sportsleague"/> </owl:class>

now, want read ontology using jena , retrieve owl class has object ""ligue de basketball" in french language. don't know how can utilize jena library set french language in case.

from dbpedia ontology, seems xml:lang="fr" predicate, have tried code:

string inputfilename = "c:\\dbpedia_3.9.owl"; // create empty in-memory ontology model ontdocumentmanager mgr = new ontdocumentmanager(); ontmodelspec s = new ontmodelspec( ontmodelspec.rdfs_mem ); s.setdocumentmanager( mgr ); ontmodel m = modelfactory.createontologymodel( s, null ); // utilize filemanager open ontology filesystem inputstream in = filemanager.get().open(inputfilename); if (in == null) { throw new illegalargumentexception( "file: " + inputfilename + " not found"); } // read ontology file m.read( in, "" ); stmtiterator stmti = m.liststatements(); while (stmti.hasnext()){ statement statement = stmti.nextstatement(); system.out.println (statement.getpredicate()); }

but only:

http://www.w3.org/2000/01/rdf-schema#label

i don't info on language in predicate. why? how can retrieve info , owl class? doing wrong here?

you need read on literals in rdf , how they're encoded in rdf/xml. ontology snippet you've shown in rdf/xml (which not designed human readable), , xml:lang not property. xml:lang attribute used specify language of literal has language tag.

2.7 languages: xml:lang

rdf/xml permits utilize of xml:lang attribute defined 2.12 language identification of xml 1.0 [xml] allow identification of content language. xml:lang attribute can used on node element or property element indicate included content in given language. typed literals includes xml literals not affected attribute. specific in-scope language nowadays (if any) applied property element string literal content or property attribute values. xml:lang="" form indicates absence of language identifier.

some examples of marking content languages rdf properties shown in illustration 8:

example 8: finish illustration of xml:lang (example08.rdf output example08.nt) class="lang-xml prettyprint-override"><?xml version="1.0" encoding="utf-8"?> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:description rdf:about="http://www.w3.org/tr/rdf-syntax-grammar"> <dc:title>rdf/xml syntax specification (revised)</dc:title> <dc:title xml:lang="en">rdf/xml syntax specification (revised)</dc:title> <dc:title xml:lang="en-us">rdf/xml syntax specification (revised)</dc:title> </rdf:description> <rdf:description rdf:about="http://example.org/buecher/baum" xml:lang="de"> <dc:title>der baum</dc:title> <dc:description>das buch ist außergewöhnlich</dc:description> <dc:title xml:lang="en">the tree</dc:title> </rdf:description> </rdf:rdf>

if @ example08.nt linked above, you'll see triples include:

class="lang-none prettyprint-override"><http://www.w3.org/tr/rdf-syntax-grammar> <http://purl.org/dc/elements/1.1/title> "rdf/xml syntax specification (revised)" . <http://www.w3.org/tr/rdf-syntax-grammar> <http://purl.org/dc/elements/1.1/title> "rdf/xml syntax specification (revised)"@en . <http://www.w3.org/tr/rdf-syntax-grammar> <http://purl.org/dc/elements/1.1/title> "rdf/xml syntax specification (revised)"@en-us . <http://example.org/buecher/baum> <http://purl.org/dc/elements/1.1/title> "der baum"@de . <http://example.org/buecher/baum> <http://purl.org/dc/elements/1.1/title> "the tree"@en .

the resources have multiple values property dc:title. xml:lang not property, used specify part of literal.

the same thing true in dbpedia data. there multiple values of property rdfs:label, , xml:lang attributes in rdf/xml serialization used indicate language. dbpedia unavailable me @ moment, if go http://dbpedia.org/ontology/basketballleague , scroll bottom of page, you'll able download info in various formats. if download in ttl/n3 format, you'll see content this:

class="lang-none prettyprint-override">dbpedia-owl:basketballleague rdfs:label "basketball league"@en , "Ομοσπονδία Καλαθοσφαίρισης""@el , "ligue de basketball"@fr, ...

you need object of predicate getobject, whether whether it's literal isliteral, , when utilize getlanguage language tag if has one. javadocs relevant classes describe methods you'll need. i've linked literal class before in paragraph.

java jena owl ontology dbpedia

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -