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


Java Node类代码示例

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


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

示例1: getDeterministicRepresentative

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
private <T extends OWLNamedObject> T getDeterministicRepresentative(Node<T> n) {
	T rep = null;
	// find lexical maximal entry as representative node
	for (T entry : n) {
		if (rep == null) {
			rep = entry;
		}
		else {
			// use IRI for comparison
			IRI repIRI = rep.getIRI();
			IRI entryIRI = entry.getIRI();
			if (entryIRI.compareTo(repIRI) > 0) {
				rep = entry;
			}
		}
	}
	return rep;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:19,代码来源:FastOwlSim.java

示例2: getAsymmetricElementGraphInformationContentSimilarity

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
public double getAsymmetricElementGraphInformationContentSimilarity(
		OWLNamedIndividual i, OWLNamedIndividual j) throws UnknownOWLClassException {
	// TODO - optimize
	Set<Node<OWLClass>> ci = getNamedCommonSubsumers(i, j);
	Set<Node<OWLClass>> cu = this.getInferredAttributes(j);
	double sumICboth = 0;
	double sumICunion = 0;
	for (Node<OWLClass> c : cu) {
		// TODO - we can avoid doing this twice by using xor in the bitmap
		OWLClass rep = getDeterministicRepresentative(c);
		sumICunion += getInformationContentForAttribute(rep);
		if (ci.contains(c)) {
			sumICboth += getInformationContentForAttribute(rep);
		}

	}
	return sumICboth / sumICunion;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:19,代码来源:FastOwlSim.java

示例3: getSimilarityMaxIC

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
public ScoreAttributeSetPair getSimilarityMaxIC(OWLNamedIndividual i,
		OWLNamedIndividual j) {
	Set<Node<OWLClass>> atts = getInferredAttributes(i);
	atts.retainAll(getInferredAttributes(j)); // intersection

	ScoreAttributeSetPair best = new ScoreAttributeSetPair(0.0);
	for (Node<OWLClass> n : atts) {
		OWLClass c = n.getRepresentativeElement();
		Double ic = this.getInformationContentForAttribute(c);
		if (Math.abs(ic - best.score) < 0.001) {
			// tie for best attribute
			best.addAttributeClass(c);
		}
		if (ic > best.score) {
			best = new ScoreAttributeSetPair(ic, c);
		}
	}
	return best;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:20,代码来源:SimpleOwlSim.java

示例4: testLCS

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
@Test
public void testLCS() throws OWLOntologyCreationException, OBOFormatParserException, IOException, UnknownOWLClassException {
	String idspace="mp";
	load(idspace);
	ABoxUtils.makeDefaultIndividuals(getOntology());
	precompute();
	OWLClass c1 = getCls("MP_0003737"); // ossification of pinnae
	OWLClass c2 = getCls("MP_0002895"); // abnormal otolithic membrane morphology
	Set<Node<OWLClass>> cs = owlsim.getNamedCommonSubsumers(c1, c2);
	msg("CS="+cs);
	// note: this test is inherently fragile, if MP changes drastically the test may need recofnigured
	assertTrue(cs.size() > 2);
	Set<Node<OWLClass>> lcs = owlsim.getNamedLowestCommonSubsumers(c1, c2);
	msg("LCS="+lcs);
	assertTrue(cs.size() > lcs.size());
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:17,代码来源:BigFastOwlSimTest.java

示例5: ancsProperBitmapCachedModifiable

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
public EWAHCompressedBitmap ancsProperBitmapCachedModifiable(OWLClass c) {
	if (properSuperclassBitmapMap != null && properSuperclassBitmapMap.containsKey(c)) {
		return properSuperclassBitmapMap.get(c);
	}
	
	Set<Integer> ancsInts = new HashSet<Integer>();
	for (Node<OWLClass> anc : reasoner.getSuperClasses(c, false)) {
		// TODO - verify robust for non-Rep elements
		OWLClass ac = anc.getRepresentativeElement();
		if (ac.equals(thing))
			continue;
		Integer ix = classIndex.get(ac);
		if (ix == null) {
			msg("??"+anc);
		}
		ancsInts.add(ix.intValue());
	}


	//msg(c + " ancs = "+caints.size());
	EWAHCompressedBitmap bm = bm(ancsInts);
	if (properSuperclassBitmapMap == null)
		properSuperclassBitmapMap = new HashMap<OWLClass,EWAHCompressedBitmap>();
	properSuperclassBitmapMap.put(c, bm);
	return bm;		
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:27,代码来源:SimSpeedTest.java

示例6: getDifferentIndividuals

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
public NodeSet<OWLNamedIndividual> getDifferentIndividuals(
		OWLNamedIndividual namedIndividual) {
	checkPreConditions(namedIndividual);
	if (!m_isConsistent) {
		Node<OWLNamedIndividual> node = new OWLNamedIndividualNode(
				getAllNamedIndividuals());
		return new OWLNamedIndividualNodeSet(Collections.singleton(node));
	}
	Individual individual = H(namedIndividual);
	Tableau tableau = getTableau();
	Set<Individual> result = new HashSet<Individual>();
	for (Individual potentiallyDifferentIndividual : m_dlOntology
			.getAllIndividuals())
		if (isResultRelevantIndividual(potentiallyDifferentIndividual)
				&& !individual.equals(potentiallyDifferentIndividual))
			if (!tableau.isSatisfiable(true, true, Collections
					.singleton(Atom.create(Equality.INSTANCE, individual,
							potentiallyDifferentIndividual)), null, null,
					null, null, new ReasoningTaskDescription(true,
							"is {0} different from {1}", individual,
							potentiallyDifferentIndividual)))
				result.add(potentiallyDifferentIndividual);
	return sortBySameAsIfNecessary(result);
}
 
开发者ID:robertoyus,项目名称:HermiT-android,代码行数:25,代码来源:Reasoner.java

示例7: init

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
private void init() {
	// default pre-processor
	NullSimPreProcessor pproc = new NullSimPreProcessor();
	pproc.setInputOntology(this.sourceOntology);
	pproc.setOutputOntology(this.sourceOntology);
	this.setSimPreProcessor(pproc);

	elementToAttributesMap = null;
	elementToInferredAttributesMap = new HashMap<OWLNamedIndividual,Set<Node<OWLClass>>>();
	attributeToElementsMap = new HashMap<OWLClass,Set<OWLNamedIndividual>>();

	lcsICcache = new HashMap<ClassExpressionPair, ScoreAttributePair>();
	icCache = new HashMap<OWLClass, Double>();
	csCache = new HashMap<ClassExpressionPair, Set<Node<OWLClass>>>();
	simStats = new SimStats();
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:17,代码来源:SimpleOwlSim.java

示例8: precomputeAttributeElementCount

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
/**
 * Mapping between an attribute (e.g. phenotype class) and the number of
 * instances it classifies
 */
protected void precomputeAttributeElementCount() {
	if (attributeElementCount != null) return;
	attributeElementCount = new HashMap<OWLClass, Integer>();
	// some high level attributes will classify all or most of the ABox;
	// this way may be faster...
	for (OWLNamedIndividual e : this.getAllElements()) {
		LOG.info("Incrementing count all attributes of " + e);
		LOG.info(" DIRECT ATTS: " + getAttributesForElement(e).size());
		for (Node<OWLClass> n : this.getInferredAttributes(e)) {
			for (OWLClass c : n.getEntities()) {
				if (!attributeElementCount.containsKey(c))
					attributeElementCount.put(c, 1);
				else
					attributeElementCount.put(c, attributeElementCount.get(c) + 1);
			}
		}
	}
	LOG.info("Finished precomputing attribute element count");
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:24,代码来源:SimpleOwlSim.java

示例9: OwlApiClassExpressionEquivalentClassesQueryTest

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
public OwlApiClassExpressionEquivalentClassesQueryTest(
		final QueryTestManifest<OWLClassExpression, EquivalentEntitiesTestOutput<OWLClass>> manifest) {
	super(manifest,
			new OwlApiReasoningTestDelegate<EquivalentEntitiesTestOutput<OWLClass>>(
					manifest) {

				@Override
				public EquivalentEntitiesTestOutput<OWLClass> getActualOutput()
						throws Exception {
					final Node<OWLClass> equivalent = getReasoner()
							.getEquivalentClasses(
									manifest.getInput().getQuery());
					return new OwlApiEquivalentEntitiesTestOutput(
							equivalent);
				}

				@Override
				public Class<? extends Exception> getInterruptionExceptionClass() {
					return ReasonerInterruptedException.class;
				}

			});
}
 
开发者ID:liveontologies,项目名称:elk-reasoner,代码行数:24,代码来源:OwlApiClassExpressionEquivalentClassesQueryTest.java

示例10: getInferredAttributes

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
public Set<Node<OWLClass>> getInferredAttributes(OWLNamedIndividual a) {
	// TODO - refactor this method - in previous versions of Elk it was
	// not possible to ask for the types an instance instantiates, now
	// with Elk 0.4 it is
	if (elementToInferredAttributesMap.containsKey(a))
		return new HashSet<Node<OWLClass>>(elementToInferredAttributesMap.get(a));
	Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>();
	for (OWLClass c : getAttributesForElement(a)) {
		// if nodes contains c, it also contains all subsumers of c
		if (nodes.contains(c)) continue;
		nodes.addAll(getNamedReflexiveSubsumers(c));
		// nodes.addAll(getReasoner().getSuperClasses(c, false).getNodes());
	}
	elementToInferredAttributesMap.put(a, nodes);
	return new HashSet<Node<OWLClass>>(nodes);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:17,代码来源:SimpleOwlSim.java

示例11: getObjectPropertyValues

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
public NodeSet<OWLNamedIndividual> getObjectPropertyValues(
		OWLNamedIndividual namedIndividual,
		OWLObjectPropertyExpression propertyExpression) {
	checkPreConditions(namedIndividual, propertyExpression);
	if (!m_isConsistent) {
		Node<OWLNamedIndividual> node = new OWLNamedIndividualNode(
				getAllNamedIndividuals());
		return new OWLNamedIndividualNodeSet(Collections.singleton(node));
	}
	AtomicRole role = H(propertyExpression.getNamedProperty());
	if (!m_dlOntology.containsObjectRole(role))
		return new OWLNamedIndividualNodeSet();
	initialisePropertiesInstanceManager();
	Individual individual = H(namedIndividual);
	Set<Individual> result;
	if (propertyExpression.getSimplified().isAnonymous()) {
		// inverse role
		result = m_instanceManager.getObjectPropertySubjects(role,
				individual);
	} else {
		// named role
		result = m_instanceManager
				.getObjectPropertyValues(role, individual);
	}
	return sortBySameAsIfNecessary(result);
}
 
开发者ID:evalincius,项目名称:Hermit_1.3.8_android,代码行数:27,代码来源:Reasoner.java

示例12: getLowestCommonSubsumersCommand

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
public void getLowestCommonSubsumersCommand() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, UnknownOWLClassException {
	if (isHelp()) {
		info("Returns LCSs using sim2");
		return;
	}
	headerOWL();
	OwlSim sos = getOWLSim();

	Set<OWLObject> objs = this.resolveEntityList();
	if (objs.size() == 2) {
		Iterator<OWLObject> oit = objs.iterator();
		OWLClass a = (OWLClass) oit.next();
		OWLClass b = (OWLClass) oit.next();
		Set<Node<OWLClass>> lcsNodes = sos.getNamedCommonSubsumers(a, b);
		for (Node<OWLClass> n : lcsNodes) {
			for (OWLClass c : n.getEntities()) {
				output(c);
			}
		}
	}
	else {
		// TODO - throw
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:OWLHandler.java

示例13: getEquivalentClasses

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
public Node<OWLClass> getEquivalentClasses(OWLClassExpression queryClassExpression) {
	classifyClasses();
	if (queryClassExpression.isOWLNothing()) {
           return getBottomClassNode();
       } else if (queryClassExpression.isOWLThing()) {
       	return getTopClassNode();
       } else if (queryClassExpression instanceof OWLClass ){
       	OWLClass queryClass = (OWLClass) queryClassExpression;
       	return owlClassHierarchyNodeToNode(classHierarchy.getNodeForElement(queryClass));
       }
	// not supported yet
	return new OWLClassNode();
}
 
开发者ID:wolpertinger-reasoner,项目名称:Wolpertinger,代码行数:14,代码来源:Wolpertinger.java

示例14: getEquivalentObjectProperties

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
@Override
public Node<OWLObjectPropertyExpression> getEquivalentObjectProperties(
		OWLObjectPropertyExpression objectPropertyExpression) throws InconsistentOntologyException,
		FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
	Objects.requireNonNull(objectPropertyExpression);
	logger.finer("getEquivalentObjectProperties(" + objectPropertyExpression + ")");
	Node<OWLObjectPropertyExpression> ret = getTranslator().translateSOPE(
			getReasoner().getEquivalentObjectProperties(getTranslator().translateOPE(objectPropertyExpression)));
	logger.finer("" + ret);
	return ret;
}
 
开发者ID:julianmendez,项目名称:jcel,代码行数:12,代码来源:JcelReasoner.java

示例15: getUnsatisfiableClasses

import org.semanticweb.owlapi.reasoner.Node; //导入依赖的package包/类
private Set<OWLClass> getUnsatisfiableClasses(boolean print) {
	
	try{
	
		Set<OWLClass> set;
	
		//Now the reasoner return a node structure. A Node contains the
		//set of entities which are equivalent
		Node<OWLClass> node = reasoner.getUnsatisfiableClasses();
	
		//set = node.getEntities();
		set = node.getEntitiesMinusBottom();
		
		//set.remove(datafactory.getOWLNothing());
		
		if (!set.isEmpty()) {
			if (print)
				System.err.println("The following classes are unsatisfiable: ");
			
			for(OWLClass cls : set) {
				if (print)
					System.err.println(" " + cls);
			}
		}
		else{
			if (print)
				System.out.println("There are '0' unsatisfiable classes.");
		}
		
		return set;
	}
	catch (Exception e){
		System.err.println("Error when invoking the reasoner to get unsatisfiable classes.");
		return new HashSet<OWLClass>();
	}
	
}
 
开发者ID:ernestojimenezruiz,项目名称:logmap-matcher,代码行数:38,代码来源:ReasonerAccessImpl.java


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