Java 类org.semanticweb.owlapi.model.OWLNamedIndividual 实例源码

项目:Resource2Vec    文件:R2VManager.java   
/**
 * @param superclass
 * @param o
 * @return
 */
private static Set<OWLIndividual> getIndividuals(String superclass,
        OWLOntology o) {

    OWLReasoner reasoner = PelletReasonerFactory.getInstance()
            .createReasoner(o);
    Set<OWLNamedIndividual> instances = reasoner.getInstances(
            OWL.Class(IRI.create(superclass)), false).getFlattened();

    // filter out all owl:sameAs instances...
    Set<OWLIndividual> ind = new TreeSet<>();
    for (OWLNamedIndividual i : instances) {
        ind.add(i);
    }
    logger.info("|I| = " + ind.size());
    logger.debug("I = " + ind);

    return ind;

}
项目:Resource2Vec    文件:R2VModel.java   
/**
 * Euclidean distance of two individuals within the model.
 * 
 * @param a
 * @param b
 * @return
 */
public Double distance(OWLNamedIndividual a, OWLNamedIndividual b) {
    HashMap<String, Double> aV = instances.get(a.toString()).getFlatSparseVector();
    HashMap<String, Double> bV = instances.get(b.toString()).getFlatSparseVector();
    TreeSet<String> commonSpace = new TreeSet<>();
    commonSpace.addAll(aV.keySet());
    commonSpace.addAll(bV.keySet());
    Double sum = 0d;
    for(String dim : commonSpace) {
        Double aVal = aV.containsKey(dim) ? aV.get(dim) : 0d;
        Double bVal = bV.containsKey(dim) ? bV.get(dim) : 0d;
        logger.trace(aVal + "\t" + bVal + "\t" + Math.pow(aVal - bVal, 2));
        sum += Math.pow(aVal - bVal, 2);
    }
    return Math.sqrt(sum);
}
项目:Wolpertinger    文件:NaiveTranslation.java   
/**
 *
 * @see org.semanticweb.owlapi.model.OWLAxiomVisitor#visit(org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom)
 */

