105 lines
3.1 KiB
Java
105 lines
3.1 KiB
Java
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
package FunctionLayer;
|
|
|
|
import com.google.common.collect.Multimap;
|
|
import com.google.common.collect.Multiset;
|
|
import java.util.Collection;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
|
|
/**
|
|
*
|
|
* @author install1
|
|
*/
|
|
public class SimilarityMatrix{
|
|
|
|
private String PrimaryString;
|
|
private String SecondaryString;
|
|
private double distance;
|
|
|
|
public double getDistance() {
|
|
return distance;
|
|
}
|
|
|
|
public void setDistance(double distance) {
|
|
this.distance = distance;
|
|
}
|
|
|
|
public SimilarityMatrix(String str1, String str2) {
|
|
this.PrimaryString = str1;
|
|
this.SecondaryString = str2;
|
|
}
|
|
|
|
public SimilarityMatrix(String str1, String str2, double result) {
|
|
this.PrimaryString = str1;
|
|
this.SecondaryString = str2;
|
|
this.distance = result;
|
|
}
|
|
|
|
/*
|
|
public double getDistanceCalculations() {
|
|
ILexicalDatabase db = new NictWordNet();
|
|
WS4JConfiguration.getInstance().setMFS(true);
|
|
RelatednessCalculator rc1 = new WuPalmer(db);
|
|
RelatednessCalculator rc2 = new Resnik(db);
|
|
RelatednessCalculator rc3 = new JiangConrath(db);
|
|
RelatednessCalculator rc4 = new Lin(db);
|
|
RelatednessCalculator rc5 = new LeacockChodorow(db);
|
|
RelatednessCalculator rc6 = new Path(db);
|
|
RelatednessCalculator rc7 = new Lesk(db);
|
|
RelatednessCalculator rc8 = new HirstStOnge(db);
|
|
double maxScore = -1D;
|
|
List<RelatednessCalculator> RCList = new ArrayList();
|
|
RCList.add(rc1);
|
|
RCList.add(rc2);
|
|
RCList.add(rc3);
|
|
RCList.add(rc4);
|
|
RCList.add(rc5);
|
|
RCList.add(rc6);
|
|
RCList.add(rc7);
|
|
RCList.add(rc8);
|
|
for (RelatednessCalculator rc : RCList) {
|
|
double s = rc.calcRelatednessOfWords(PrimaryString, SecondaryString);
|
|
s /= 1000;
|
|
if (s > 0.000000) {
|
|
System.out.println("s: " + s + "\n" + " PrimaryString: " + PrimaryString + "\n" + " SecondaryString: " + SecondaryString + "\n"
|
|
+ " rc: " + rc.toString() + "\n");
|
|
}
|
|
String str = String.format("%.12f", s);
|
|
if (str.contains(",")) {
|
|
str = str.substring(0, str.indexOf(","));
|
|
}
|
|
int strend = str.length() > 6 ? 6 : str.length();
|
|
str = str.substring(0, strend);
|
|
double score = Double.valueOf(str);
|
|
if (score > maxScore) {
|
|
maxScore = score;
|
|
}
|
|
}
|
|
return maxScore == -1D ? 0.00 : maxScore;
|
|
}
|
|
*/
|
|
public String getPrimaryString() {
|
|
return PrimaryString;
|
|
}
|
|
|
|
public void setPrimaryString(String PrimaryString) {
|
|
this.PrimaryString = PrimaryString;
|
|
}
|
|
|
|
public String getSecondaryString() {
|
|
return SecondaryString;
|
|
}
|
|
|
|
public void setSecondaryString(String SecondaryString) {
|
|
this.SecondaryString = SecondaryString;
|
|
}
|
|
|
|
|
|
}
|