Package au.csiro.ontology.model

Examples of au.csiro.ontology.model.NamedConcept


    }

    protected Concept getConcept(String id, Map<String, Concept> ci) {
        Concept c = ci.get(id);
        if (c == null) {
            c = new NamedConcept(id);
            ci.put(id, c);
        }
        return c;
    }
View Full Code Here


                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));
                                }
                            }
                        }
                    }

                    axioms.add(new ConceptInclusion(new NamedConcept(c1), new Conjunction(conjs)));

                    if (primitive.get(c1).equals("0")) {
                        axioms.add(new ConceptInclusion(new Conjunction(conjs), new NamedConcept(c1)));
                    }
                }
            }
           
            Statistics.INSTANCE.setTime("rf1 loading", System.currentTimeMillis() - start);
View Full Code Here

            if (axiom instanceof OWLDeclarationAxiom) {
                OWLDeclarationAxiom a = (OWLDeclarationAxiom)axiom;
                OWLEntity ent = a.getEntity();
                if (ent.isOWLClass()) {
                    res.add(new ConceptInclusion(
                            new NamedConcept(ent.asOWLClass().toStringID()), NamedConcept.TOP_CONCEPT));
                } else if (ent.isOWLObjectProperty()) {
                    // Do nothing for now.
                } else if (ent.isOWLDataProperty()) {
                    // Do nothing for now.
                }
View Full Code Here

                if (("<"+THING_IRI+">").equals(id) || THING_IRI.equals(id))
                    push(NamedConcept.TOP_CONCEPT);
                else if (("<"+NOTHING_IRI+">").equals(id) || NOTHING_IRI.equals(id))
                    push(NamedConcept.BOTTOM_CONCEPT);
                else
                    push(new NamedConcept(id));
            }

        });

        if (stack.size() != 1) {
View Full Code Here

    }

    protected Concept getConcept(String id, Map<String, Concept> ci) {
        Concept c = ci.get(id);
        if (c == null) {
            c = new NamedConcept(id);
            ci.put(id, c);
        }
        return c;
    }
