hi can you send me the code for ismapped() function...

On Wed, Apr 3, 2013 at 11:16 AM, Mark Fischer <[email protected]>wrote:

> I did something similar a while back.
> This doesn't quite do what you want, but it may be close.
> I compared inequivalent classes and such as well as super classes.
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>     private boolean areEqual(OntClass thisOne, OntClass thatOne){
>         return areEqual(false, thisOne, thatOne);
>     }
>
>     private boolean areEqual(boolean deep, OntClass thisOne, OntClass
> thatOne){
>         if (thisOne.isUnionClass() && thatOne.isUnionClass()) {
>             return areEqual(thisOne.asUnionClass(),
> thatOne.asUnionClass());
>         } else if (thisOne.isIntersectionClass() &&
> thatOne.isIntersectionClass()) {
>             return areEqual(thisOne.asIntersectionClass(),
> thatOne.asIntersectionClass());
>         } else if (thisOne.isComplementClass() &&
> thatOne.isComplementClass()) {
>             return areEqual(thisOne.asComplementClass(),
> thatOne.asComplementClass());
>         } else if (thisOne.isRestriction() && thatOne.isRestriction()) {
>             return areEqual(thisOne.asRestriction(),
> thatOne.asRestriction());
>         } else if (thisOne.isURIResource() && thatOne.isURIResource()) {
>             // Both classes must have the same URI to be the same
>             if(!haveEqualURI(thisOne, thatOne))
>                 return false;
>
>             if(deep){
>                 // Must have the same Equivalent Classes
>                 if(!areEqual(thisOne.listEquivalentClasses().toList(),
> thatOne.listEquivalentClasses().toList()))
>                     return false;
>                 // Must have the same Superclasses
>                 if(!areEqual(thisOne.listSuperClasses().toList(),
> thatOne.listSuperClasses().toList()))
>                     return false;
>                 // Must have the same Disjoint Classes
>                 if(!areEqual(thisOne.listDisjointWith().toList(),
> thatOne.listDisjointWith().toList()))
>                     return false;
>             }
>             return true;
>         }
>         return false;
>     }
>
>     private boolean haveEqualURI(OntResource thisURI, OntResource thatURI){
>         if(thisURI.isURIResource() && thatURI.isURIResource()){
>             if(thisURI.getLocalName().equals(thatURI.getLocalName())){
>                 if(isMapped(thisURI.getNameSpace(),
> thatURI.getNameSpace())){
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
>
>     private boolean areEqual(OntProperty thisOne, OntProperty thatOne){
>         return areEqual(false, thisOne, thatOne);
>     }
>
>     private boolean areEqual(boolean deep, OntProperty thisOne,
> OntProperty thatOne){
>
>         if(thisOne.isURIResource() && thatOne.isURIResource()){
>             // Both properties must have the same URI to be the same
>             if(!haveEqualURI(thisOne, thatOne))
>                 return false;
>
>             if(deep){
>                 if(thisOne.isDatatypeProperty() &&
> !thatOne.isDatatypeProperty()) return false;
>                 if(thisOne.isFunctionalProperty() &&
> !thatOne.isFunctionalProperty()) return false;
>                 if(thisOne.isInverseFunctionalProperty() &&
> !thatOne.isInverseFunctionalProperty()) return false;
>                 if(thisOne.isObjectProperty() &&
> !thatOne.isObjectProperty()) return false;
>                 if(thisOne.isSymmetricProperty() &&
> !thatOne.isSymmetricProperty()) return false;
>                 if(thisOne.isTransitiveProperty() &&
> !thatOne.isTransitiveProperty()) return false;
>                 if(!areEqual(thisOne.listRange().toList(),
> thatOne.listRange().toList())) return false;
>                 if(!areEqual(thisOne.listDomain().toList(),
> thatOne.listDomain().toList())) return false;
>
> if(!areEqual(thisOne.listSuperProperties(true).toList(),
> thatOne.listSuperProperties(true).toList())) return false;
>             }
>             return true;
>         }
>         return false;
>     }
>
>     // This will catch UnionClass, IntersectionClass, and ComplementClass
>     private boolean areEqual(BooleanClassDescription thisOne,
> BooleanClassDescription thatOne){
>         return areEqual(thisOne.listOperands().toList(),
> thatOne.listOperands().toList());
>     }
>
>     private boolean areEqual(List<? extends OntResource> thisOne,
> List<? extends OntResource> thatOne){
>         for(int i = 0; i < thisOne.size(); i++ ){
>             for(int j = 0; j < thatOne.size(); j++){
>                 if(areEqual(thisOne.get(i), thatOne.get(j))){
>                     thisOne.remove(i);
>                     thatOne.remove(j);
>                     i--;
>                     break;
>                 }
>             }
>         }
>         if(thisOne.size() == 0 && thatOne.size() == 0) return true;
>         return false;
>     }
>
>     private boolean areEqual(Restriction thisOne, Restriction thatOne){
>         // Same property for this restriction
>         if(!areEqual(thisOne.getOnProperty(), thatOne.getOnProperty()))
>             return false;
>
>         // Same restriction type and values
>         if (thisOne.isAllValuesFromRestriction() &&
> thatOne.isAllValuesFromRestriction())
>             return
> areEqual(thisOne.asAllValuesFromRestriction().getAllValuesFrom(),
> thatOne.asAllValuesFromRestriction().getAllValuesFrom());
>         if (thisOne.isSomeValuesFromRestriction() &&
> thatOne.isSomeValuesFromRestriction())
>             return
> areEqual(thisOne.asSomeValuesFromRestriction().getSomeValuesFrom(),
> thatOne.asSomeValuesFromRestriction().getSomeValuesFrom());
>         if (thisOne.isHasValueRestriction() &&
> thatOne.isHasValueRestriction())
>             return
> areEqual(thisOne.asHasValueRestriction().getHasValue(),
> thatOne.asHasValueRestriction().getHasValue());
>         if (thisOne.isCardinalityRestriction() &&
> thatOne.isCardinalityRestriction())
>             return thisOne.asCardinalityRestriction().getCardinality()
> == thatOne.asCardinalityRestriction().getCardinality();
>         if (thisOne.isMaxCardinalityRestriction() &&
> thatOne.isMaxCardinalityRestriction())
>             return
> thisOne.asMaxCardinalityRestriction().getMaxCardinality() ==
> thatOne.asMaxCardinalityRestriction().getMaxCardinality();
>         if (thisOne.isMinCardinalityRestriction() &&
> thatOne.isMinCardinalityRestriction())
>             return
> thisOne.asMinCardinalityRestriction().getMinCardinality() ==
> thatOne.asMinCardinalityRestriction().getMinCardinality();
>
>         return false;
>     }
>
>     private boolean areEqual(RDFNode thisOne, RDFNode thatOne){
>         if(thisOne.isResource() && thatOne.isResource())
>             return areEqual(thisOne.asResource(), thatOne.asResource());
>         if(thisOne.isLiteral() &&  thatOne.isLiteral())
>             return areEqual(thisOne.asLiteral(), thatOne.asLiteral());
>         return false;
>     }
>
>     private boolean areEqual(Resource thisOne, Resource thatOne){
>         if(thisOne.canAs(OntClass.class) && thatOne.canAs(OntClass.class))
>             return areEqual(thisOne.as(OntClass.class),
> thatOne.as(OntClass.class));
>         if(thisOne.canAs(OntProperty.class) &&
> thatOne.canAs(OntProperty.class))
>             return areEqual(thisOne.as(OntProperty.class),
> thatOne.as(OntProperty.class));
>         else
>             return thisOne.equals(thatOne);
>     }
>
>     private boolean areEqual(Literal thisOne, Literal thatOne){
>         return this.equals(thatOne);
>     }
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> --
> Mark Fischer
>
>
> On Wed, Apr 3, 2013 at 12:23 PM, aarthi <[email protected]> wrote:
>
> > hi...  i need to compare two ontologies using jena... if i take two
> > classes, each in a separate ontology. in order to say these two classes
> are
> > structurally equivalent, i need to say all the super class for the 2
> >  classes we considered are similar.. can anyone help me for the code
> >
> >
> > On Sat, Mar 30, 2013 at 8:24 AM, aarthi <[email protected]>
> wrote:
> >
> > > hi thanks.. it worked correctly. because i didn't add the jena files
> > > correctly.sorry for that. and  i need to retrieve the class and
> > > properties names from an ontology. if i execute my previous code i
> > > just got the triple format. is there anyway to store the class and
> > > properties names in a separate file or in a database? if its possible
> > > please guide me.....
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On 3/30/13, Andy Seaborne <[email protected]> wrote:
> > > > Which version of Jena is this?
> > > >
> > > > Jena doesn't use Apache commons logging (it did a long time ago, I
> > > > think).  For some libraries we use, there is a Apache commons logging
> > > > dependency, which is met via jcl-over-slf4j in the POMs.
> > > >
> > > > But that's nowhere near PropertyImpl, which has a reference to SLF4J
> > > > nowadays.
> > > >
> > > >       Andy
> > > >
> > > >  >>> Exception in thread "main" java.lang.NoClassDefFoundError:
> > > >  >>> org/apache/commons/logging/LogFactory
> > > >  >>>          at
> > > >  >>>
> > > com.hp.hpl.jena.rdf.model.impl.PropertyImpl.<clinit>(PropertyImpl.java
> > > >  >> :
> > > >  >>> 58)
> > > >
> > > >
> > > > On 30/03/13 13:38, John A. Fereira wrote:
> > > >> Specifically, you'll need to include the commons-logging jar file in
> > > your
> > > >> classpath.  Typically that would mean specifying a directory which
> > > >> includes that jar file as well as the jar files for the jena library
> > and
> > > >> any other dependency library.  You'll probably also need to include
> > one
> > > >> for log4j or simple logging (slf4j) library.
> > > >>
> > > >>> -----Original Message-----
> > > >>> From: Milorad Tosic [mailto:[email protected]]
> > > >>> Sent: Saturday, March 30, 2013 9:07 AM
> > > >>> To: aarthi; users
> > > >>> Subject: Re:
> > > >>>
> > > >>> Looks like you need to include an additional library for
> > > >>> org.apache.commons.logging.LogFactory class.
> > > >>>
> > > >>> Regards,
> > > >>> Milorad
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>> ________________________________
> > > >>>> From: aarthi <[email protected]>
> > > >>>> To: Milorad Tosic <[email protected]>; users <
> [email protected]
> > >
> > > >>>> Sent: Saturday, March 30, 2013 1:56 PM
> > > >>>> Subject:
> > > >>>>
> > > >>>> hi..
> > > >>>>    i'm doing my project with ontology. i need to retrieve the
> class
> > > and
> > > >>>> properties names in order to compare them for equality. to
> retrieve
> > > >>> the
> > > >>>> class an property names i'm using a java code. i have attached
> that
> > > >>>> code with this mail. but i got some error, I don't know how to
> > resolve
> > > >>>> that. for that i had import com.hp.hpl.jena package. i dont get
> the
> > > >>>> classpath files and javadoc files. is it enough if i add only the
> > > >>>> source package? pls help me....
> > > >>>>
> > > >>>> this is my code:
> > > >>>>
> > > >>>>
> > > >>>> //package testejena;
> > > >>>> 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.rdf.model.ModelFactory;
> > > >>>> import com.hp.hpl.jena.util.FileManager; import
> > > >>>> com.hp.hpl.jena.util.iterator.ExtendedIterator;
> > > >>>> import java.io.InputStream;
> > > >>>> import java.util.Iterator;
> > > >>>>PropertyImpl
> > > >>>> public class testeProp {
> > > >>>>      static final String inputFileName = "newspaper.owl";
> > > >>>>      public static void main(String args[]) {
> > > >>>>          try {
> > > >>>>              //create the reasoning model using the base
> > > >>>>              OntModel inf =
> > > >>>> ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
> > > >>>>
> > > >>>>              // use the FileManager to find the input file
> > > >>>>              InputStream in =
> FileManager.get().open(inputFileName);
> > > >>>>              if (in == null) {
> > > >>>>                  throw new IllegalArgumentException("File: " +
> > > >>>> inputFileName + " not found");
> > > >>>>              }
> > > >>>>
> > > >>>>              inf.read(in, "");
> > > >>>>
> > > >>>>              String URI =
> > > >>>> "http://www.owl-ontologies.com/Ontology1363337688.owl#";;
> > > >>>>
> > > >>>>              ExtendedIterator classes = inf.listClasses();
> > > >>>>              while (classes.hasNext()) {
> > > >>>>                  OntClass essaClasse = (OntClass) classes.next();
> > > >>>>
> > > >>>>                  String vClasse =
> > > essaClasse.getLocalName().toString();
> > > >>>>
> > > >>>>                  if (essaClasse.hasSubClass()) {
> > > >>>>                      System.out.println("Classe: " + vClasse);
> > > >>>>                      OntClass cla = inf.getOntClass(URI +
> vClasse);
> > > >>>>                      for (Iterator i = cla.listSubClasses();
> > > >>>> i.hasNext();) {
> > > >>>>                          OntClass c = (OntClass) i.next();
> > > >>>>                          System.out.print("   " + c.getLocalName()
> > + "
> > > >>> "
> > > >>>> + "\n");
> > > >>>>                      }
> > > >>>>                  }
> > > >>>>              }
> > > >>>>          } catch (Exception e) {
> > > >>>>              System.out.println("there may be error");
> > > >>>>              System.out.println(e.getMessage());
> > > >>>>          }
> > > >>>>      }
> > > >>>> }
> > > >>>>
> > > >>>>
> > > >>>>
> > ----------------------------------------------------------------------
> > > >>> -
> > > >>>> --------------------------- if i run my program i got the
> following
> > > >>>> error:
> > > >>>>
> > > >>>>
> > > >>>> Exception in thread "main" java.lang.NoClassDefFoundError:
> > > >>>> org/apache/commons/logging/LogFactory
> > > >>>>          at
> > > >>>>
> > com.hp.hpl.jena.rdf.model.impl.PropertyImpl.<clinit>(PropertyImpl.java
> > > >>> :
> > > >>>> 58)
> > > >>>>          at
> > > >>>>
> > com.hp.hpl.jena.enhanced.BuiltinPersonalities.<clinit>(BuiltinPersonal
> > > >>> i
> > > >>>> ties.java:28)
> > > >>>>          at
> > > >>>> com.hp.hpl.jena.rdf.model.impl.ModelCom.<init>(ModelCom.java:51)
> > > >>>>          at
> > > >>>>
> > com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel(ModelFactory
> > > >>> .
> > > >>>> java:119)
> > > >>>>          at
> > > >>>>
> > com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel(ModelFactory
> > > >>> .
> > > >>>> java:113)
> > > >>>>          at
> > > >>>>
> > com.hp.hpl.jena.rdf.model.impl.ModelSpecImpl.<clinit>(ModelSpecImpl.ja
> > > >>> v
> > > >>>> a:56)
> > > >>>>          at testeProp.main(testeProp.java:16) Caused by:
> > > >>>> java.lang.ClassNotFoundException:
> > > >>>> org.apache.commons.logging.LogFactory
> > > >>>>          at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> > > >>>>          at java.security.AccessController.doPrivileged(Native
> > Method)
> > > >>>>          at
> > java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> > > >>>>          at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> > > >>>>          at
> > > >>>> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> > > >>>>          at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> > > >>>>          ... 7 more
> > > >>>> Java Result: 1
> > > >>>> BUILD SUCCESSFUL (total time: 0 seconds)
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>> please anyone help me...
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>
> > > >
> > > >
> > >
> >
>
  • Re: Milorad Tosic
    • RE: John A. Fereira
      • Re: Andy Seaborne
        • Re: aarthi
          • Re: aarthi
            • Re: Mark Fischer
              • Re: aarthi
                • Re: Mark Fischer
            • Re: Milorad Tosic

Reply via email to