当前位置: 首页>>代码示例>>Java>>正文


Java OWLNamedIndividual类代码示例

本文整理汇总了Java中org.semanticweb.owlapi.model.OWLNamedIndividual的典型用法代码示例。如果您正苦于以下问题:Java OWLNamedIndividual类的具体用法?Java OWLNamedIndividual怎么用?Java OWLNamedIndividual使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OWLNamedIndividual类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLNamedIndividual类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIndividuals

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
/**
 * @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;

}
 
开发者ID:AKSW,项目名称:Resource2Vec,代码行数:25,代码来源:R2VManager.java

示例2: distance

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:AKSW,项目名称:Resource2Vec,代码行数:23,代码来源:R2VModel.java

示例3: visit

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
/**
 *
 * @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);
}
 
开发者ID:wolpertinger-reasoner,项目名称:Wolpertinger,代码行数:27,代码来源:NaiveTranslation.java

示例4: randomizeClassAssertions

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
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);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:17,代码来源:ABoxUtils.java

示例5: visit

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
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) });
}
 
开发者ID:wolpertinger-reasoner,项目名称:Wolpertinger,代码行数:18,代码来源:OWLNormalization.java

示例6: findMatches

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
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);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:18,代码来源:FastOwlSim.java

示例7: create

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
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);
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:19,代码来源:MapInferenceProvider.java

示例8: getTypes

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
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;
}
 
开发者ID:ernestojimenezruiz,项目名称:logmap-matcher,代码行数:17,代码来源:StructuralReasoner2.java

示例9: runOwlSim

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:SimCommandRunner.java

示例10: removeAnnotations

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
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;
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:20,代码来源:CoreMolecularModelManager.java

示例11: showSim

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
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));	
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:18,代码来源:SimCommandRunner.java

示例12: addAnnotations

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
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);
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:19,代码来源:MolecularModelManager.java

示例13: addToOntology

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
@Override
public void addToOntology() {
  OWLClass clazz = featurePool.getReusableClass();
  OWLNamedIndividual individual = factory.getOWLNamedIndividual(":NamedIndividual", pm);

  addAxiomToOntology(factory.getOWLClassAssertionAxiom(clazz, individual));
}
 
开发者ID:VisualDataWeb,项目名称:OntoBench,代码行数:8,代码来源:NamedIndividualFeature.java

示例14: addToOntology

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
@Override
public void addToOntology() {
  OWLNamedIndividual i1 = factory.getOWLNamedIndividual(":SameAs_Individual1", pm);
  OWLNamedIndividual i2 = factory.getOWLNamedIndividual(":SameAs_Individual2", pm);

  addAxiomToOntology(factory.getOWLSameIndividualAxiom(i1, i2));
}
 
开发者ID:VisualDataWeb,项目名称:OntoBench,代码行数:8,代码来源:OwlSameAsFeature.java

示例15: addToOntology

import org.semanticweb.owlapi.model.OWLNamedIndividual; //导入依赖的package包/类
@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));
}
 
开发者ID:VisualDataWeb,项目名称:OntoBench,代码行数:10,代码来源:OwlAllDifferentFeature.java


注:本文中的org.semanticweb.owlapi.model.OWLNamedIndividual类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。