display owl file content in triplets.

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

display owl file content in triplets.

Gayathri
I am new to owl api. I have created a dynamic web project and  loaded the existing owl file from file system. I tried displaying the output in triplets. But i am getting raw output of the owl file. Please let me know how to display the owl file in triplet format removing the uri's.
Reply | Threaded
Open this post in threaded view
|

Re: display owl file content in triplets.

Jiba
Administrator
Hi,

You can use onto.save("filename.nt", format = "ntriples") to export triplets. It will displays full URL, but you can process the file later to remove them if you want so.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: display owl file content in triplets.

Gayathri
The following is my code.

OWLOntologyManager man = OWLManager.createOWLOntologyManager();
           File file = new File("/home/eclipse-workspace/Newwebapp/src/com/gayathri/steels2.owl");
           OWLOntology o;
           try {
                o=man.loadOntologyFromOntologyDocument(file);
                StringDocumentTarget target = new StringDocumentTarget();
                  try {
                        o.saveOntology(new FunctionalSyntaxDocumentFormat(), target);
                       
                        resp.getWriter().write("Hello World!!"+target.toString());
                } catch (OWLOntologyStorageException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                 
        } catch (OWLOntologyCreationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
        }


Jiba wrote
Hi,

You can use onto.save("filename.nt", format = "ntriples") to export triplets. It will displays full URL, but you can process the file later to remove them if you want so.

Jiba
Where should i add the line? Also i am loading a local owl file so should i change the filename.nt to filepath?
Reply | Threaded
Open this post in threaded view
|

Re: display owl file content in triplets.

Jiba
Administrator
This forum is about Owlready and the use of Python for manipulating ontologies. But your code is in Java, so it is out of topic.

My knowledge in Java is much more limited.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: display owl file content in triplets.

Gayathri
Thanks for the reply. Can you please tell me what is triplets and how it will look like. I am posting the output of my code after removing uri's from owl file. I don't know whether the retrieved output is a triplet or not. Please let me know whether the following is a triplet or not.

type
Ontology
versionIRI
isRuleEnabled
type
AnnotationProperty
DASE_RULE
type
AnnotationProperty
alloyAlsoKnownAs
type
ObjectProperty
alloyAlsoKnownAs
type
SymmetricProperty
alloyAlsoKnownAs
type
TransitiveProperty
SAE205
type
NamedIndividual
SAE205
type
DesignationType
SAE205
type
SAE
SAE205
alloyHasComposition
S20500
SAE205
AtomList
first
type
IndividualPropertyAtom
propertyPredicate
hasSpec
argument1
a
argument2
s
rest
Reply | Threaded
Open this post in threaded view
|

Re: display owl file content in triplets.

Jiba
Administrator
Hi,

This looks like triplets but splitted, one element per line.

A normal triplet would be:

    isRuleEnabled, type, AnnotationProperty

and so on.

JIba
Reply | Threaded
Open this post in threaded view
|

Re: display owl file content in triplets.

Gayathri
Can you please tell me how to load file from server machine?