econniterativepartitioning.java
来自「Semantic Web Ontology Editor」· Java 代码 · 共 1,353 行 · 第 1/5 页
JAVA
1,353 行
cont = true; } } } } break; } } } if(cont) continue; //*** if C is IN AN Intersection/union and any of its components are in O2 if (!changed && this.ClassesInIntersections.get(desc)!=null) { Set aux = (HashSet) this.ClassesInIntersections.get(desc); for (Iterator iter2 = aux.iterator(); iter2.hasNext(); ) { OWLDescription intDesc = (OWLDescription) iter2.next(); if (checkState(intDesc, STATE_O2)) { if (DEBUG) System.out.println("Moving class "+getName(desc) + " because its IN AN INTERSECTION and one of its components has moved"); out.write("Moving class "+getName(desc) + " because its IN AN INTERSECTION and one of its components has moved <br>"); changed = makeStateChange(desc, STATE_O2, DescriptionsO1, DescriptionsO2); //Optimization: if(aux.size()>threshold){ Set aux2 = new HashSet(aux); for (Iterator it = aux2.iterator(); it.hasNext(); ) { OWLDescription d =(OWLDescription)it.next(); if(checkState(d, STATE_O1)) changed = makeStateChange(d, STATE_O2, DescriptionsO1, DescriptionsO2); } cont=true; } break; } } } if(cont) continue; if (!changed && this.ClassesInUnions.get(desc)!=null) { for (Iterator iter2 = ((HashSet) this.ClassesInUnions.get(desc)).iterator(); iter2.hasNext(); ) { OWLDescription intDesc = (OWLDescription) iter2.next(); if (checkState(intDesc, STATE_O2)) { if (DEBUG) System.out.println("Moving class "+getName(desc) + " because its IN A UNION and one of its components has moved"); out.write("Moving class "+getName(desc) + " because its IN A UNION and one of its components has moved <br>"); changed = makeStateChange(desc, STATE_O2, DescriptionsO1, DescriptionsO2); break; } } } } //****** end classes check copyChanged = changed | copyChanged; changed = false; //********** handle state changes for individuals in O1 copy = new HashSet(IndividualsO1); for (Iterator iter = copy.iterator(); iter.hasNext();) { OWLIndividual ind = (OWLIndividual) iter.next(); //*** check if type(a) = C and C in O2 for (Iterator iter2 = ind.getTypes(source).iterator(); iter2.hasNext();) { OWLDescription desc = (OWLDescription) iter2.next(); if (checkState(desc, STATE_O2)) { if (DEBUG) System.out.println("Moving individual " +getName(ind) + " because its an INSTANCE-OF class "+ getName(desc) + " and C has moved"); out.write("Moving individual " +getName(ind) + " because its an INSTANCE-OF class "+ getName(desc) + " and C has moved <br>"); changed = this.makeStateChange(ind, STATE_O2, this.IndividualsO1, this.IndividualsO2); break; } } //*** if R(a,b), then based on R.. Set relProps = new HashSet(); relProps.addAll(ind.getDataPropertyValues(source).keySet()); relProps.addAll(ind.getObjectPropertyValues(source).keySet()); if (!changed) { for (Iterator iter2 = relProps.iterator(); iter2.hasNext();) { OWLProperty prop = (OWLProperty) iter2.next(); if (this.checkPropertyCausingTransitionA(prop)) { if (DEBUG) System.out.println("Moving individual 'a' " +getName(ind) + " because R(a,b), where R is "+ getName(prop) + " and R has moved"); out.write("Moving individual 'a' " +getName(ind) + " because R(a,b), where R is "+ getName(prop) + " and R has moved <br>"); changed = makeStateChange(ind, STATE_O2, IndividualsO1, IndividualsO2); break; } } } //*** if R(b,a), then based on R.. if (!changed && this.individualsAndPropertiesAssertions.get(ind)!=null) { for (Iterator iter2 = ((HashSet) this.individualsAndPropertiesAssertions.get(ind)).iterator(); iter2.hasNext();) { OWLProperty prop = (OWLProperty) iter2.next(); if (this.checkPropertyCausingTransitionB(prop)) { if (DEBUG) System.out.println("Moving individual 'a' " +getName(ind) + " because R(b,a), where R is "+ getName(prop) + " and R has moved"); out.write("Moving individual 'a' " +getName(ind) + " because R(b,a), where R is "+ getName(prop) + " and R has moved <br>"); changed = makeStateChange(ind, STATE_O2, IndividualsO1, IndividualsO2); break; } } } //*** if hasValue(R,a), then based on R.. if (!changed && this.individualsAndPropertiesRestriction.get(ind)!=null) { for (Iterator iter2 = ((HashSet) this.individualsAndPropertiesRestriction.get(ind)).iterator(); iter2.hasNext();) { OWLProperty prop = (OWLProperty) iter2.next(); if (this.checkPropertyCausingTransitionB(prop)) { if (DEBUG) System.out.println("Moving individual " +getName(ind) + " because hasValue(R, a), where R is "+ getName(prop) + " and R has moved"); out.write("Moving individual " +getName(ind) + " because hasValue(R, a), where R is "+ getName(prop) + " and R has moved <br>"); changed = makeStateChange(ind, STATE_O2, IndividualsO1, IndividualsO2); break; } } } //*** if a is in enumeration and enum itself is in O2,.. if (!changed && this.individualsInEnumerations.get(ind)!=null) { for (Iterator iter2 = ((HashSet) this.individualsInEnumerations.get(ind)).iterator(); iter2.hasNext();) { OWLEnumeration enu = (OWLEnumeration) iter2.next(); if (checkState(enu, STATE_O2)) { if (DEBUG) System.out.println("Moving individual " +getName(ind) + " because its IN AN ENUM which itself has moved"); out.write("Moving individual " +getName(ind) + " because its IN AN ENUM which itself has moved <br>"); changed = makeStateChange(ind, STATE_O2, IndividualsO1, IndividualsO2); break; } } } } //**** end individuals check copyChanged = changed | copyChanged; changed = false; //****** check for state changes for datatype //****** and link properties together copy = new HashSet(this.DataPropO1); copy.addAll(this.LinkPropO1); for (Iterator iter = copy.iterator(); iter.hasNext();) { OWLProperty prop = (OWLProperty) iter.next(); Set addToSet = new HashSet(); Set removeFromSet = new HashSet(); // determine which sets to alter based on property // being considerer if (prop instanceof OWLDataProperty) { removeFromSet = this.DataPropO1; addToSet = this.DataPropO2; } else { // else its a link property removeFromSet = this.LinkPropO1; addToSet = this.LinkPropO2; // also check for moving linkproperty if inverse is in updatedLP for (Iterator iter2 = SetUtils.union(reasoner.inversePropertiesOf((OWLObjectProperty)prop)).iterator(); iter2.hasNext();) { OWLObjectProperty invProp = (OWLObjectProperty) iter2.next(); if (updatedLP.contains(invProp)) { if (DEBUG) System.out.println("Moving LinkProperty " +getName(prop) + " because its inverse "+ getName(invProp) + " has been updated"); out.write("Moving LinkProperty " +getName(prop) + " because its inverse "+ getName(invProp) + " has been updated <br>"); changed = this.makeStateChange(prop, STATE_O2, this.LinkPropO1, this.LinkPropO2); break; } } } //*** check if domain(P,C) and C in O2 if(!changed){ for (Iterator iter2=prop.getDomains(source).iterator(); iter2.hasNext();) { OWLDescription desc = (OWLDescription) iter2.next(); if (this.checkState(desc, STATE_O2)) { if (DEBUG) System.out.println("Moving Link/Data Property " +getName(prop) + " because its DOMAIN "+ getName(desc) + " has moved"); out.write("Moving Link/Data Property " +getName(prop) + " because its DOMAIN "+ getName(desc) + " has moved <br>"); changed = this.makeStateChange(prop, STATE_O2, removeFromSet, addToSet); if(prop instanceof OWLObjectProperty){ for (Iterator it = SetUtils.union(reasoner.inversePropertiesOf((OWLObjectProperty)prop)).iterator(); it.hasNext();) { OWLObjectProperty invProp = (OWLObjectProperty) it.next(); updatedInverses.put(invProp,target.getURI()); } } break; } } } //*** check if P(a,d) and a in O2 if (!changed && this.propToIndividualAssertions.get(prop)!=null) { for (Iterator iter2=((HashSet) this.propToIndividualAssertions.get(prop)).iterator(); iter2.hasNext();) { OWLIndividual ind = (OWLIndividual) iter2.next(); if (checkState(ind, STATE_O2)) { if (DEBUG) System.out.println("Moving Link/Data Property " +getName(prop) + " because R(a,d), where a is "+ getName(ind) + " and has moved"); out.write("Moving Link/Data Property " +getName(prop) + " because R(a,d), where a is "+ getName(ind) + " and has moved <br>"); changed = this.makeStateChange(prop, STATE_O2, removeFromSet, addToSet); if(prop instanceof OWLObjectProperty){ for (Iterator it = SetUtils.union(reasoner.inversePropertiesOf((OWLObjectProperty)prop)).iterator(); it.hasNext();) { OWLObjectProperty invProp = (OWLObjectProperty) it.next(); updatedInverses.put(invProp,target.getURI()); } } break; } } } //*** check if related (sup/super/equ) properties of P are in O2 if (!changed) { Set related = new HashSet(); if (equivalents.get(prop)!=null) related.addAll((HashSet) this.equivalents.get(prop)); if (subProperties.get(prop)!=null) related.addAll((HashSet) this.subProperties.get(prop)); if (superProperties.get(prop)!=null) related.addAll((HashSet) this.superProperties.get(prop)); for (Iterator iter2 = related.iterator(); iter2.hasNext();) { OWLProperty relProp = (OWLProperty) iter2.next(); if (checkState(relProp, STATE_O2)) { if (DEBUG) System.out.println("Moving Link/Data Property " +getName(prop) + " because related (EQU/SUB/SUPER) property "+ getName(relProp) + " has moved"); out.write("Moving Link/Data Property " +getName(prop) + " because related (EQU/SUB/SUPER) property "+ getName(relProp) + " has moved <br>"); changed = this.makeStateChange(prop, STATE_O2, removeFromSet, addToSet); if(prop instanceof OWLObjectProperty){ for (Iterator it = SetUtils.union(reasoner.inversePropertiesOf((OWLObjectProperty)prop)).iterator(); iter2.hasNext();) { OWLObjectProperty invProp = (OWLObjectProperty) it.next(); updatedInverses.put(invProp,target.getURI()); } } break; } } } //*** check if restriction involves P and restriction itself is in O2.. if (!changed && this.propToDescriptionRestrictions.get(prop)!=null) { for (Iterator iter2=((HashSet) this.propToDescriptionRestrictions.get(prop)).iterator(); iter2.hasNext();) { OWLDescription desc = (OWLDescription) iter2.next(); if (checkState(desc, STATE_O2)) { if (DEBUG) System.out.println("Moving Link/Data Property " +getName(prop) + " because its IN A RESTRICTION which itself has moved"); out.write("Moving Link/Data Property " +getName(prop) + " because its IN A RESTRICTION which itself has moved <br>"); changed = this.makeStateChange(prop, STATE_O2, removeFromSet, addToSet); if(prop instanceof OWLObjectProperty){ for (Iterator it = SetUtils.union(reasoner.inversePropertiesOf((OWLObjectProperty)prop)).iterator(); it.hasNext();) { OWLObjectProperty invProp = (OWLObjectProperty) it.next(); updatedInverses.put(invProp,target.getURI()); } } break; } } } }// end dataproperty/linkproperty check copyChanged = changed | copyChanged; changed = false; //*** check for state transition for object properties copy = new HashSet(this.ObjPropS1); copy.addAll(this.ObjPropS2); copy.addAll(this.ObjPropS3); for (Iterator iter = copy.iterator(); iter.hasNext();) { OWLObjectProperty prop = (OWLObjectProperty) iter.next(); Set removeFrom = new HashSet(); String currentState = ""; if (checkState(prop, STATE_O1)) { removeFrom = this.ObjPropS1; currentState = "S1"; } if (checkState(prop, STATE_L12)) { removeFrom = this.ObjPropS2; currentState = "S2"; } if (checkState(prop, STATE_L21)) { removeFrom = this.ObjPropS3; currentState = "S3"; } //*** check if related (sup/super/equ) properties of P are in S2,S3,S4 Set related = new HashSet(); if (equivalents.get(prop)!=null) related.addAll((HashSet) this.equivalents.get(prop)); if (subProperties.get(prop)!=null) related.addAll((HashSet) this.subProperties.get(prop));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?