public void visit(OWLNegativeObjectPropertyAssertionAxiom negObjPropertyAssertion) {
    //assert !negObjPropertyAssertion.getProperty().isAnonymous();

    OWLObjectProperty property = negObjPropertyAssertion.getProperty().asOWLObjectProperty();
    String propertyName = mapper.getPredicateName(property);

    OWLNamedIndividual subject = negObjPropertyAssertion.getSubject().asOWLNamedIndividual();
    OWLNamedIndividual object = negObjPropertyAssertion.getObject().asOWLNamedIndividual();

    String subjectName = mapper.getConstantName(subject);
    String objectName = mapper.getConstantName(object);

    writer.print(ASP2CoreSymbols.CLASSICAL_NEGATION);
    writer.print(propertyName);
    writer.print(ASP2CoreSymbols.BRACKET_OPEN);
    writer.print(subjectName);
    writer.print(ASP2CoreSymbols.ARG_SEPERATOR);
    writer.print(objectName);
    writer.print(ASP2CoreSymbols.BRACKET_CLOSE);
    writer.print(ASP2CoreSymbols.EOR);
}
项目:owltools    文件:ABoxUtils.java   
public static void randomizeClassAssertions(OWLOntology ont, int num) {
    Set<OWLClassAssertionAxiom> caas = new HashSet<OWLClassAssertionAxiom>();
    Set<OWLClassAssertionAxiom> caasNew = new HashSet<OWLClassAssertionAxiom>();
        Set<OWLNamedIndividual> inds = ont.getIndividualsInSignature(Imports.INCLUDED);
    OWLNamedIndividual[] indArr = (OWLNamedIndividual[]) inds.toArray();
    for (OWLNamedIndividual ind : inds) {
        caas.addAll( ont.getClassAssertionAxioms(ind) );
    }
    for (OWLClassAssertionAxiom caa : caas) {
        OWLIndividual randomIndividual = null;
        caasNew.add(ont.getOWLOntologyManager().getOWLDataFactory().getOWLClassAssertionAxiom(caa.getClassExpression(), 
                randomIndividual));
    }
    ont.getOWLOntologyManager().removeAxioms(ont, caas);
    ont.getOWLOntologyManager().addAxioms(ont, caasNew);
}
项目:Wolpertinger    文件:OWLNormalization.java   
public void visit(SWRLDataRangeAtom atom) {
    if (atom.getArgument() instanceof SWRLVariable)
        throwVarError(atom);
    // dr(literal) :-
    // convert to: ClassAssertion(DataSomeValuesFrom(freshDP DataOneOf(literal)) freshIndividual)
    // and top -> \forall freshDP.dr
    OWLLiteral lit=((SWRLLiteralArgument)atom.getArgument()).getLiteral();
    OWLDataRange dr=atom.getPredicate();
    OWLNamedIndividual freshIndividual=getFreshIndividual();
    OWLDataProperty freshDP=getFreshDataProperty();
    OWLDataSomeValuesFrom some=m_factory.getOWLDataSomeValuesFrom(freshDP,m_factory.getOWLDataOneOf(lit));
    OWLClassExpression definition=getDefinitionFor(some,m_alreadyExists);
    if (!m_alreadyExists[0])
        m_newInclusions.add(new OWLClassExpression[] { negative(definition),some });
    addFact(m_factory.getOWLClassAssertionAxiom(definition,freshIndividual));
    m_newInclusions.add(new OWLClassExpression[] { m_factory.getOWLDataAllValuesFrom(freshDP,dr) });
}
项目:owltools    文件:FastOwlSim.java   
public List<ElementPairScores> findMatches(Set<OWLClass> atts, String targetIdSpace, double minSimJPct, double minMaxIC) throws Exception {
    Set<OWLNamedIndividual> candidateTargetSet;

    if (targetIdSpace == null) { 
        candidateTargetSet = getAllElements();
    }
    else {
        candidateTargetSet = new HashSet<OWLNamedIndividual>();
        for (OWLNamedIndividual j : getAllElements()) {
            if (j.getIRI().toString().contains("/"+targetIdSpace+"_")) {
                candidateTargetSet.add(j);
            }

        }
    }
    return findMatchesWithin(atts, candidateTargetSet, minSimJPct, minMaxIC);
}
项目:minerva    文件:MapInferenceProvider.java   
public static InferenceProvider create(OWLReasoner r, OWLOntology ont) {
    Map<OWLNamedIndividual, Set<OWLClass>> inferredTypes = new HashMap<>();
    boolean isConsistent = r.isConsistent();
    if (isConsistent) {
        Set<OWLNamedIndividual> individuals = ont.getIndividualsInSignature();
        for (OWLNamedIndividual individual : individuals) {
            Set<OWLClass> inferred = new HashSet<>();
            Set<OWLClass> flattened = r.getTypes(individual, true).getFlattened();
            for (OWLClass cls : flattened) {
                if (cls.isBuiltIn() == false) {
                    inferred.add(cls);
                }
            }
            inferredTypes.put(individual, inferred);
        }
    }
    return new MapInferenceProvider(isConsistent, inferredTypes);
}
项目:logmap-matcher    文件:StructuralReasoner2.java   
public NodeSet<OWLClass> getTypes(OWLNamedIndividual ind, boolean direct) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
    ensurePrepared();
    DefaultNodeSet<OWLClass> result = new OWLClassNodeSet();
    for (OWLOntology ontology : getRootOntology().getImportsClosure()) {
        for (OWLClassAssertionAxiom axiom : ontology.getClassAssertionAxioms(ind)) {
            OWLClassExpression ce = axiom.getClassExpression();
            if (!ce.isAnonymous()) {
                result.addNode(classHierarchyInfo.getEquivalents(ce.asOWLClass()));
                if (!direct) {
                    result.addAllNodes(getSuperClasses(ce, false).getNodes());
                }
            }
        }
    }
    return result;
}
项目:owltools    文件:SimCommandRunner.java   
/**
 * performs all by all individual comparison
 * @param opts 
 * @throws UnknownOWLClassException 
 */
public void runOwlSim(Opts opts) throws UnknownOWLClassException {
    sos.setSimProperties(simProperties);
    OWLPrettyPrinter owlpp = getPrettyPrinter();
    if (opts.nextEq("-q")) {
        runOwlSimOnQuery(opts, opts.nextOpt());
        return;
    }
    Set<OWLNamedIndividual> insts = pproc.getOutputOntology().getIndividualsInSignature();
    LOG.info("All by all for "+insts.size()+" individuals");
    for (OWLNamedIndividual i : insts) {
        for (OWLNamedIndividual j : insts) {
            // similarity is symmetrical
            if (isComparable(i,j)) {
                showSim(i,j, owlpp);
            }
        }
    }
    LOG.info("FINISHED All by all for "+insts.size()+" individuals");
}
项目:minerva    文件:CoreMolecularModelManager.java   
public OWLObjectPropertyAssertionAxiom removeAnnotations(ModelContainer model, OWLObjectPropertyExpression p,
        OWLNamedIndividual i, OWLNamedIndividual j, Set<OWLAnnotation> annotations, METADATA metadata) {
    OWLOntology ont = model.getAboxOntology();
    Set<OWLObjectPropertyAssertionAxiom> axioms = ont.getObjectPropertyAssertionAxioms(i);
    OWLObjectPropertyAssertionAxiom toModify = null;
    for (OWLObjectPropertyAssertionAxiom axiom : axioms) {
        if (p.equals(axiom.getProperty()) && j.equals(axiom.getObject())) {
            toModify = axiom;
            break;
        }
    }
    OWLObjectPropertyAssertionAxiom newAxiom = null;
    if (toModify != null) {
        Set<OWLAnnotation> combindedAnnotations = new HashSet<OWLAnnotation>(toModify.getAnnotations());
        combindedAnnotations.removeAll(annotations);
        newAxiom = modifyAnnotations(toModify, combindedAnnotations, model, metadata);
    }
    return newAxiom;
}
项目:owltools    文件:SimCommandRunner.java   
private void showSim(OWLNamedIndividual i, OWLNamedIndividual j, OWLPrettyPrinter owlpp) {
    ScoreAttributeSetPair maxic = sos.getSimilarityMaxIC(i, j);
    if ( maxic.score < getPropertyAsDouble(SimConfigurationProperty.minimumMaxIC)) {
        return;
    }
    double s = sos.getElementJaccardSimilarity(i, j);
    if (s < getPropertyAsDouble(SimConfigurationProperty.minimumSimJ)) {
        return;
    }
    ScoreAttributeSetPair bma = sos.getSimilarityBestMatchAverageAsym(i, j);

    System.out.println("SimJ\t"+renderPair(i,j, owlpp)+"\t"+s);

    System.out.println("MaxIC\t"+renderPair(i,j, owlpp)+"\t"+maxic.score+"\t"+show(maxic.attributeClassSet, owlpp));

    System.out.println("BMAasym\t"+renderPair(i,j, owlpp)+"\t"+bma.score+"\t"+show(bma.attributeClassSet, owlpp));  
}
项目:minerva    文件:MolecularModelManager.java   
public List<OWLNamedIndividual> addAnnotations(ModelContainer model, String pid, 
        String iid, String jid, Set<OWLAnnotation> annotations, METADATA metadata) throws UnknownIdentifierException {
    OWLObjectProperty property = getObjectProperty(pid, model);
    if (property == null) {
        throw new UnknownIdentifierException("Could not find a property for id: "+pid);
    }
    OWLNamedIndividual individual1 = getIndividual(iid, model);
    if (individual1 == null) {
        throw new UnknownIdentifierException("Could not find a individual (1) for id: "+iid);
    }
    OWLNamedIndividual individual2 = getIndividual(jid, model);
    if (individual2 == null) {
        throw new UnknownIdentifierException("Could not find a individual (2) for id: "+jid);
    }
    addAnnotations(model, property, individual1, individual2, annotations, metadata);

    return Arrays.asList(individual1, individual2);
}
项目:OntoBench    文件:NamedIndividualFeature.java   
@Override
public void addToOntology() {
  OWLClass clazz = featurePool.getReusableClass();
  OWLNamedIndividual individual = factory.getOWLNamedIndividual(":NamedIndividual", pm);

  addAxiomToOntology(factory.getOWLClassAssertionAxiom(clazz, individual));
}
项目:OntoBench    文件:OwlSameAsFeature.java   
@Override
public void addToOntology() {
  OWLNamedIndividual i1 = factory.getOWLNamedIndividual(":SameAs_Individual1", pm);
  OWLNamedIndividual i2 = factory.getOWLNamedIndividual(":SameAs_Individual2", pm);

  addAxiomToOntology(factory.getOWLSameIndividualAxiom(i1, i2));
}
项目:OntoBench    文件:OwlAllDifferentFeature.java   
@Override
public void addToOntology() {
  OWLNamedIndividual i1 = factory.getOWLNamedIndividual(":AllDifferent_Individual1", pm);
  OWLNamedIndividual i2 = factory.getOWLNamedIndividual(":AllDifferent_Individual2", pm);
  OWLNamedIndividual i3 = factory.getOWLNamedIndividual(":AllDifferent_Individual3", pm);
  OWLNamedIndividual i4 = factory.getOWLNamedIndividual(":AllDifferent_Individual4", pm);

  addAxiomToOntology(factory.getOWLDifferentIndividualsAxiom(i1, i2, i3, i4));
}
项目:OntoBench    文件:OwlNegativeDataPropertyAssertionFeature.java   
@Override
public void addToOntology() {
  OWLNamedIndividual source = factory.getOWLNamedIndividual(":NegativeDataPropertyAssertion_SourceIndividual", pm);
  OWLLiteral target = factory.getOWLLiteral("NegativeDataPropertyAssertion_TargetValue");
  OWLDataProperty property = factory.getOWLDataProperty(":negativeDataPropertyAssertionProperty", pm);

  addAxiomToOntology(factory.getOWLNegativeDataPropertyAssertionAxiom(property, source, target));
}
项目:OntoBench    文件:OwlNegativeObjectPropertyAssertionFeature.java   
@Override
public void addToOntology() {
  OWLNamedIndividual source = factory.getOWLNamedIndividual(":NegativeObjectPropertyAssertion_SourceIndividual", pm);
  OWLNamedIndividual target = factory.getOWLNamedIndividual(":NegativeObjectPropertyAssertion_TargetIndividual", pm);
  OWLObjectProperty property = featurePool.getExclusiveProperty(":negativeObjectPropertyAssertionProperty");

  addAxiomToOntology(factory.getOWLNegativeObjectPropertyAssertionAxiom(property, source, target));
}
项目:OntoBench    文件:MultipleIndividualsFeature.java   
@Override
public void addToOntology() {
  OWLClass clazz = featurePool.getExclusiveClass(baseIri);
  List<OWLNamedIndividual> individuals = new ArrayList<>(individualCount);

  for (int i = 1; i <= individualCount; i++) {
    individuals.add(factory.getOWLNamedIndividual(baseIri + "_" + i, pm));
  }

  individuals.forEach(individual -> addAxiomToOntology(factory.getOWLClassAssertionAxiom(clazz, individual)));
}
项目:OntoBench    文件:OwlObjectOneOfFeature.java   
@Override
public void addToOntology() {
  OWLNamedIndividual i1 = factory.getOWLNamedIndividual(":ObjectOneOf_Individual1", pm);
  OWLNamedIndividual i2 = factory.getOWLNamedIndividual(":ObjectOneOf_Individual2", pm);
  OWLObjectOneOf oneOf = factory.getOWLObjectOneOf(i1, i2);

  OWLClass oneOfClass = featurePool.getExclusiveClass(":ObjectOneOf");

  addAxiomToOntology(factory.getOWLEquivalentClassesAxiom(oneOfClass, oneOf));
}
项目:OntoBench    文件:OwlObjectOneOfOwl2RlFeature.java   
@Override
public void addToOntology() {
  OWLNamedIndividual i1 = factory.getOWLNamedIndividual(":ObjectOneOf_RL_Individual1", pm);
  OWLNamedIndividual i2 = factory.getOWLNamedIndividual(":ObjectOneOf_RL_Individual2", pm);
  OWLObjectOneOf oneOf = factory.getOWLObjectOneOf(i1, i2);

  OWLClass oneOfClass = featurePool.getExclusiveClass(":ObjectOneOf_RL");

  addAxiomToOntology(factory.getOWLSubClassOfAxiom(oneOf, oneOfClass));
}
项目:OntoBench    文件:OwlObjectOneOfOwl2ElFeature.java   
@Override
public void addToOntology() {
  OWLNamedIndividual individual = factory.getOWLNamedIndividual(":ObjectOneOf_EL_Individual", pm);
  OWLObjectOneOf oneOf = factory.getOWLObjectOneOf(individual);

  OWLClass oneOfClass = featurePool.getExclusiveClass(":ObjectOneOf_EL");

  addAxiomToOntology(factory.getOWLSubClassOfAxiom(oneOfClass, oneOf));
}
项目:OBEP    文件:SemanticEvent.java   
public SemanticEvent(OWLNamedIndividual message, String packetID, long timeStamp, String stream) {
    this.axioms = new HashSet<OWLAxiom>();
    this.message = message;
    this.packetID = packetID;
    this.timeStamp = timeStamp;
    this.stream = stream;
}
项目:Resource2Vec    文件:R2VInstance.java   
public R2VInstance(R2VModel model, OWLNamedIndividual ind) {
    super();
    this.model = model;
    this.ind = ind;
    this.uri = ind.toString();
    this.features = new HashMap<>();
}
项目:Resource2Vec    文件:R2VModel.java   
/**
 * @param ind
 * @return
 */
