📄 matchinglist.java
字号:
Matching newMatching = new Matching(cp1,cp2);
newMatching.updateCmaxWeight(nb);
this.list.add(newMatching);
}
}
/** Add nb times the weight of topo to the weight of the matchings (cp1,cp2).
* Creates the matching with this weight if it does not exist. */
public void updateMatchingWithTopo(ConceptualPrimitive cp1,ConceptualPrimitive cp2,int nb){
boolean exists = false;
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(m.getFirstCP().equals(cp1) && m.getSecondCP().equals(cp2)){
m.updateTopoWeight(nb);
exists = true;
}
}
if(!exists){
Matching newMatching = new Matching(cp1,cp2);
newMatching.updateTopoWeight(nb);
this.list.add(newMatching);
}
}
/** Add nb times the weight of topoPlus to the weight of the matchings (cp1,cp2).
* Creates the matching with this weight if it does not exist. */
public void updateMatchingWithTopoPlus(ConceptualPrimitive cp1,ConceptualPrimitive cp2,int nb){
boolean exists = false;
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(m.getFirstCP().equals(cp1) && m.getSecondCP().equals(cp2)){
m.updateTopoPlusWeight(nb);
exists = true;
}
}
if(!exists){
Matching newMatching = new Matching(cp1,cp2);
newMatching.updateTopoPlusWeight(nb);
this.list.add(newMatching);
}
}
/** Add nb times the weight of signature to the weight of the matchings (cp1,cp2).
* Creates the matching with this weight if it does not exist. */
public void updateMatchingWithSignature(ConceptualPrimitive cp1,ConceptualPrimitive cp2,int nb){
boolean exists = false;
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(m.getFirstCP().equals(cp1) && m.getSecondCP().equals(cp2)){
m.updateSignatureWeight(nb);
exists = true;
}
}
if(!exists){
Matching newMatching = new Matching(cp1,cp2);
newMatching.updateSignatureWeight(nb);
this.list.add(newMatching);
}
}
/** Add nb times the weight of isa to the weight of the matchings (cp1,cp2).
* Creates the matching with this weight if it does not exist. */
public void updateMatchingWithIsa(ConceptualPrimitive cp1,ConceptualPrimitive cp2,int nb){
boolean exists = false;
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(m.getFirstCP().equals(cp1) && m.getSecondCP().equals(cp2)){
m.updateIsaWeight(nb);
exists = true;
}
}
if(!exists){
Matching newMatching = new Matching(cp1,cp2);
newMatching.updateIsaWeight(nb);
this.list.add(newMatching);
}
}
/** Remove all the matchings with cp1 in first position and cp2 in second position. */
public void removeMatching(ConceptualPrimitive cp1,ConceptualPrimitive cp2){
LinkedList newList = new LinkedList();
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(!m.getFirstCP().equals(cp1) || !m.getSecondCP().equals(cp2)) newList.add(m);
}
this.list = newList;
}
/** Returns a list of the matchings that have cp in first position. */
public LinkedList getMatchingsWithFirst(ConceptualPrimitive cp){
LinkedList result = new LinkedList();
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(m.getFirstCP().equals(cp)) result.add(m);
}
return result;
}
/** Returns a list of the matchings that have cp in first position. */
public LinkedList getMatchingsWithSecond(ConceptualPrimitive cp){
LinkedList result = new LinkedList();
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(m.getSecondCP().equals(cp)) result.add(m);
}
return result;
}
/** Returns the list of matchings in weight decreasing order. */
public LinkedList getMatchingsSortedByWeight(){
LinkedList result = (LinkedList) this.list.clone();
Collections.sort(result);
return result;
}
public LinkedList getConceptMatchings(){
LinkedList result = new LinkedList();
for(Iterator i = list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(m.getFirstCP() instanceof ConceptType) result.add(m);
}
return result;
}
public LinkedList getRelationMatchings(){
LinkedList result = new LinkedList();
for(Iterator i = list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(m.getFirstCP() instanceof RelationType) result.add(m);
}
return result;
}
/** Returns the list of concept matchings in weight decreasing order. */
public LinkedList getConceptMatchingsSortedByWeight(){
LinkedList result = this.getConceptMatchings();
Collections.sort(result);
return result;
}
/** Returns the list of relation matchings in weight decreasing order. */
public LinkedList getRelationMatchingsSortedByWeight(){
LinkedList result = this.getRelationMatchings();
Collections.sort(result);
return result;
}
/** Only keep the pertinent concept matchings that have a weigth more or equal to
* the sill, and select among them the better matching for each concept type of
* o1. */
public void fixConceptMatchings(double sill){
LinkedList conMatchList = this.getConceptMatchingsSortedByWeight();
LinkedList resultCon = new LinkedList();
for(Iterator i = o1.getConceptTypes().iterator();i.hasNext();){
ConceptType ct = (ConceptType) i.next();
boolean test = false;
for(Iterator j = conMatchList.iterator();j.hasNext() && !test;){
Matching m = (Matching) j.next();
if(((ConceptType) m.getFirstCP()).equals(ct)){
if(m.getWeight() >= sill) resultCon.add(m);
test = true;
}
}
}
resultCon.addAll(this.getRelationMatchings());
this.list = resultCon;
}
/** Only keep the pertinent relation matchings that have a weigth more or equal to
* the sill, and select among them the better matching for each relation type of
* o1. */
public void fixRelationMatchings(double sill){
LinkedList relMatchList = this.getRelationMatchingsSortedByWeight();
LinkedList resultRel = new LinkedList();
for(Iterator i = o1.getRelationTypes().iterator();i.hasNext();){
RelationType rt = (RelationType) i.next();
//System.out.println("Relation "+rt.toString(Language.ENGLISH));
boolean test = false;
for(Iterator j = relMatchList.iterator();j.hasNext() && !test;){
Matching m = (Matching) j.next();
//System.out.println("Matching "+m.toString(Language.ENGLISH));
if(((RelationType) m.getFirstCP()).equals(rt)){
if(m.getWeight() >= sill){
resultRel.add(m);
//System.out.println("kept");
}
test = true;
}
}
}
resultRel.addAll(this.getConceptMatchings());
this.list = resultRel;
}
/** Remove all matchings that have a weight less or equal to the given sill. */
public void removeIrrelevantMatchings(double sill){
LinkedList result = new LinkedList();
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
if(m.getWeight() > sill) result.add(m);
}
this.list = result;
}
public String toString(Language l){
String result = new String();
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
result.concat(m.toString(l));
result.concat("\n");
}
return result;
}
/** Print in the given file a latex tabular corresponding to the description of the matchings. */
public void print(FileWriter out,Language l) throws IOException{
int partNb = 1;
out.write("\\documentclass{article} \n");
out.write("\\usepackage[T1]{fontenc} \n");
out.write("\\usepackage{pstricks} \n");
out.write("\\usepackage{graphicx} \n");
out.write("\\usepackage{amsfonts} \n");
out.write("\\usepackage{amssymb} \n");
out.write("\\usepackage{rotating} \n");
out.write("\\usepackage{graphicx} \n");
out.write("\\begin{document} \n");
out.write("\\pagestyle{empty} \n \n");
out.write("\\begin{figure} \n");
out.write("\\tiny \n");
out.write("\\centerline{ \n");
out.write("\\begin{sideways} \n");
out.write("\\begin{tabular}{\u007C*{17}{c\u007C}} \n");
out.write("\\hline \n");
out.write("\\begin{tabular}{c}{Primitive}\\\\{of ontology}\\end{tabular} \u0026 \\begin{tabular}{c}{Primitive}\\\\{of ontology}\\end{tabular} \u0026 \\multicolumn{5}{c\u007C}{Algebraic Properties} \u0026 \\multicolumn{2}{c\u007C}{Cardinalities} \u0026 \\multicolumn{2}{c\u007C}{Axioms} \u0026 \\multicolumn{3}{c\u007C}{Multiple Primitives Properties} \u0026 Signatures \u0026 \\begin{tabular}{c}{\\it ISA}\\\\{relations}\\end{tabular} \u0026 Abstraction \\\\ \n");
out.write("\\cline{3-14} \n");
out.write("$O_1$ & $O_2$ & $W_{S}$ & $W_{T}$ & $W_{R}$ & $W_{I}$ & $W_{A}$ & $W_{cmin}$ & $W_{cmax}$ & $W_{Topo}$ & $W_{Topo+}$ & $W_{Disj}$ & $W_{Incomp}$ & $W_{Exclu}$ & $W_{sign}$ & $W_{isa}$ & $W_{Abst}$ \\\\ \n");
out.write("\\hline \n");
int cpt = 0;
for(Iterator i = this.list.iterator();i.hasNext();){
Matching m = (Matching) i.next();
m.print(out,l);
out.write("\\hline \n");
cpt++;
if(cpt==70){
out.write("\\end{tabular} \n");
out.write("\\end{sideways}} \n");
out.write("\\normalsize \n");
out.write("\\caption{Results} \n");
out.write("\\label{results" + partNb + "} \n");
out.write("\\end{figure} \n \n");
out.write("\\begin{figure} \n");
out.write("\\tiny \n");
out.write("\\centerline{ \n");
out.write("\\begin{sideways} \n");
out.write("\\begin{tabular}{\u007C*{17}{c\u007C}} \n");
out.write("\\hline \n");
out.write("\\begin{tabular}{c}{Primitive}\\\\{of ontology}\\end{tabular} \u0026 \\begin{tabular}{c}{Primitive}\\\\{of ontology}\\end{tabular} \u0026 \\multicolumn{5}{c\u007C}{Algebraic Properties} \u0026 \\multicolumn{2}{c\u007C}{Cardinalities} \u0026 \\multicolumn{2}{c\u007C}{Axioms} \u0026 \\multicolumn{3}{c\u007C}{Multiple Primitives Properties} \u0026 Signatures \u0026 \\begin{tabular}{c}{\\it ISA}\\\\{relations}\\end{tabular} \u0026 Abstraction \\\\ \n");
out.write("\\cline{3-14} \n");
out.write("$O_1$ & $O_2$ & $W_{S}$ & $W_{T}$ & $W_{R}$ & $W_{I}$ & $W_{A}$ & $W_{cmin}$ & $W_{cmax}$ & $W_{Topo}$ & $W_{Topo+}$ & $W_{Disj}$ & $W_{Incomp}$ & $W_{Exclu}$ & $W_{sign}$ & $W_{isa}$ & $W_{Abst}$ \\\\ \n");
out.write("\\hline \n");
cpt = 0;
partNb ++;
}
}
out.write("\\end{tabular} \n");
out.write("\\end{sideways}} \n");
out.write("\\normalsize \n");
out.write("\\caption{Results} \n");
out.write("\\label{results} \n");
out.write("\\end{figure} \n");
out.write("\\end{document}");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -