java - Sparql Query results in Tamil using Eclipse -
we trying execute sparql query our owl ontology created in tamil using protege in eclipse ide. code works fine results don't seem appear in tamil. following code , output.
import java.lang.*; import java.util.regex.*; import java.io.*; import com.hp.hpl.jena.sparql.*; import com.hp.hpl.jena.*; import com.hp.hpl.jena.rdf.model.model; import com.hp.hpl.jena.rdf.model.modelfactory; import com.hp.hpl.jena.query.*; import java.io.file; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; import java.util.iterator; import com.hp.hpl.jena.ontology.ontclass; import com.hp.hpl.jena.ontology.ontmodel; import com.hp.hpl.jena.ontology.ontmodelspec; import com.hp.hpl.jena.query.query; import com.hp.hpl.jena.query.queryexecution; import com.hp.hpl.jena.query.queryexecutionfactory; import com.hp.hpl.jena.query.queryfactory; import com.hp.hpl.jena.query.resultset; import com.hp.hpl.jena.query.resultsetformatter; import com.hp.hpl.jena.rdf.model.model; import com.hp.hpl.jena.rdf.model.modelfactory; import com.hp.hpl.jena.util.filemanager; import com.hp.hpl.jena.vocabulary.owl; import com.hp.hpl.jena.vocabulary.rdfs; import edu.stanford.smi.protegex.owl.protegeowl; import edu.stanford.smi.protegex.owl.jena.jenaowlmodel; import edu.stanford.smi.protegex.owl.model.owlmodel; public class sample { public static void main(string[] args) throws filenotfoundexception, ioexception, nullpointerexception { try { //opening owl file inputstream in = new fileinputstream(new file("c:/users/sandhya/desktop/ontology/newtamil.owl")); model model=modelfactory.creatememmodelmaker().createdefaultmodel() ; model.read(in,null); system.out.println(model); in.close(); string querystring = "prefix pizza: <http://www.semanticweb.org/ontologies/2013/3/newtamil.owl#> "+ " prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+ "prefix owl: <http://www.w3.org/2002/07/owl#> "+ "prefix xsd: <http://www.w3.org/2001/xmlschema#> "+ "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+ "select ?subject ?object "+ " { ?subject rdfs:subclassof ?object }"; com.hp.hpl.jena.query.query q = queryfactory.create(querystring); queryexecution qe = queryexecutionfactory.create(q, model); resultset results = qe.execselect(); while (results.hasnext()) { system.out.println(results.getresourcemodel() ); resultsetformatter.out(system.out, results, q); qe.close(); } }catch(java.lang.nullpointerexception e){ system.out.println(e);} catch(exception e){ system.out.println("query failed !"); } } }
output: -------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------
| subject | object |
|%e0%ae%aa%e0%ae%aa%e0%af%80%e0%ae%be%e0%af%82 | %e0%af%8d%e0%ae%a4%e0%af%81%e0%ae%b0%e0%ae%aa |
|%e0%ae%95%e0%af%81%e0%ae%b0%e0%af%82%e0%ae%95%e0%ae%a4%e0%ae%aa | %e0%af%8d%e0%ae%a4%e0%af%81%e0%ae%b0%e0%ae%aa |
we want displayed in tamil. installed unicode , redirected output text file , checked still not give expected result. in advance.
jena prints in utf-8.
it looks data %-encoded.
Comments
Post a Comment