public Double distanceFromMeanPoint(OWLNamedIndividual ind) {
    HashMap<String, Double> aV = instances.get(ind.toString()).getFlatSparseVector();
    HashMap<String, Double> bV = getMeanPoint();
    Double sum = 0d;
    for(String dim : bV.keySet()) {
        Double aVal = aV.containsKey(dim) ? aV.get(dim) : 0d;
        Double bVal = bV.get(dim);
        sum += Math.pow(aVal - bVal, 2);
    }
    return Math.sqrt(sum);
}
项目:owltools    文件:TransformationUtils.java   
public static void addLabel(OWLNamedIndividual i, OWLGraphWrapper g, OWLReasoner reasoner) {
    OWLOntology ontology = g.getSourceOntology();
    Set<OWLClass> types = new HashSet<>();
    if (reasoner == null) {
        for (OWLClassExpression x : OwlHelper.getTypes(i, ontology)) {
            if (!x.isAnonymous()) {
                types.add((OWLClass) x);
            }
        }
    }
    else {
         types = reasoner.getTypes(i, true).getFlattened();
    }
    StringBuffer iLabel = null;
    for (OWLClass type : types) {
        String label = g.getLabel(type);
        if (iLabel == null)
            iLabel = new StringBuffer("a");
        else
            iLabel.append(" & ");
        iLabel.append(" "+label);
    }
    OWLDataFactory df = g.getDataFactory();
    OWLAxiom ax =
            df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()),
            i.getIRI(), 
            df.getOWLLiteral(iLabel.toString()));
    g.getManager().addAxiom(ontology,
            ax);
}
项目:HermiT-android    文件:Reasoner.java   
protected boolean containsFreshEntities(OWLObject... objects) {
    for (OWLObject object : objects) {
        if (!(object instanceof OWLEntity)
                || !((OWLEntity) object).isBuiltIn()) {
            for (OWLDataProperty dp : object.getDataPropertiesInSignature())
                if (!isDefined(dp)
                        && !Prefixes.isInternalIRI(dp.getIRI().toString()))
                    return true;
            for (OWLObjectProperty op : object
                    .getObjectPropertiesInSignature())
                if (!isDefined(op)
                        && !Prefixes.isInternalIRI(op.getIRI().toString()))
                    return true;
            for (OWLNamedIndividual individual : object
                    .getIndividualsInSignature())
                if (!isDefined(individual)
                        && !Prefixes.isInternalIRI(individual.getIRI()
                                .toString()))
                    return true;
            for (OWLClass owlClass : object.getClassesInSignature())
                if (!isDefined(owlClass)
                        && !Prefixes.isInternalIRI(owlClass.getIRI()
                                .toString()))
                    return true;
        }
    }
    return false;
}
项目:ontocomplib    文件:IndividualObject.java   
public boolean hasType(OWLClassExpression type, OWLNamedIndividual individual) {
    boolean ret = false;
    Set<OWLClassAssertionAxiom> set = getContext().getReasoner().getRootOntology().getClassAssertionAxioms(individual);
    for (OWLClassAssertionAxiom axiom : set) {
        ret = ret || getContext().isSubClassOf(axiom.getClassExpression(), type);
    }
    return ret;
}
项目:owltools    文件:Sim2CommandRunner.java   
@Deprecated
public void OLDinstanceICValues(Opts opts) throws Exception {
    try {
        loadProperties(opts);
        pproc = new NullSimPreProcessor();
        pproc.setInputOntology(g.getSourceOntology());
        pproc.setOutputOntology(g.getSourceOntology());
        if (owlsim == null) {
            owlsim = getOwlSimFactory().createOwlSim(g.getSourceOntology());
            ((SimpleOwlSim) owlsim).setSimPreProcessor(pproc);
            owlsim.createElementAttributeMapFromOntology();
        }
        Set<OWLNamedIndividual> insts = pproc.getOutputOntology()
                .getIndividualsInSignature();
        LOG.info("Writing IC values for all " + insts.size() + " annotations.");

        for (OWLNamedIndividual i : insts) {
            for (OWLClass c : owlsim.getAttributesForElement(i)) {
                resultOutStream.print(g.getIdentifier(i));
                resultOutStream.print("\t");
                resultOutStream.print(g.getIdentifier(c));
                resultOutStream.print("\t");
                resultOutStream.print(owlsim.getInformationContentForAttribute(c));
                resultOutStream.println();
                resultOutStream.flush();
            }
        }

    } finally {
        IOUtils.closeQuietly(resultOutStream);
    }

}
项目:jcel    文件:Translator.java   
public Set<IntegerNamedIndividual> translateSI(Node<OWLNamedIndividual> owlObject) {
    Set<IntegerNamedIndividual> ret = new HashSet<>();
    owlObject.getEntities().forEach(indiv -> {
        ret.add(translateI(indiv));
    });
    return Collections.unmodifiableSet(ret);
}
项目:owltools    文件:SimEngine.java   
private boolean excludeObjectFromComparison(OWLObject a) {
    System.out.println("TESTING:"+a);
    //boolean exclude = false;
    if (excludeClassesInComparison && !(a instanceof OWLNamedIndividual)) {
        return true;
    }
    if (this.comparisonSuperclass != null) {
        if (!graph.getSubsumersFromClosure(a).contains(comparisonSuperclass)) {
            return true;
        }
    }
    return false;
}
项目:logmap-matcher    文件:OAEI2015InstanceProcessing.java   
public int getPublicationCount(OWLOntology onto, OWLNamedIndividual indiv){

    OWLObjectProperty author_of = onto.getOWLOntologyManager().getOWLDataFactory().
            getOWLObjectProperty(IRI.create("http://islab.di.unimi.it/imoaei2015#author_of"));

    OWLDataProperty publication_count = onto.getOWLOntologyManager().getOWLDataFactory().
            getOWLDataProperty(IRI.create("http://islab.di.unimi.it/imoaei2015#publication_count"));

    Set<OWLIndividual> publications = indiv.getObjectPropertyValues(author_of, onto);
    Set<OWLLiteral> data_values;

    try {
        //They have not been grouped or there are not publications
        if (publications.size()>1 || publications.isEmpty()){
            return publications.size();
        }

        for (OWLIndividual pub : publications){

            data_values = pub.getDataPropertyValues(publication_count, onto);

            for (OWLLiteral value : data_values){
                //if (value.isInteger()){
                    return value.parseInteger();
                //}
            }
        }
        return 1;

    }
    catch (Exception e){
        LogOutput.printError("Error extracting information about publications.");
        return 0;
    }

}
项目:minerva    文件:LegoModelWalker.java   
private Set<OWLObjectSomeValuesFrom> getSvfTypes(OWLNamedIndividual i, OWLOntology model) {
    Set<OWLClassAssertionAxiom> axioms = model.getClassAssertionAxioms(i);
    final Set<OWLObjectSomeValuesFrom> svfs = new HashSet<OWLObjectSomeValuesFrom>();
    for (OWLClassAssertionAxiom axiom : axioms) {
        axiom.getClassExpression().accept(new OWLClassExpressionVisitorAdapter(){

            @Override
            public void visit(OWLObjectSomeValuesFrom svf) {
                svfs.add(svf);
            }
        });
    }
    return svfs;
}
项目:owltools    文件:LegoTools.java   
public List<LegoNode> createLegoNodes(Collection<OWLNamedIndividual> individuals) throws UnExpectedStructureException {
    List<LegoNode> nodes = new ArrayList<LegoNode>(individuals.size());
    Set<OWLOntology> ontologies = new HashSet<OWLOntology>(graph.getAllOntologies());
    for (OWLNamedIndividual individual : individuals) {
        Set<OWLClassAssertionAxiom> axioms = getClassAxioms(individual, ontologies);
        final LegoNode node = createNode(individual, axioms, ontologies);
        if (node != null) {
            // links
            List<LegoLink> links = new ArrayList<LegoLink>();
            Set<OWLObjectPropertyAssertionAxiom> propertyAxioms = getPropertyAxioms(individual, ontologies);
            for (OWLObjectPropertyAssertionAxiom propertyAxiom : propertyAxioms) {
                OWLIndividual object = propertyAxiom.getObject();
                if (object instanceof OWLNamedIndividual == false) {
                    throw new UnExpectedStructureException("Expected a named individual for a link: "+propertyAxiom);
                }
                OWLNamedIndividual namedTarget = (OWLNamedIndividual) object;
                OWLObjectPropertyExpression property = propertyAxiom.getProperty();
                LegoLink link = new LegoLink(individual, namedTarget, property);
                LegoMetadata.extractMetadata(link, propertyAxiom);
                links.add(link);
            }
            if (!links.isEmpty()) {
                node.setLinks(links);
            }

            nodes.add(node);
        }
    }

    return nodes;
}
项目:skoseditor    文件:SKOSConceptSchemeInferredHierarchyViewComponent.java   
public Set<OWLNamedIndividual> getConceptSchemes () {

        Set<OWLNamedIndividual> inds = new HashSet<OWLNamedIndividual>(10);

        for (OWLOntology onto  : getOWLEditorKit().getModelManager().getOntologies()) {
            Set<OWLClassAssertionAxiom> axioms = onto.getClassAssertionAxioms(getOWLEditorKit().getModelManager().getOWLDataFactory().getOWLClass(SKOSVocabulary.CONCEPTSCHEME.getIRI()));
            for (OWLClassAssertionAxiom axiom : axioms) {
                inds.add(axiom.getIndividual().asOWLNamedIndividual());
            }

        }
        return inds;
    }
