Package au.csiro.ontology

Examples of au.csiro.ontology.Factory


        // This set will contain the base axioms
        Set<Axiom> baseAxioms = new HashSet<Axiom>();
       
        // The factory can be used to create axioms using the default
        // implementing classes
        Factory f = new Factory();
       
        // The factory returns IConcepts - in this case the actual type is
        // INamedConcept<String>
        Concept endocardium = f.createNamedConcept("Endocardium");
        Concept tissue = f.createNamedConcept("Tissue");
        Concept heartWall = f.createNamedConcept("HeartWall");
        Concept heartValve = f.createNamedConcept("HeartValve");
        Concept bodyWall = f.createNamedConcept("BodyWall");
        Concept heart = f.createNamedConcept("Heart");
        Concept bodyValve = f.createNamedConcept("BodyValve");
        Concept endocarditis = f.createNamedConcept("Endocarditis");
        Concept inflammation = f.createNamedConcept("Inflammation");
        Concept disease = f.createNamedConcept("Disease");
        Concept heartDisease = f.createNamedConcept("HeartDisease");
        Concept criticalDisease = f.createNamedConcept("CriticalDisease");
       
        // The factory can also be used to create roles
        Role actsOn = f.createNamedRole("acts-on");
        Role partOf = f.createNamedRole("part-of");
        Role contIn = f.createNamedRole("cont-in");
        Role hasLoc = f.createNamedRole("has-loc");
       
        // Finally, the factory can be used to create axioms
        Concept lhs = endocardium;
        Concept rhs = f.createConjunction(
                tissue,
                f.createExistential((NamedRole) contIn, heartWall),
                f.createExistential((NamedRole) contIn, heartValve)
        );
        baseAxioms.add(f.createConceptInclusion(lhs, rhs));
       
        lhs = heartWall;
        rhs = f.createConjunction(
                bodyWall,
                f.createExistential((NamedRole) partOf, heart)
        );
        baseAxioms.add(f.createConceptInclusion(lhs, rhs));
       
        lhs = heartValve;
        rhs = f.createConjunction(
                bodyValve,
                f.createExistential((NamedRole) partOf, heart)
        );
        baseAxioms.add(f.createConceptInclusion(lhs, rhs));
       
        lhs = endocarditis;
        rhs = f.createConjunction(
                inflammation,
                f.createExistential((NamedRole) hasLoc, endocardium)
        );
        baseAxioms.add(f.createConceptInclusion(lhs, rhs));

        lhs = inflammation;
        rhs = f.createConjunction(
                disease,
                f.createExistential(actsOn, tissue)
        );
        baseAxioms.add(f.createConceptInclusion(lhs, rhs));
       
        lhs = f.createConjunction(
                heartDisease,
                f.createExistential(hasLoc, heartValve)
        );
        rhs = criticalDisease;
        baseAxioms.add(f.createConceptInclusion(lhs, rhs));
       
        // There is no direct support in the API to create an equivalence axiom
        // so it has to be created using two concept inclusion axioms
        lhs = heartDisease;
        rhs = f.createConjunction(
                disease,
                f.createExistential(hasLoc, heart)
        );
        baseAxioms.add(f.createConceptInclusion(lhs, rhs));
        baseAxioms.add(f.createConceptInclusion(rhs, lhs));
       
        Role[] rlhs = new Role[]{partOf, partOf};
        Role rrhs = partOf;
        baseAxioms.add(f.createRoleInclusion(rlhs, rrhs));
       
        rlhs = new Role[]{partOf};
        rrhs = contIn;
        baseAxioms.add(f.createRoleInclusion(rlhs, rrhs));
       
        rlhs = new Role[]{hasLoc, contIn};
        rrhs = hasLoc;
        baseAxioms.add(f.createRoleInclusion(rlhs, rrhs));
       
        // The first time the classify method is called it runs a full
        // classification
        reasoner.loadAxioms(baseAxioms);
        reasoner.classify();
       
        // If classification worked properly then Endocarditis should be
        // classified not only as an Inflammation but also as a HeartDisease
        // and a CriticalDisease
        Ontology t = reasoner.getClassifiedOntology();
       
        // We use the same id that was used to create the concept to look for
        // the corresponding node in the taxonomy
        Node endocarditisNode = t.getNode("Endocarditis");
        System.out.println("Node for endocarditis:\n  "+
                endocarditisNode.getEquivalentConcepts());
       
       
        // We can now print the equivalent concepts in the node and the parent
        // nodes
        Set<Node> parentNodes = endocarditisNode.getParents();
        System.out.println("Parents of endocarditis:");
        for(Node parentNode : parentNodes) {
            System.out.println("  "+parentNode.getEquivalentConcepts());
        }
       
        // We can now add more axioms to the ontology and re-run the
        // classification
        Set<Axiom> additionalAxioms = new HashSet<Axiom>();
       
        Concept heartInflammation = f.createNamedConcept("HeartInflammation");
       
        lhs = heartInflammation;
        rhs = inflammation;
        additionalAxioms.add(f.createConceptInclusion(lhs, rhs));
       
        lhs = endocarditis;
        rhs = f.createConjunction(
                heartInflammation,
                f.createExistential(hasLoc, endocardium)
        );
        additionalAxioms.add(f.createConceptInclusion(lhs, rhs));
       
        // Subsequent invocations will trigger an incremental classification
        System.out.println("Running incremental classification:");
        reasoner.loadAxioms(additionalAxioms);
        reasoner.classify();
View Full Code Here


        // This set will contain the axioms
        Set<Axiom> axioms = new HashSet<Axiom>();
       
        // The factory can be used to create axioms using the default
        // implementing classes
        Factory f = new Factory();
       
        // The factory returns IConcepts - in this case the actual type is
        // INamedConcept<String>
        Concept nonCardiacChestPain = f.createNamedConcept("274668005");
        Concept duringExcersice = f.createNamedConcept("309604004");
        Concept interview = f.createNamedConcept("108217004");
        Concept present = f.createNamedConcept("52101004");
       
        // The factory can also be used to create roles
        Role associatedWith = f.createNamedRole("47429007");
       
        // We need to define exactly what the identifier for the new concept
        // will be
        Concept historyCardioStandardNonAnginalChestPainExertion = f.createNamedConcept("pce_24220");
       
        // This is the axiom created for the discernable
        axioms.add(
            f.createConceptInclusion(
                historyCardioStandardNonAnginalChestPainExertion,
                f.createConjunction(
                        nonCardiacChestPain,
                        f.createExistential(associatedWith, duringExcersice)
                )
        ));
       
        // This is the axiom created for the qualifier
        axioms.add(
            f.createConceptInclusion(
                historyCardioStandardNonAnginalChestPainExertion,
                interview
            )
        );
       
        // This is the axiom created for the value
        axioms.add(
            f.createConceptInclusion(
                historyCardioStandardNonAnginalChestPainExertion,
                present
            )
        );
       
View Full Code Here

            }
        }
       
        // 3. Add test axiom
        System.out.println("Adding test axiom");
        Factory f = new Factory();
        String newId = UUID.randomUUID().toString();
        uuidToDescMap.put(newId, "Special Appendicits");
       
        Concept specialAppendicitis = f.createNamedConcept(newId);
        String appendicitsUuid = "55450fab-6786-394d-89f9-a0fd44bd7e7e";
        Concept appendicitis = f.createNamedConcept(appendicitsUuid);
        Axiom a1 = f.createConceptInclusion(specialAppendicitis, appendicitis);
        Set<Axiom> axioms = new HashSet<Axiom>();
        axioms.add(a1);
       
        // 4. Classify incrementally
        System.out.println("Classifying incrementally");
