On Mon, Jan 14, 2013 at 2:53 PM, hlel emna <[email protected]> wrote:
> thank you, I can solve the problem.
> an other problem:
> I have the following classes: woman, man
> Date of marriage is dataProperty woman
> john is an instance of human
> pretty is an instance of woman
> emna is an instance of woman
> john marie pretty in 1998
> john marie emna in 1990
> how I can add this information?
> my code:
> OntModel m=
> ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
> String ns ="http://www.w3.org/2002/07/owl#";
> String base="http://www.w3.org/2002/07/owl";
> //create class
> OntClass f = m.createClass(ns+ "femme" );
> OntClass h = m.createClass(ns+ "homme" );
>
> // create individual
> Individual h1 = m.createIndividual( ns+"john", h );//ns
> Individual f1 = m.createIndividual( ns + "pretty", f );
> Individual f2 = m.createIndividual( ns + "emna", f );
> //create ObjectProperty
> ObjectProperty ma = m.createObjectProperty(ns + "marier" );
> ma.addDomain(h);ma.addRange(f);
> //create DataProperty
> DatatypeProperty datemariage =
> m.createDatatypeProperty(ns+"marriagedate");
> datemariage.addDomain(h);
> //add they information: john marie pretty in 1998 and
> //john marie emna in 1990
> h1.addProperty(ma,f1);
> h1.addProperty(datemariage,"1990");
>
> FileOutputStream writer =new
> FileOutputStream("G:\\thése\\Rech12\\ENCD\\pizza\\context.owl");
> m.write(writer, "RDF/XML");
> please help me
It may be helpful to think of marriage as a 3-ary predicate:
marier : person x person x date
so that you have
marier( john, pretty, "1998" )
Relationships of any arity can be represented in RDF by reifying the
relationship (i.e., creating an individual for each instance of the
relationship) and attaching its components to it. Your RDF
representation would reify the relationship "marriage" so that have
individuals
_:m3 a :Marriage . // 1990 marriage
_:m78 a :Marriage . // 1998 marriage
You then attach the parts to it:
_:m3 a :Marriage ;
:hasHusband :john ;
:hasWife :pretty ;
:hasYear "1990" .
_:m78 a :Marriage ;
:hasHusband :john ;
:hasWife :emna ;
:hasYear "1998" .
If you still want to have a :marier predicate around, it might be
worthwhile to add some inference capability (e.g., with Jena rules, or
OWL) that would to relate the reified representation with the direct
representation. There are plenty of resources about reification for
n-ary relations in RDF. The English Wikipedia entry [1] might be a
useful start.
//JT
[1] http://en.wikipedia.org/wiki/Reification_(computer_science)#RDF_and_OWL
--
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/