项目:minerva    文件:GafToLegoTranslator.java   
private OWLAxiom labelAxiom(OWLDataFactory f, OWLNamedIndividual individual, String annLabel) {
    return 
            f.getOWLAnnotationAssertionAxiom(
                    f.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()),
                    individual.getIRI(),
                    f.getOWLLiteral(annLabel));
}
项目:owltools    文件:OWLGraphWrapperExtended.java   
/**
 * Returns an OWLNamedIndividual with this IRI <b>if it has been declared</b>
 * in the source or support ontologies. Returns null otherwise.
 * 
 * @param iri
 * @return {@link OWLNamedIndividual}
 */
public OWLNamedIndividual getOWLIndividual(IRI iri) {
    OWLNamedIndividual c = getDataFactory().getOWLNamedIndividual(iri);
    for (OWLOntology o : getAllOntologies()) {
        for (OWLDeclarationAxiom da : o.getDeclarationAxioms(c)) {
            if (da.getEntity() instanceof OWLNamedIndividual) {
                return (OWLNamedIndividual) da.getEntity();
            }
        }
    }
    return null;
}
项目:owltools    文件:SimJSONTest.java   
@Test
public void testSearch() throws Exception {
    ParserWrapper pw = new ParserWrapper();
    sourceOntol = pw.parseOBO(getResource("sim/mp-subset-1.obo").getAbsolutePath());
    g =  new OWLGraphWrapper(sourceOntol);
    parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);

    owlpp = new OWLPrettyPrinter(g);
    final int truncLen = 200;

    // assume buffering
    OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
    try {

        createOwlSim();
            //sos.setReasoner(reasoner);
        LOG.info("Reasoner="+owlsim.getReasoner());

        SimJSONEngine sj = new SimJSONEngine(g, owlsim);

        //sos.saveOntology("/tmp/z.owl");

        reasoner.flush();

        owlsim.createElementAttributeMapFromOntology();
        owlsim.computeSystemStats();


        for (OWLNamedIndividual i : sourceOntol.getIndividualsInSignature()) {
            Set<OWLClass> atts = owlsim.getAttributesForElement(i);
            String jsonStr = sj.search(atts, "MGI", true, false);

            LOG.info(jsonStr);
        }

    }
    finally {
        reasoner.dispose();
    }
}
项目:owltools    文件:OwlHelper.java   
public static Set<OWLClassExpression> getTypes(OWLNamedIndividual i, OWLOntology ont) {
    Set<OWLClassExpression> types;
    if (i != null && ont != null) {
        types = new HashSet<>();
        for (OWLClassAssertionAxiom axiom : ont.getClassAssertionAxioms(i)) {
            types.add(axiom.getClassExpression());
        }
    }
    else {
        types = Collections.emptySet();
    }
    return types;
}
项目:minerva    文件:OperationsImpl.java   
private OWLNamedIndividual getIndividual(String id, BatchHandlerValues values) throws UnknownIdentifierException {
    if (values.notVariable(id)) {
        IRI iri = curieHandler.getIRI(id); 
        OWLNamedIndividual i = m3.getIndividual(iri, values.model);
        if (i == null) {
            throw new UnknownIdentifierException("No individual found for id: '"+id+"' and IRI: "+iri+" in model: "+values.model.getModelId());
        }
        return i;
    }
    return values.getVariableValue(id);
}
项目:owltools    文件:DescriptionTreeSimilarity.java   
private OWLClassExpression makeClassExpression(OWLObject x) {
    if (x instanceof OWLClassExpression)
        return (OWLClassExpression) x;
    else if (x instanceof OWLNamedIndividual) {
        // TODO - move this to graphwrapper
        Set<OWLNamedIndividual> nis = new HashSet<OWLNamedIndividual>();
        nis.add((OWLNamedIndividual) x);
        return graph.getDataFactory().getOWLObjectOneOf(nis);
    }
    else {
        System.err.println("cannot make CE from:"+x);
    }
    return null;
}