📄 matching.java
字号:
package toocom.matching;
import java.io.*;
import toocom.ocgl.*;
/**
* This class represent a matching of conceptual primitives.
*
* @author Fr閐閞ic F黵st
*/
public class Matching implements Comparable{
private ConceptualPrimitive c1;
private ConceptualPrimitive c2;
protected int abstractionWeight;
protected int disjunctionWeight;
protected int incompatibilityWeight;
protected int exclusivityWeight;
protected int symmetryWeight;
protected int transitivityWeight;
protected int reflexivityWeight;
protected int irreflexivityWeight;
protected int antisymmetryWeight;
protected int cminWeight;
protected int cmaxWeight;
protected int topoWeight;
protected int topoPlusWeight;
protected int signatureWeight;
protected int isaWeight;
public Matching(ConceptualPrimitive c1,ConceptualPrimitive c2){
this.c1 = c1;
this.c2 = c2;
}
/** Returns true if the matching is about concept, false otherwise. */
public boolean isConceptMatching(){
return (c1 instanceof ConceptType);
}
public ConceptualPrimitive getFirstCP(){
return this.c1;
}
public ConceptualPrimitive getSecondCP(){
return this.c2;
}
/** Add the given weight to the value of the matching weight. */
public void updateAbstractionWeight(int weight){
this.abstractionWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateDisjunctionWeight(int weight){
this.disjunctionWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateIncompatibilityWeight(int weight){
this.incompatibilityWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateExclusivityWeight(int weight){
this.exclusivityWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateSymmetryWeight(int weight){
this.symmetryWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateTransitivityWeight(int weight){
this.transitivityWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateReflexivityWeight(int weight){
this.reflexivityWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateIrreflexivityWeight(int weight){
this.irreflexivityWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateAntisymmetryWeight(int weight){
this.antisymmetryWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateCminWeight(int weight){
this.cminWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateCmaxWeight(int weight){
this.cmaxWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateTopoWeight(int weight){
this.topoWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateTopoPlusWeight(int weight){
this.topoPlusWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateSignatureWeight(int weight){
this.signatureWeight += weight;
}
/** Add the given weight to the value of the matching weight. */
public void updateIsaWeight(int weight){
this.isaWeight += weight;
}
public int getWeight(){
return abstractionWeight*MatchingAlgorithm.abstractionWeight +
disjunctionWeight*MatchingAlgorithm.disjunctionWeight +
incompatibilityWeight*MatchingAlgorithm.incompatibilityWeight +
exclusivityWeight*MatchingAlgorithm.exclusivityWeight +
symmetryWeight*MatchingAlgorithm.symmetryWeight +
transitivityWeight*MatchingAlgorithm.transitivityWeight +
reflexivityWeight*MatchingAlgorithm.reflexivityWeight +
irreflexivityWeight*MatchingAlgorithm.irreflexivityWeight +
antisymmetryWeight*MatchingAlgorithm.antisymmetryWeight +
cminWeight*MatchingAlgorithm.cminWeight +
cmaxWeight*MatchingAlgorithm.cmaxWeight +
topoWeight*MatchingAlgorithm.topoWeight +
topoPlusWeight*MatchingAlgorithm.topoPlusWeight +
signatureWeight*MatchingAlgorithm.signatureWeight +
isaWeight*MatchingAlgorithm.isaWeight;
}
/** Returns the weight of the given matching - those of this matching (return -1 if
* m is not a Matching instance). */
public int compareTo(Object m){
if(m instanceof Matching) return (((Matching) m).getWeight() - this.getWeight());
else return -1;
}
public String toString(Language l){
return "(" + c1.getTerm(l) + "," + c2.getTerm(l) + this.getWeight() + ")";
}
/** Print in the given file a latex tabular line corresponding to the description of the matching. */
public void print(FileWriter out,Language l) throws IOException{
out.write(c1.getTerm(l) + " \u0026 " + c2.getTerm(l) + " \u0026 ");
if(c1 instanceof ConceptType)
out.write("\u0024\\diagup\u0024 \u0026 \u0024\\diagup\u0024 \u0026 \u0024\\diagup\u0024 \u0026 \u0024\\diagup\u0024 \u0026 \u0024\\diagup\u0024 \u0026 \u0024\\diagup\u0024 \u0026 \u0024\\diagup\u0024 \u0026 ");
else out.write(this.symmetryWeight + " \u0026 " + this.transitivityWeight + " \u0026 " + this.reflexivityWeight + " \u0026 " + this.irreflexivityWeight + " \u0026 " + this.antisymmetryWeight + " \u0026 " + this.cminWeight + " \u0026 " + this.cmaxWeight + " \u0026 ");
out.write(this.topoWeight + " \u0026 " + this.topoPlusWeight + " \u0026 ");
if(c1 instanceof ConceptType)
out.write(this.disjunctionWeight + " \u0026 \u0024\\diagup\u0024 \u0026 \u0024\\diagup\u0024 \u0026 \u0024\\diagup\u0024 \u0026 ");
else out.write("\u0024\\diagup\u0024 \u0026 " + this.incompatibilityWeight + " \u0026 " + this.exclusivityWeight + " \u0026 " + this.signatureWeight + " \u0026 ");
out.write(this.isaWeight + " \u0026 ");
if(c1 instanceof ConceptType)
out.write(this.abstractionWeight + " \\\\\n");
else out.write("\u0024\\diagup\u0024 \\\\\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -