public PeopleOntology(Ontology base) { super(ONTOLOGY_NAME, base, new ReflectiveIntrospector()); try { PrimitiveSchema stringSchema = (PrimitiveSchema) getSchema(BasicOntology.STRING); PrimitiveSchema integerSchema = (PrimitiveSchema) getSchema(BasicOntology.INTEGER); ConceptSchema addressSchema = new ConceptSchema(ADDRESS); addressSchema.add(STREET, stringSchema, ObjectSchema.OPTIONAL); addressSchema.add(NUMBER, integerSchema, ObjectSchema.OPTIONAL); addressSchema.add(CITY, stringSchema); ConceptSchema personSchema = new ConceptSchema(PERSON); personSchema.add(NAME, stringSchema); personSchema.add(ADDRESS, addressSchema, ObjectSchema.OPTIONAL); ConceptSchema manSchema = new ConceptSchema(MAN); manSchema.addSuperSchema(personSchema); ConceptSchema womanSchema = new ConceptSchema(WOMAN); womanSchema.addSuperSchema(personSchema); add(personSchema, Person.class); add(manSchema, Man.class); add(womanSchema, Woman.class); add(addressSchema, Address.class); AggregateSchema childrenSchema = new AggregateSchema(BasicOntology.SEQUENCE); PredicateSchema fatherOfSchema = new PredicateSchema(FATHER_OF); fatherOfSchema.add(FATHER, manSchema); fatherOfSchema.add(CHILDREN, childrenSchema); PredicateSchema motherOfSchema = new PredicateSchema(MOTHER_OF); motherOfSchema.add(MOTHER, womanSchema); motherOfSchema.add(CHILDREN, childrenSchema); add(fatherOfSchema, FatherOf.class); add(motherOfSchema, MotherOf.class); AgentActionSchema marrySchema = new AgentActionSchema(MARRY); marrySchema.add(HUSBAND, manSchema); marrySchema.add(WIFE, womanSchema); add(marrySchema); } catch (OntologyException oe) { oe.printStackTrace(); } }
/** * Add a slot of type PredicateSchema to this schema. * * @param name The name of the slot. * @param slotSchema The schema of the slot. * @param optionality The optionality, i.e. <code>OPTIONAL</code> or <code>MANDATORY</code> */ public void add(String name, PredicateSchema slotSchema, int optionality) { super.add(name, slotSchema, optionality); }
/** * Add a mandatory slot of type PredicateSchema to this schema. * * @param name The name of the slot. * @param slotSchema The schema of the slot. */ public void add(String name, PredicateSchema slotSchema) { super.add(name, slotSchema); }