Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
dmeoli committed Jul 29, 2021
1 parent 746a556 commit 9419521
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class SimilarityCalculationDemo {
WS4JConfiguration.getInstance().setMFS(true);
ILexicalDatabase db = new MITWordNet();
rcs = new RelatednessCalculator[]{
new HirstStOnge(db), new LeacockChodorow(db), new Lesk(db), new WuPalmer(db),
new Resnik(db), new JiangConrath(db), new Lin(db), new Path(db)
new WuPalmer(db), new JiangConrath(db), new LeacockChodorow(db), new Lin(db),
new Resnik(db), new Path(db), new Lesk(db), new HirstStOnge(db)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
*/
public class JiangConrath extends RelatednessCalculator {

private static double min = 0.0D;
private static double max = Double.MAX_VALUE;
private static final double min = 0.0D;
private static final double max = Double.MAX_VALUE;

private static List<POS[]> POSPairs = new ArrayList<POS[]>() {{
private static final List<POS[]> POSPairs = new ArrayList<POS[]>() {{
add(new POS[]{POS.NOUN, POS.NOUN});
add(new POS[]{POS.VERB, POS.VERB});
}};
Expand All @@ -55,7 +55,7 @@ protected Relatedness calcRelatedness(Concept concept1, Concept concept2) {
if (Objects.requireNonNull(lcsList).size() == 0) return new Relatedness(min, tracer.toString(), null);
if (WS4JConfiguration.getInstance().useTrace()) {
tracer.append("JCN(").append(concept1).append(", ").append(concept2).append(")\n");
tracer.append(Objects.requireNonNull(subTracer).toString());
tracer.append(Objects.requireNonNull(subTracer));
lcsList.forEach(lcs -> {
tracer.append("Lowest Common Subsumer(s): ");
tracer.append(lcs.getSubsumer().toString()).append(" (IC = ").append(lcs.getIC()).append(")\n");
Expand All @@ -70,8 +70,8 @@ protected Relatedness calcRelatedness(Concept concept1, Concept concept2) {
double ic1 = ICFinder.getInstance().IC(pathFinder, concept1);
double ic2 = ICFinder.getInstance().IC(pathFinder, concept2);
if (WS4JConfiguration.getInstance().useTrace()) {
tracer.append("IC(").append(concept1.toString()).append(") = ").append(ic1).append("\n");
tracer.append("IC(").append(concept2.toString()).append(") = ").append(ic2).append("\n");
tracer.append("IC(").append(concept1).append(") = ").append(ic1).append("\n");
tracer.append("IC(").append(concept2).append(") = ").append(ic2).append("\n");
}
double distance;
if (ic1 > 0 && ic2 > 0) distance = ic1 + ic2 - (2 * lcsIC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
*/
public class LeacockChodorow extends RelatednessCalculator {

private static double min = 0.0D;
private static double max = Double.MAX_VALUE;
private static final double min = 0.0D;
private static final double max = Double.MAX_VALUE;

private static List<POS[]> POSPairs = new ArrayList<POS[]>() {{
private static final List<POS[]> POSPairs = new ArrayList<POS[]>() {{
add(new POS[]{POS.NOUN, POS.NOUN});
add(new POS[]{POS.VERB, POS.VERB});
}};
Expand All @@ -63,7 +63,7 @@ protected Relatedness calcRelatedness(Concept concept1, Concept concept2) {
double score = -Math.log((double) length / (double) (2 * maxDepth));
if (WS4JConfiguration.getInstance().useTrace()) {
tracer.append("LCH(").append(concept1).append(", ").append(concept2).append(")\n");
tracer.append(Objects.requireNonNull(subTracer).toString());
tracer.append(Objects.requireNonNull(subTracer));
lcsList.forEach(lcs -> {
tracer.append("Lowest Common Subsumer(s): ");
tracer.append(lcs.getSubsumer().toString()).append(" (Length = ").append(lcs.getPathLength()).append(")\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
*/
public class Lin extends RelatednessCalculator {

private static double min = 0.0D;
private static double max = 1.0D;
private static final double min = 0.0D;
private static final double max = 1.0D;

private static List<POS[]> POSPairs = new ArrayList<POS[]>() {{
private static final List<POS[]> POSPairs = new ArrayList<POS[]>() {{
add(new POS[]{POS.NOUN, POS.NOUN});
add(new POS[]{POS.VERB, POS.VERB});
}};
Expand All @@ -53,7 +53,7 @@ protected Relatedness calcRelatedness(Concept concept1, Concept concept2) {
double score = (ic1 > 0 && ic2 > 0) ? (2D * lcsList.get(0).getIC() / (ic1 + ic2)) : 0D;
if (WS4JConfiguration.getInstance().useTrace()) {
tracer.append("LIN(").append(concept1).append(", ").append(concept2).append(")\n");
tracer.append(Objects.requireNonNull(subTracer).toString());
tracer.append(Objects.requireNonNull(subTracer));
lcsList.forEach(lcs -> {
tracer.append("Lowest Common Subsumer(s): ");
tracer.append(lcs.getSubsumer()).append(" (IC = ").append(lcs.getIC()).append(")\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
*/
public class Path extends RelatednessCalculator {

private static double min = 0.0D;
private static double max = 1.0D;
private static final double min = 0.0D;
private static final double max = 1.0D;

private static List<POS[]> POSPairs = new ArrayList<POS[]>() {{
private static final List<POS[]> POSPairs = new ArrayList<POS[]>() {{
add(new POS[]{POS.NOUN, POS.NOUN});
add(new POS[]{POS.VERB, POS.VERB});
}};
Expand All @@ -46,7 +46,7 @@ protected Relatedness calcRelatedness(Concept concept1, Concept concept2) {
else score = -1.0D;
if (WS4JConfiguration.getInstance().useTrace()) {
tracer.append("PATH(").append(concept1).append(", ").append(concept2).append(")\n");
tracer.append(Objects.requireNonNull(subTracer).toString());
tracer.append(Objects.requireNonNull(subTracer));
tracer.append("Shortest path: ").append(path).append("\n");
tracer.append("Path length = ").append(dist).append("\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
*/
public class Resnik extends RelatednessCalculator {

private static double min = 0.0D;
private static double max = Double.MAX_VALUE;
private static final double min = 0.0D;
private static final double max = Double.MAX_VALUE;

private static List<POS[]> POSPairs = new ArrayList<POS[]>() {{
private static final List<POS[]> POSPairs = new ArrayList<POS[]>() {{
add(new POS[]{POS.NOUN, POS.NOUN});
add(new POS[]{POS.VERB, POS.VERB});
}};
Expand All @@ -56,7 +56,7 @@ protected Relatedness calcRelatedness(Concept concept1, Concept concept2) {
if (Objects.requireNonNull(lcsList).size() == 0) return new Relatedness(min, tracer.toString(), null);
if (WS4JConfiguration.getInstance().useTrace()) {
tracer.append("RES(").append(concept1).append(", ").append(concept2).append(")\n");
tracer.append(Objects.requireNonNull(subTracer).toString());
tracer.append(Objects.requireNonNull(subTracer));
lcsList.forEach(lcs -> {
tracer.append("Lowest Common Subsumer(s): ");
tracer.append(lcs.getSubsumer()).append(" (IC = ").append(lcs.getIC()).append(")\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
*/
public class WuPalmer extends RelatednessCalculator {

private static double min = 0.0D;
private static double max = 1.0D;
private static final double min = 0.0D;
private static final double max = 1.0D;

private static List<POS[]> POSPairs = new ArrayList<POS[]>() {{
private static final List<POS[]> POSPairs = new ArrayList<POS[]>() {{
add(new POS[]{POS.NOUN, POS.NOUN});
add(new POS[]{POS.VERB, POS.VERB});
}};
Expand All @@ -47,7 +47,7 @@ protected Relatedness calcRelatedness(Concept concept1, Concept concept2) {
if (depth1 > 0 && depth2 > 0) score = (double) (2 * depth) / (double) (depth1 + depth2);
if (WS4JConfiguration.getInstance().useTrace()) {
tracer.append("WUP(").append(concept1).append(", ").append(concept2).append(")\n");
tracer.append(Objects.requireNonNull(subTracer).toString());
tracer.append(Objects.requireNonNull(subTracer));
lcsList.forEach(lcs -> {
tracer.append("Lowest Common Subsumer(s): ");
tracer.append(lcs.getLeaf()).append(" (Depth = ").append(lcs.getDepth()).append(")\n");
Expand Down

0 comments on commit 9419521

Please sign in to comment.