econniterativepartitioning.java
来自「Semantic Web Ontology Editor」· Java 代码 · 共 1,353 行 · 第 1/5 页
JAVA
1,353 行
if (DEBUG) System.out.println("Completed state machine.."+swoopModel.getTimeStamp()); System.out.println("----Timers for state machine iterations----"); System.out.println(timers.toString()); System.out.println(timers2.toString()); System.out.println(timers4.toString()); System.out.println(timers8.toString()); System.out.println(timers9.toString()); } public void makeChanges() throws OWLException{ if (DEBUG) System.out.println("Starting makeChanges().."+swoopModel.getTimeStamp()); //*********************************************************** //Classes and Descriptions in O2 //*********************************************************** for(Iterator iter = DescriptionsO2.iterator(); iter.hasNext(); ){ OWLDescription d = (OWLDescription)iter.next(); //Add entity to Target if(d instanceof OWLClass){ OntologyChange oc = new AddEntity(target,(OWLClass)d,null); changes.add(oc); if(APPLY) oc.accept((ChangeVisitor)target); } //handle class equivalence axioms if(equivalents.containsKey(d)){ for(Iterator it = ((Set)equivalents.get(d)).iterator(); it.hasNext();){ if(d instanceof OWLClass){ OWLDescription equiv = (OWLDescription)it.next(); OntologyChange oc5 = new AddEquivalentClass(target,(OWLClass)d,equiv,null); changes.add(oc5); if(APPLY) oc5.accept((ChangeVisitor)target); OntologyChange oc16 = new RemoveEquivalentClass(source,(OWLClass)d,equiv,null); changes.add(oc16); if(APPLY) oc16.accept((ChangeVisitor)source); } else{ OWLClass equiv = (OWLClass)it.next(); OntologyChange oc5 = new AddEquivalentClass(target,(OWLClass)equiv,d,null); changes.add(oc5); if(APPLY) oc5.accept((ChangeVisitor)target); OntologyChange oc16 = new RemoveEquivalentClass(source,(OWLClass)equiv,d,null); changes.add(oc16); if(APPLY) oc16.accept((ChangeVisitor)source); } } } //handle subClassAxioms if(subClasses.containsKey(d) && d instanceof OWLClass){ for(Iterator it = ((Set)superClasses.get(d)).iterator(); it.hasNext(); ){ OWLDescription sup = (OWLDescription)it.next(); OntologyChange oc5 = new AddSuperClass(target,(OWLClass)d,sup,null); changes.add(oc5); if(APPLY) oc5.accept((ChangeVisitor)target); OntologyChange oc16 = new RemoveSuperClass(source,(OWLClass)d,sup,null); changes.add(oc16); if(APPLY) oc16.accept((ChangeVisitor)source); } } if(d instanceof OWLClass){ for(Iterator j = ((OWLClass)d).getEnumerations(source).iterator(); j.hasNext(); ){ OWLEnumeration enum_ = (OWLEnumeration)(j.next()); for(Iterator u = enum_.getIndividuals().iterator(); u.hasNext(); ){ OWLIndividual indiv = (OWLIndividual)u.next(); EnumElementChange change = new EnumElementChange("Add", target, (OWLClass) d, indiv, null); changes.add(change); if(APPLY) change.accept((ChangeVisitor)target); } } } }//end loop for classes //**************************************** //Individuals in O2 //**************************************** for(Iterator iter2 = IndividualsO2.iterator(); iter2.hasNext(); ) { OWLIndividual ind = (OWLIndividual)iter2.next(); OntologyChange oc = new AddEntity(target,ind,null); changes.add(oc); if(APPLY) oc.accept((ChangeVisitor)target); //Assertions R(a,b), where ``a'' has been moved for(Iterator it = ind.getObjectPropertyValues(source).keySet().iterator(); it.hasNext(); ){ OWLObjectProperty prop = (OWLObjectProperty)it.next(); Set copytypes = new HashSet((Set)ind.getObjectPropertyValues(source).get(prop)); for(Iterator i = copytypes.iterator(); i.hasNext(); ){ OWLIndividual b = (OWLIndividual)i.next(); OntologyChange oc3 = new AddObjectPropertyInstance(target,ind,prop,b,null); changes.add(oc3); if(APPLY) oc3.accept((ChangeVisitor)target); OntologyChange oc2 = new RemoveObjectPropertyInstance(source,ind,prop,b,null); changes.add(oc2); if(APPLY) oc2.accept((ChangeVisitor)source); } } //Assertions of the form U(a,d) for(Iterator it3 = ind.getDataPropertyValues(source).keySet().iterator(); it3.hasNext(); ){ OWLDataProperty prop = (OWLDataProperty)it3.next(); for(Iterator i = ((Set)ind.getDataPropertyValues(source).get(prop)).iterator(); i.hasNext();){ OWLDataValue b = (OWLDataValue)i.next(); OntologyChange oc3 = new AddDataPropertyInstance(target,ind,prop,b,null); changes.add(oc3); if(APPLY) oc3.accept((ChangeVisitor)target); OntologyChange oc2 = new RemoveDataPropertyInstance(source,ind,prop,b,null); changes.add(oc2); if(APPLY) oc2.accept((ChangeVisitor)source); } } //Assertions of the form C(a) // AK: need to create a copy of types to avoid concurrent modification exception // because you are iterating over types in source, while deleting them inside the loop Set copyTypes = new HashSet(ind.getTypes(source)); for(Iterator it2= copyTypes.iterator(); it2.hasNext(); ){ OWLDescription desc = (OWLDescription)it2.next(); OntologyChange oc3 = new AddIndividualClass(target,ind,desc,null); changes.add(oc3); if(APPLY) oc3.accept((ChangeVisitor)target); OntologyChange oc2 = new RemoveIndividualClass(source,ind,desc,null); changes.add(oc2); if(APPLY) oc2.accept((ChangeVisitor)source); } } //************************************************************ //Datatype properties in O2 //************************************************************ for (Iterator iter3 = DataPropO2.iterator(); iter3.hasNext(); ){ OWLDataProperty prop = (OWLDataProperty)iter3.next(); //Add entity to Target=O2 OntologyChange oc = new AddEntity(target,prop,null); changes.add(oc); if(APPLY) oc.accept((ChangeVisitor)target); //Copy property attributes if(prop.isFunctional(source)){ SetFunctional oc25 = new SetFunctional(source, prop, false, null); changes.add(oc25); if(APPLY) oc25.accept((ChangeVisitor)source); SetFunctional oc26 = new SetFunctional(target, prop, true, null); changes.add(oc26); if(APPLY) oc26.accept((ChangeVisitor)target); } //domains Set copyTypes = new HashSet(prop.getDomains(source)); for(Iterator it = copyTypes.iterator(); it.hasNext(); ){ OWLDescription desc = (OWLDescription)it.next(); OntologyChange oc3 = new AddDomain(target,prop,desc,null); changes.add(oc3); if(APPLY) oc3.accept((ChangeVisitor)target); OntologyChange oc2 = new RemoveDomain(source,prop,desc,null); changes.add(oc2); if(APPLY) oc2.accept((ChangeVisitor)source); } Set copytypes = new HashSet(prop.getRanges(source)); for(Iterator it = copytypes.iterator(); it.hasNext(); ){ OWLDataType dat = (OWLDataType)it.next(); //Add range axiom to Target OntologyChange oc3 = new AddDataPropertyRange(target,prop,dat,null); changes.add(oc3); //Remove range axiom from Source if(APPLY) oc3.accept((ChangeVisitor)target); OntologyChange oc2 = new RemoveDataPropertyRange(source,prop,dat,null); changes.add(oc2); if(APPLY) oc2.accept((ChangeVisitor)source); } } //**************************************************************************** //Object Properties in State2: Links from source-->Target //***************************************************************************** for(Iterator iter9 = ObjPropS2.iterator(); iter9.hasNext(); ){ OWLObjectProperty prop = (OWLObjectProperty)iter9.next(); OntologyChange oc = new SetLinkTarget(source,prop,target.getURI(),null); changes.add(oc); if(APPLY) oc.accept((ChangeVisitor)source); } //****************************************************************************** //Link properties in O2 //***************************************************************************** for(Iterator iter4 = LinkPropO2.iterator(); iter4.hasNext(); ){ OWLObjectProperty prop = (OWLObjectProperty)iter4.next(); OntologyChange oc = new AddEntity(target,prop,null); changes.add(oc); //Try // OntologyChange oc3 = new SetLinkTarget(source,prop,null,null); // changes.add(oc3); // if(APPLY) oc3.accept((ChangeVisitor)source); // if(APPLY) oc.accept((ChangeVisitor)target); if (prop.isInverseFunctional(source)){ SetInverseFunctional oc27 = new SetInverseFunctional(source, (OWLObjectProperty)prop, false, null); changes.add(oc27); if(APPLY) oc27.accept((ChangeVisitor)source); SetInverseFunctional oc28 = new SetInverseFunctional(target, (OWLObjectProperty)prop, true, null); changes.add(oc28); if(APPLY) oc28.accept((ChangeVisitor)target); } if(prop.isFunctional(source)){ SetFunctional oc25 = new SetFunctional(source, prop, false, null); changes.add(oc25); if(APPLY) oc25.accept((ChangeVisitor)source); SetFunctional oc26 = new SetFunctional(target, prop, true, null); changes.add(oc26); if(APPLY) oc26.accept((ChangeVisitor)target); } for(Iterator it = prop.getDomains(source).iterator(); it.hasNext(); ){ OWLDescription desc = (OWLDescription)it.next(); OntologyChange oc76 = new AddDomain(target,prop,desc,null); changes.add(oc76); if(APPLY) oc76.accept((ChangeVisitor)target); OntologyChange oc2 = new RemoveDomain(source,prop,desc,null); changes.add(oc2); if(APPLY) oc2.accept((ChangeVisitor)source); } Set copytypes = new HashSet(prop.getRanges(source)); for(Iterator it = copytypes.iterator(); it.hasNext(); ){ OWLDescription desc = (OWLDescription)it.next(); //Add range axiom to Target OntologyChange oc31 = new AddObjectPropertyRange(target,prop,desc,null); changes.add(oc31); //Remove range axiom from Source if(APPLY) oc31.accept((ChangeVisitor)target); OntologyChange oc2 = new RemoveObjectPropertyRange(source,prop,desc,null); changes.add(oc2); if(APPLY) oc2.accept((ChangeVisitor)source); } //Test copytypes = new HashSet(prop.getInverses(source)); for(Iterator it = copytypes.iterator(); it.hasNext(); ){ OWLObjectProperty pinv = (OWLObjectProperty)it.next(); OntologyChange oc2 = new AddInverse(target,prop,pinv,null); changes.add(oc2); if(APPLY) oc2.accept((ChangeVisitor)target); RemoveInverse change = new RemoveInverse(source, prop, pinv, null); changes.add(change); if(APPLY) change.accept((ChangeVisitor)source); } } //*********************************************************************************** //ObjectProperties in State 3: Link Properties Target-->Source //*********************************************************************************** for(Iterator iter5 = ObjPropS3.iterator(); iter5.hasNext(); ){ OWLObjectProperty prop = (OWLObjectProperty)iter5.n
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?