View Full Code Here

     * </ol>
     *
     */
    public static void bottlesExample() {
        // A factory is used to create expressions and axioms
        Factory f = new Factory();
       
        // Create all the concepts
        Concept bottle = f.createNamedConcept("bottle");
        Concept plasticBottle = f.createNamedConcept("plasticBottle");
        Concept glassBottle = f.createNamedConcept("glassBottle");
        Concept purplePlasticBottle = f.createNamedConcept("purplePlasticBottle");
        Concept plastic = f.createNamedConcept("plastic");
        Concept tallBottle = f.createNamedConcept("tallBottle");
        Concept wideBottle = f.createNamedConcept("wideBottle");
        Concept wineBottle = f.createNamedConcept("wineBottle");
       
        // Create all the roles
        Role isMadeOf = f.createNamedRole("isMadeOf");
       
        // Create all the features
        Feature hasHeight = f.createNamedFeature("hasHeight");
        Feature hasWidth = f.createNamedFeature("hasWidth");
       
        Set<Axiom> axioms = new HashSet<Axiom>();
       
        // This is an example of a primitive child with no roles.
        Axiom a0 = new ConceptInclusion(glassBottle, bottle);
        axioms.add(a0);
       
        // This is an example of a fully defined child with one role. In this
        // case two axioms are needed because the API does not support
        // equivalence directly.
        Axiom a1 = new ConceptInclusion(
                plasticBottle,
                f.createConjunction(
                        bottle,
                        f.createExistential(isMadeOf, plastic)
                )
        );
        Axiom a1b = new ConceptInclusion(
                f.createConjunction(
                        bottle,
                        f.createExistential(isMadeOf, plastic)
                ),
                plasticBottle
        );
        axioms.add(a1);
        axioms.add(a1b);
       
        // This is an example of a primitive child with no roles
        Axiom a2 = new ConceptInclusion(
                purplePlasticBottle,
                plasticBottle
        );
        axioms.add(a2);
       
        // This is an example of a fully defined child with a concrete domain
        Axiom a3 = new ConceptInclusion(
                tallBottle,
                f.createConjunction(
                        bottle,
                        f.createDatatype(
                                hasHeight,
                                Operator.GREATER_THAN,
                                f.createIntegerLiteral(5))
                )
        );
       
        Axiom a3b = new ConceptInclusion(
                f.createConjunction(
                        bottle,
                        f.createDatatype(
                                hasHeight,
                                Operator.GREATER_THAN,
                                f.createIntegerLiteral(5))
                ),
                tallBottle
        );
        axioms.add(a3);
        axioms.add(a3b);
       
        // This is another example of a fully defined child with a concrete
        // domain
        Axiom a4 = new ConceptInclusion(
                wideBottle,
                f.createConjunction(
                        bottle,
                        f.createDatatype(
                                hasWidth,
                                Operator.GREATER_THAN,
                                f.createIntegerLiteral(5))
                )
        );
       
        Axiom a4b = new ConceptInclusion(
                f.createConjunction(
                        bottle,
                        f.createDatatype(
                                hasWidth,
                                Operator.GREATER_THAN,
                                f.createIntegerLiteral(5))
                ),
                wideBottle
        );
        axioms.add(a4);
        axioms.add(a4b);
       
        // Yet another example of a fully defined child with a concrete domain
        Axiom a5 = new ConceptInclusion(
                wineBottle,
                f.createConjunction(
                        glassBottle,
                        f.createDatatype(
                                hasWidth,
                                Operator.EQUALS,
                                f.createIntegerLiteral(2)),
                        f.createDatatype(
                                hasHeight,
                                Operator.EQUALS,
                                f.createIntegerLiteral(6))
                )
        );
        Axiom a5b = new ConceptInclusion(
                f.createConjunction(
                        glassBottle,
                        f.createDatatype(
                                hasWidth,
                                Operator.EQUALS,
                                f.createIntegerLiteral(2)),
                        f.createDatatype(
                                hasHeight,
                                Operator.EQUALS,
                                f.createIntegerLiteral(6))
                ),
                wineBottle
        );
        axioms.add(a5);
        axioms.add(a5b);
View Full Code Here

TOP

Related Classes of au.csiro.ontology.Factory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.