View Full Code Here

     */
    protected Concept transformToModel(Object obj) {
        if(obj instanceof NamedConcept) {
            return (NamedConcept) obj;
        } else if(obj instanceof String) {
            return new NamedConcept((String) obj);
        } else if(obj instanceof au.csiro.snorocket.core.model.Conjunction) {
            au.csiro.snorocket.core.model.Conjunction conj = (au.csiro.snorocket.core.model.Conjunction) obj;
            List<Concept> conjs = new ArrayList<Concept>();
            for(AbstractConcept ac : conj.getConcepts()) {
                conjs.add(transformToModel(ac));
            }
            return new Conjunction(conjs.toArray(new Concept[conjs.size()]));
        } else if(obj instanceof au.csiro.snorocket.core.model.Existential) {
            au.csiro.snorocket.core.model.Existential ex = (au.csiro.snorocket.core.model.Existential) obj;
            String roleId = (String) factory.lookupRoleId(ex.getRole());
            Concept con = transformToModel(ex.getConcept());
            return new Existential(new NamedRole(roleId), con);
        } else if(obj instanceof au.csiro.snorocket.core.model.Datatype) {
            au.csiro.snorocket.core.model.Datatype dt = (au.csiro.snorocket.core.model.Datatype) obj;
            String featureId = factory.lookupFeatureId(dt.getFeature());
            Literal l = transformLiteralToModel(dt.getLiteral());
            return new Datatype(new NamedFeature(featureId), dt.getOperator(), l);
        } else if(obj instanceof au.csiro.snorocket.core.model.Concept) {
            au.csiro.snorocket.core.model.Concept c = (au.csiro.snorocket.core.model.Concept) obj;
            Object id = factory.lookupConceptId(c.hashCode());
            if(id instanceof String) {
                return new NamedConcept((String) id);
            } else if(id instanceof NamedConcept) {
                // If TOP or BOTTOM
                return (NamedConcept) id;
            } else {
                return transformToModel(id);
View Full Code Here

                continue;
            }
           
            Concept rhs = getNecessary(contextIndex, taxonomy, key);

            final Concept lhs = new NamedConcept(id);
            if (!lhs.equals(rhs) && !rhs.equals(NamedConcept.TOP_CONCEPT)) { // skip trivial axioms
                inferred.add(new ConceptInclusion(lhs, rhs));
            }
        }

        return inferred;
View Full Code Here

        final Node node = taxonomy.get(id);
        if (node != null) {
            for (final Node parent: node.getParents()) {
                final String parentId = parent.getEquivalentConcepts().iterator().next();
                if (!NamedConcept.TOP.equals(parentId)) {      // Top is redundant
                    result.add(new NamedConcept(parentId));
                }
            }
            // Look for Datatype concepts
            final IntIterator ancestorItr = contextIndex.get(key).getS().iterator();
            while (ancestorItr.hasNext()) {
                int anc = ancestorItr.next();
                if (factory.isVirtualConcept(anc)) {
                    Object c = factory.lookupConceptId(anc);
                    if (c instanceof au.csiro.snorocket.core.model.Datatype) {
                        addDatatype(result, (au.csiro.snorocket.core.model.Datatype) c);
                    }
                }
            }
        } else if (id instanceof au.csiro.snorocket.core.model.Conjunction) {
            // In this case, we have a result of normalisation so we reach inside and grab out the parents
            for (AbstractConcept conjunct: ((au.csiro.snorocket.core.model.Conjunction) id).getConcepts()) {
                if (conjunct instanceof au.csiro.snorocket.core.model.Concept) {
                    final int conjunctInt = ((au.csiro.snorocket.core.model.Concept) conjunct).hashCode();
                    final String conjunctId = factory.lookupConceptId(conjunctInt).toString();
                    result.add(new NamedConcept(conjunctId));
                } else if (conjunct instanceof au.csiro.snorocket.core.model.Datatype) {
                    addDatatype(result, (au.csiro.snorocket.core.model.Datatype) conjunct);
                }
            }
        } else {
            // Ignore
        }
       
        final Context ctx = contextIndex.get(key);
        CR succ = ctx.getSucc();
       
        for(int roleId : succ.getRoles()) {
            NamedRole role = new NamedRole(factory.lookupRoleId(roleId).toString());
            IConceptSet values = getLeaves(succ.lookupConcept(roleId));
            for (IntIterator itr2 = values.iterator(); itr2.hasNext(); ) {
                int valueInt = itr2.next();
                if (!factory.isVirtualConcept(valueInt)) {
                    final String valueId = factory.lookupConceptId(valueInt).toString();
                    result.add(new Existential(role, new NamedConcept(valueId)));
                } else {
                    final Concept valueConcept = getNecessary(contextIndex, taxonomy, valueInt);
                    final Existential x = new Existential(role, Builder.build(no, valueConcept));
                    result.add(x);
                }
View Full Code Here

*/
@SuppressWarnings("deprecation")
public class Factory {

    public static Concept createNamedConcept(String id) {
        return new NamedConcept(id);
    }
View Full Code Here

     */
    protected Concept transformToModel(Object obj) {
        if(obj instanceof NamedConcept) {
            return (NamedConcept) obj;
        } else if(obj instanceof String) {
            return new NamedConcept((String) obj);
        } else if(obj instanceof au.csiro.snorocket.core.model.Conjunction) {
            au.csiro.snorocket.core.model.Conjunction conj = (au.csiro.snorocket.core.model.Conjunction) obj;
            List<Concept> conjs = new ArrayList<Concept>();
            for(AbstractConcept ac : conj.getConcepts()) {
                conjs.add(transformToModel(ac));
            }
            return new Conjunction(conjs.toArray(new Concept[conjs.size()]));
        } else if(obj instanceof au.csiro.snorocket.core.model.Existential) {
            au.csiro.snorocket.core.model.Existential ex = (au.csiro.snorocket.core.model.Existential) obj;
            String roleId = (String) factory.lookupRoleId(ex.getRole());
            Concept con = transformToModel(ex.getConcept());
            return new Existential(new NamedRole(roleId), con);
        } else if(obj instanceof au.csiro.snorocket.core.model.Datatype) {
            au.csiro.snorocket.core.model.Datatype dt = (au.csiro.snorocket.core.model.Datatype) obj;
            String featureId = factory.lookupFeatureId(dt.getFeature());
            Literal l = transformLiteralToModel(dt.getLiteral());
            return new Datatype(new NamedFeature(featureId), dt.getOperator(), l);
        } else if(obj instanceof au.csiro.snorocket.core.model.Concept) {
            au.csiro.snorocket.core.model.Concept c = (au.csiro.snorocket.core.model.Concept) obj;
            Object id = factory.lookupConceptId(c.hashCode());
            if(id instanceof String) {
                return new NamedConcept((String) id);
            } else if(id instanceof NamedConcept) {
                // If TOP or BOTTOM
                return (NamedConcept) id;
            } else {
                return transformToModel(id);
View Full Code Here

TOP

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

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.