⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 relationirreflexivity.java

📁 toocom源代码,主要应用在本体匹配方面!
💻 JAVA
字号:
package toocom.ocgl;

import java.util.*;
import java.awt.Graphics;

/**
 * This class represents the irreflexivity of a relation.
 *
 * @author Fr閐閞ic F黵st
 */
public class RelationIrreflexivity extends AxiomSchemaOne{
	
	public RelationIrreflexivity(RelationType r){
		super(CGConstants.getRelationIrreflexivityTerms(),r);
	}
		
	/** A primitive can be irreflexive if it is a relation, if its arity is 2, if the two 
	 *  concepts of its signature are defined and have the same type and if it is not reflexive. */
	public boolean isValid(){
		return (super.cp instanceof RelationType) &&
				(((RelationType) super.cp).getArity() == 2) &&
				(((RelationType) super.cp).getSignature().getConceptType(1) != null) &&
				(((RelationType) super.cp).getSignature().getConceptType(2) != null) &&
				((RelationType) super.cp).getSignature().getConceptType(1).equals(((RelationType) super.cp).getSignature().getConceptType(2)) &&
			    !super.cp.hasAxiomSchema("toocom.ocgl.RelationReflexivity");
	}
	
	public Axiom getAxiomForm(){
		Axiom axiom = new Axiom(CGConstants.getRelationIrreflexivityTerms());
		axiom.getTerms().appendWithSeparator(((RelationType) super.cp).getTerms()," - ");
		Relation r = new Relation((RelationType) super.cp);
		r.setTerms(r.getTerms().denyTerms());
		ConceptType ct = ((RelationType) super.cp).getSignature().getConceptType(1);
		Concept c = new Concept(ct);
		r.setLinkedConcept(c,1);
		r.setLinkedConcept(c,2);
		axiom.addHypothesisConcept(c);
		axiom.addConclusionRelation(r);
		return axiom;
	}
	
	/** An irreflexivity axiom schema is operationalized, in an inferential context of use,
	 *  by a rule, and, in a validation context of use, by a negative constraint. */
	public LinkedList getOperationalForm(Ontology onto,Language l){
		LinkedList result = new LinkedList();
		if(this.isValid()){
			if(this.cou.isInferential()){
				LinkedList li = this.cp.getAxiomSchemata("toocom.ocgl.RelationExclusivity");
				if(li.size() == 1){
					RelationExclusivity re = (RelationExclusivity) li.getFirst();
					RelationType exclu = (RelationType) re.getTheOtherPrimitive(this.cp);
					Rule rule = new Rule(CGConstants.getRuleTerms().appendAndCopy(CGConstants.getRelationIrreflexivityTerms()," : ").appendAndCopy(super.cp.getTerms()," - "));
					Concept c1 = new Concept(((RelationType) this.cp).getSignature().getConceptType(1));
					Concept c2 = new Concept(((RelationType) this.cp).getSignature().getConceptType(2));
					Relation r1 = new Relation((RelationType) this.cp);
					Relation r2 = new Relation(onto.getDifferenceRelationType());
					r1.setLinkedConcept(c1,1);
					r1.setLinkedConcept(c2,2);
					r2.setLinkedConcept(c1,1);
					r2.setLinkedConcept(c2,2);
					rule.addHypothesisConcept(c1);
					rule.addHypothesisConcept(c2);
					rule.addHypothesisRelation(r1);
					rule.addConclusionRelation(r2);
					result.add(rule);
				}
			}
			else{
				NegativeConstraint nc = new NegativeConstraint(CGConstants.getNegativeConstraintTerms().appendAndCopy(CGConstants.getRelationIrreflexivityTerms()," : ").appendAndCopy(super.cp.getTerms()," - "));
				Concept c = new Concept(((RelationType) this.cp).getSignature().getConceptType(1));
				Relation r = new Relation((RelationType) this. cp);
				r.setLinkedConcept(c,1);
				r.setLinkedConcept(c,2);
				nc.addHypothesisConcept(c);
				nc.addConclusionRelation(r);
				result.add(nc);
			}
		}
		return result;
	}
	
	public void paint(Graphics g,Language l){
		g.setColor(CGConstants.IRREFLEXIVITY_COLOR);
		g.drawString("I",super.cp.x - (CGConstants.PROPERTY_SYMBOLS_SPACING * 6),super.cp.y - (CGConstants.PROPERTY_SYMBOLS_SPACING * 4));	
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -