Package au.csiro.ontology.model

Examples of au.csiro.ontology.model.NamedRole


        }
        return c;
    }

    protected NamedRole getRole(String id, Map<String, NamedRole> ri) {
        NamedRole r = ri.get(id);
        if (r == null) {
            r = new NamedRole(id);
            ri.put(id, r);
        }
        return r;
    }
View Full Code Here


        protected void mapRoles(List<Concept> conjs, Set<RoleValuePair> rvs) {
            if (rvs.size() > 1) {
                Concept[] innerConjs = new Concept[rvs.size()];
                int j = 0;
                for (RoleValuePair rv : rvs) {
                    NamedRole role = getRole(rv.role, ri);
                    Concept filler = resolveFiller(getConcept(rv.value, ci), rv.id);
                    Existential exis = new Existential(role, filler);
                    innerConjs[j++] = exis;
                }
                // Wrap with a role group
                conjs.add(new Existential(getRole(roleGroupId, ri), new Conjunction(innerConjs)));
            } else {
                RoleValuePair first = rvs.iterator().next();
                NamedRole role = getRole(first.role, ri);
                Concept filler = resolveFiller(getConcept(first.value, ci), first.id);
                Existential exis = new Existential(role, filler);
                if (neverGroupedIds.contains(first.role)) {
                    // Does not need a role group
                    conjs.add(exis);
View Full Code Here

            // Add the role axioms
            for (String r1 : roles.keySet()) {
                String parentRole = roles.get(r1).get("parentrole");

                if (!"".equals(parentRole)) {
                    axioms.add(new RoleInclusion(new NamedRole(r1), new NamedRole(parentRole)));
                }

                String rightId = roles.get(r1).get("rightID");
                if (!"".equals(rightId)) {
                    axioms.add(new RoleInclusion(new Role[] { new NamedRole(r1), new NamedRole(rightId) },
                            new NamedRole(r1)));
                }
            }

            // Add concept axioms
            for (String c1 : primitive.keySet()) {
                if (roles.get(c1) != null)
                    continue;
                Set<String> prs = parents.get(c1);
                int numParents = (prs != null) ? prs.size() : 0;

                List<String[]> relsVal = rels.get(c1);
                int numRels = 0;
                if (relsVal != null)
                    numRels = 1;

                int numElems = numParents + numRels;

                if (numElems == 0) {
                    // do nothing
                } else if (numElems == 1 && (prs != null && !prs.isEmpty())) {
                    axioms.add(new ConceptInclusion(new NamedConcept(c1), new NamedConcept(prs.iterator().next())));
                } else {
                    List<Concept> conjs = new ArrayList<Concept>();
                   
                    if(prs != null) {
                        for (String pr : prs) {
                            conjs.add(new NamedConcept(pr));
                        }
                    }

                    if (relsVal != null) {
                        for (Set<RoleValuePair> rvs : groupRoles(relsVal)) {
                            if (rvs.size() > 1) {
                                List<Concept> innerConjs = new ArrayList<Concept>();
                                for (RoleValuePair rv : rvs) {
                                    NamedRole role = new NamedRole(rv.role);
                                    Concept filler = new NamedConcept(rv.value);
                                    Existential exis = new Existential(role, filler);
                                    innerConjs.add(exis);
                                }
                                // Wrap with a role group
                                conjs.add(new Existential(new NamedRole("RoleGroup"), new Conjunction(innerConjs)));
                            } else {
                                RoleValuePair first = rvs.iterator().next();
                                NamedRole role = new NamedRole(first.role);
                                Concept filler = new NamedConcept(first.value);
                                Existential exis = new Existential(role, filler);
                                if (metadata.getNeverGroupedIds().contains(first.role)) {
                                    // Does not need a role group
                                    conjs.add(exis);
                                } else {
                                    // Needs a role group
                                    conjs.add(new Existential(new NamedRole("RoleGroup"), exis));
                                }
                            }
                        }
                    }
View Full Code Here

        OWLObjectPropertyExpression sup = a.getSuperProperty();

        int size = sub.size();
        Role[] lhss = new Role[size];
        for (int i = 0; i < size; i++) {
            lhss[i] = new NamedRole(sub.get(i).asOWLObjectProperty().toStringID());
        }

        Role rhs = new NamedRole(sup.asOWLObjectProperty().toStringID());

        if (lhss.length == 1 || lhss.length == 2) {
            return new RoleInclusion(lhss, rhs);
        } else {
            problems.add("Unable to import axiom "+a.toString()+". RoleChains longer than 2 not supported.");
View Full Code Here

    private Axiom transformOWLSubObjectPropertyOfAxiom(OWLSubObjectPropertyOfAxiom a) {
        OWLObjectPropertyExpression sub = a.getSubProperty();
        OWLObjectPropertyExpression sup = a.getSuperProperty();

        Role lhs = new NamedRole(sub.asOWLObjectProperty().toStringID());
        Role rhs = new NamedRole(sup.asOWLObjectProperty().toStringID());

        return new RoleInclusion(new Role[]{lhs}, rhs);
    }
View Full Code Here

        return new RoleInclusion(new Role[]{lhs}, rhs);
    }

    private Axiom transformOWLReflexiveObjectPropertyAxiom(OWLReflexiveObjectPropertyAxiom a) {
        OWLObjectPropertyExpression exp = a.getProperty();
        return new RoleInclusion(new Role[] {}, new NamedRole(exp.asOWLObjectProperty().toStringID()));
    }
View Full Code Here

        return new RoleInclusion(new Role[] {}, new NamedRole(exp.asOWLObjectProperty().toStringID()));
    }

    private Axiom transformOWLTransitiveObjectPropertyAxiom(OWLTransitiveObjectPropertyAxiom a) {
        OWLObjectPropertyExpression exp = a.getProperty();
        Role r = new NamedRole(exp.asOWLObjectProperty().toStringID());
        return new RoleInclusion(new Role[] { r, r }, r);
    }
View Full Code Here

        for (OWLSubObjectPropertyOfAxiom ax : a.asSubObjectPropertyOfAxioms()) {
            OWLObjectPropertyExpression sub = ax.getSubProperty();
            OWLObjectPropertyExpression sup = ax.getSuperProperty();

            axioms.add(
                    new RoleInclusion(new NamedRole(sub.asOWLObjectProperty().toStringID()),
                    new NamedRole(sup.asOWLObjectProperty().toStringID()))
            );
        }
        return axioms;
    }
View Full Code Here

            public void visit(OWLObjectAllValuesFrom e) {
                unimplemented(e);
            }

            public void visit(OWLObjectSomeValuesFrom e) {
                NamedRole r = new NamedRole(e.getProperty().asOWLObjectProperty().toStringID());
                e.getFiller().accept(this);
                try {
                    push(new Existential(r, pop()));
                } catch(EmptyStackException ex) {
                    problems.add("Unable to add axiom " + e + " because of previous problems.");
View Full Code Here

        }
        return c;
    }

    protected NamedRole getRole(String id, Map<String, NamedRole> ri) {
        NamedRole r = ri.get(id);
        if (r == null) {
            r = new NamedRole(id);
            ri.put(id, r);
        }
        return r;
    }
View Full Code Here

TOP

Related Classes of au.csiro.ontology.model.NamedRole

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.