From f6433877b4a5d8caf554c1a2f132861215d45688 Mon Sep 17 00:00:00 2001 From: Alex | Kronox Date: Fri, 10 Jan 2025 08:54:44 +0100 Subject: [PATCH] remove symmetric similarity --- .../de/jplag/options/SimilarityMetric.java | 1 - .../reportobject/mapper/MetricMapperTest.java | 4 ++-- .../src/components/ComparisonTableFilter.vue | 1 - .../DistributionDiagramOptions.vue | 3 +-- report-viewer/src/model/MetricType.ts | 10 +--------- .../comparisonTable/ComparisonTable.test.ts | 2 +- .../ComparisonTableFilter.test.ts | 9 ++------- .../model/factories/ComparisonFactory.test.ts | 1 - .../model/factories/OverviewFactory.test.ts | 12 ------------ .../unit/model/factories/ValidComparison.json | 1 - .../unit/model/factories/ValidOverview.json | 18 ++++++------------ 11 files changed, 13 insertions(+), 49 deletions(-) diff --git a/core/src/main/java/de/jplag/options/SimilarityMetric.java b/core/src/main/java/de/jplag/options/SimilarityMetric.java index 4cefb9ff7..0748b5e27 100644 --- a/core/src/main/java/de/jplag/options/SimilarityMetric.java +++ b/core/src/main/java/de/jplag/options/SimilarityMetric.java @@ -10,7 +10,6 @@ public enum SimilarityMetric implements ToDoubleFunction { MIN("minimum similarity", JPlagComparison::minimalSimilarity), MAX("maximal similarity", JPlagComparison::maximalSimilarity), INTERSECTION("matched tokens", it -> (double) it.getNumberOfMatchedTokens()), - SYMMETRIC("symmetric similarity", JPlagComparison::symmetricSimilarity), LONGEST_MATCH("number of tokens in the longest match", it -> it.matches().stream().mapToInt(Match::length).max().orElse(0)), OVERALL("Sum of both submission lengths", it -> it.firstSubmission().getNumberOfTokens() + it.secondSubmission().getNumberOfTokens()); diff --git a/core/src/test/java/de/jplag/reporting/reportobject/mapper/MetricMapperTest.java b/core/src/test/java/de/jplag/reporting/reportobject/mapper/MetricMapperTest.java index afd334110..9ccb28c32 100644 --- a/core/src/test/java/de/jplag/reporting/reportobject/mapper/MetricMapperTest.java +++ b/core/src/test/java/de/jplag/reporting/reportobject/mapper/MetricMapperTest.java @@ -58,9 +58,9 @@ public void test_getTopComparisons() { // then Assertions.assertEquals(List.of( new TopComparison("1", "2", - Map.of("AVG", .7, "MAX", .8, "MIN", .5, "LONGEST_MATCH", 9.0, "INTERSECTION", 13.0, "SYMMETRIC", .5, "OVERALL", 52.0)), + Map.of("AVG", .7, "MAX", .8, "MIN", .5, "LONGEST_MATCH", 9.0, "INTERSECTION", 13.0, "OVERALL", 52.0)), new TopComparison("3", "4", - Map.of("AVG", .3, "MAX", .9, "MIN", .01, "LONGEST_MATCH", 23.0, "INTERSECTION", 42.0, "SYMMETRIC", .25, "OVERALL", 336.0))), + Map.of("AVG", .3, "MAX", .9, "MIN", .01, "LONGEST_MATCH", 23.0, "INTERSECTION", 42.0, "OVERALL", 336.0))), result); } diff --git a/report-viewer/src/components/ComparisonTableFilter.vue b/report-viewer/src/components/ComparisonTableFilter.vue index 3d40a1362..c1903341b 100644 --- a/report-viewer/src/components/ComparisonTableFilter.vue +++ b/report-viewer/src/components/ComparisonTableFilter.vue @@ -134,7 +134,6 @@ const tableSortingOptions = computed(() => { const secondaryMetricOptions = [ MetricJsonIdentifier.MAXIMUM_SIMILARITY, MetricJsonIdentifier.MINIMUM_SIMILARITY, - MetricJsonIdentifier.SYMMETRIC, MetricJsonIdentifier.INTERSECTION, MetricJsonIdentifier.LONGEST_MATCH, MetricJsonIdentifier.OVERALL diff --git a/report-viewer/src/components/distributionDiagram/DistributionDiagramOptions.vue b/report-viewer/src/components/distributionDiagram/DistributionDiagramOptions.vue index 352c3ff9d..0cc60ed7c 100644 --- a/report-viewer/src/components/distributionDiagram/DistributionDiagramOptions.vue +++ b/report-viewer/src/components/distributionDiagram/DistributionDiagramOptions.vue @@ -51,7 +51,6 @@ const resolutionOptions = [10, 20, 25, 50, 100] as BucketOptions[] const metricOptions = [ MetricJsonIdentifier.AVERAGE_SIMILARITY, MetricJsonIdentifier.MAXIMUM_SIMILARITY, - MetricJsonIdentifier.MINIMUM_SIMILARITY, - MetricJsonIdentifier.SYMMETRIC + MetricJsonIdentifier.MINIMUM_SIMILARITY ] diff --git a/report-viewer/src/model/MetricType.ts b/report-viewer/src/model/MetricType.ts index 52637c841..c063e30ba 100644 --- a/report-viewer/src/model/MetricType.ts +++ b/report-viewer/src/model/MetricType.ts @@ -3,7 +3,6 @@ export enum MetricJsonIdentifier { MAXIMUM_SIMILARITY = 'MAX', MINIMUM_SIMILARITY = 'MIN', INTERSECTION = 'INTERSECTION', - SYMMETRIC = 'SYMMETRIC', LONGEST_MATCH = 'LONGEST_MATCH', OVERALL = 'OVERALL' } @@ -75,6 +74,7 @@ class PercentageMetricType extends MetricType { } } +// eslint-disable-next-line @typescript-eslint/no-namespace export namespace MetricTypes { export const AVERAGE_SIMILARITY = new PercentageMetricType( 'AVG', @@ -100,12 +100,6 @@ export namespace MetricTypes { 'The number of tokens that are matched between the two files.', MetricJsonIdentifier.INTERSECTION ) - export const SYMMETRIC = new PercentageMetricType( - 'SYM', - 'Symmetric', - 'A symmetric similarity measure.', - MetricJsonIdentifier.SYMMETRIC - ) export const LONGEST_MATCH = new IdentityMetricType( 'LONG', 'Longest Match', @@ -124,7 +118,6 @@ export namespace MetricTypes { MAXIMUM_SIMILARITY, MINIMUM_SIMILARITY, INTERSECTION, - SYMMETRIC, LONGEST_MATCH, OVERALL ] @@ -141,7 +134,6 @@ export namespace MetricTypes { MetricJsonIdentifier.MAXIMUM_SIMILARITY, MetricJsonIdentifier.MINIMUM_SIMILARITY, MetricJsonIdentifier.INTERSECTION, - MetricJsonIdentifier.SYMMETRIC, MetricJsonIdentifier.LONGEST_MATCH, MetricJsonIdentifier.OVERALL ] diff --git a/report-viewer/tests/unit/components/comparisonTable/ComparisonTable.test.ts b/report-viewer/tests/unit/components/comparisonTable/ComparisonTable.test.ts index c0970e35f..6419c2d4a 100644 --- a/report-viewer/tests/unit/components/comparisonTable/ComparisonTable.test.ts +++ b/report-viewer/tests/unit/components/comparisonTable/ComparisonTable.test.ts @@ -329,7 +329,7 @@ describe('ComparisonTable', async () => { expect(displayedComparisonsMaxSorted[2].firstSubmissionId).toBe('H') expect(displayedComparisonsMaxSorted[3].firstSubmissionId).toBe('E') - await metricOptions[7].trigger('click') + await metricOptions[6].trigger('click') await flushPromises() // Test sorting by cluster diff --git a/report-viewer/tests/unit/components/comparisonTable/ComparisonTableFilter.test.ts b/report-viewer/tests/unit/components/comparisonTable/ComparisonTableFilter.test.ts index c6752cb13..828402142 100644 --- a/report-viewer/tests/unit/components/comparisonTable/ComparisonTableFilter.test.ts +++ b/report-viewer/tests/unit/components/comparisonTable/ComparisonTableFilter.test.ts @@ -50,17 +50,12 @@ describe('ComparisonTableFilter', async () => { expect(store().uiState.comparisonTableClusterSorting).toBeFalsy() expectHighlighting(1) - await options[4].trigger('click') - expect(store().uiState.comparisonTableSortingMetric).toBe(MetricJsonIdentifier.SYMMETRIC) - expect(store().uiState.comparisonTableClusterSorting).toBeFalsy() - expectHighlighting(4) - - await options[7].trigger('click') + await options[6].trigger('click') expect(store().uiState.comparisonTableSortingMetric).toBe( MetricJsonIdentifier.AVERAGE_SIMILARITY ) expect(store().uiState.comparisonTableClusterSorting).toBeTruthy() - expectHighlighting(7) + expectHighlighting(6) await options[0].trigger('click') expect(store().uiState.comparisonTableSortingMetric).toBe( diff --git a/report-viewer/tests/unit/model/factories/ComparisonFactory.test.ts b/report-viewer/tests/unit/model/factories/ComparisonFactory.test.ts index 24d6ce8e7..c8a250fb7 100644 --- a/report-viewer/tests/unit/model/factories/ComparisonFactory.test.ts +++ b/report-viewer/tests/unit/model/factories/ComparisonFactory.test.ts @@ -63,7 +63,6 @@ describe('Test JSON to Comparison', () => { expect(result.similarities[MetricJsonIdentifier.MAXIMUM_SIMILARITY]).toBe(0.5) expect(result.similarities[MetricJsonIdentifier.MINIMUM_SIMILARITY]).toBe(0.4) expect(result.similarities[MetricJsonIdentifier.INTERSECTION]).toBe(229) - expect(result.similarities[MetricJsonIdentifier.SYMMETRIC]).toBe(0.5) expect(result.similarities[MetricJsonIdentifier.LONGEST_MATCH]).toBe(139) expect(result.similarities[MetricJsonIdentifier.OVERALL]).toBe(916) diff --git a/report-viewer/tests/unit/model/factories/OverviewFactory.test.ts b/report-viewer/tests/unit/model/factories/OverviewFactory.test.ts index 887114754..0df964249 100644 --- a/report-viewer/tests/unit/model/factories/OverviewFactory.test.ts +++ b/report-viewer/tests/unit/model/factories/OverviewFactory.test.ts @@ -37,7 +37,6 @@ describe('Test JSON to Overview', () => { [MetricJsonIdentifier.AVERAGE_SIMILARITY]: 0.9960435212660732, [MetricJsonIdentifier.MAXIMUM_SIMILARITY]: 0.9960435212660732, [MetricJsonIdentifier.MINIMUM_SIMILARITY]: 0.99, - [MetricJsonIdentifier.SYMMETRIC]: 0.98, [MetricJsonIdentifier.LONGEST_MATCH]: 13, [MetricJsonIdentifier.INTERSECTION]: 32, [MetricJsonIdentifier.OVERALL]: 100 @@ -53,7 +52,6 @@ describe('Test JSON to Overview', () => { [MetricJsonIdentifier.AVERAGE_SIMILARITY]: 0.751044776119403, [MetricJsonIdentifier.MAXIMUM_SIMILARITY]: 0.947289156626506, [MetricJsonIdentifier.MINIMUM_SIMILARITY]: 0.5, - [MetricJsonIdentifier.SYMMETRIC]: 0.8, [MetricJsonIdentifier.LONGEST_MATCH]: 4, [MetricJsonIdentifier.INTERSECTION]: 12, [MetricJsonIdentifier.OVERALL]: 133 @@ -69,7 +67,6 @@ describe('Test JSON to Overview', () => { [MetricJsonIdentifier.AVERAGE_SIMILARITY]: 0.751044776119403, [MetricJsonIdentifier.MAXIMUM_SIMILARITY]: 0.947289156626506, [MetricJsonIdentifier.MINIMUM_SIMILARITY]: 0.46, - [MetricJsonIdentifier.SYMMETRIC]: 0.78, [MetricJsonIdentifier.LONGEST_MATCH]: 12, [MetricJsonIdentifier.INTERSECTION]: 12, [MetricJsonIdentifier.OVERALL]: 98 @@ -85,7 +82,6 @@ describe('Test JSON to Overview', () => { [MetricJsonIdentifier.AVERAGE_SIMILARITY]: 0.28322981366459626, [MetricJsonIdentifier.MAXIMUM_SIMILARITY]: 0.8085106382978723, [MetricJsonIdentifier.MINIMUM_SIMILARITY]: 0.1, - [MetricJsonIdentifier.SYMMETRIC]: 0.456, [MetricJsonIdentifier.LONGEST_MATCH]: 5, [MetricJsonIdentifier.INTERSECTION]: 6, [MetricJsonIdentifier.OVERALL]: 32 @@ -101,7 +97,6 @@ describe('Test JSON to Overview', () => { [MetricJsonIdentifier.AVERAGE_SIMILARITY]: 0.2378472222222222, [MetricJsonIdentifier.MAXIMUM_SIMILARITY]: 0.9716312056737588, [MetricJsonIdentifier.MINIMUM_SIMILARITY]: 0.05, - [MetricJsonIdentifier.SYMMETRIC]: 0.23, [MetricJsonIdentifier.LONGEST_MATCH]: 7, [MetricJsonIdentifier.INTERSECTION]: 9, [MetricJsonIdentifier.OVERALL]: 34 @@ -117,7 +112,6 @@ describe('Test JSON to Overview', () => { [MetricJsonIdentifier.AVERAGE_SIMILARITY]: 0.2378472222222222, [MetricJsonIdentifier.MAXIMUM_SIMILARITY]: 0.9716312056737588, [MetricJsonIdentifier.MINIMUM_SIMILARITY]: 0.06, - [MetricJsonIdentifier.SYMMETRIC]: 0.235, [MetricJsonIdentifier.LONGEST_MATCH]: 3, [MetricJsonIdentifier.INTERSECTION]: 6, [MetricJsonIdentifier.OVERALL]: 134 @@ -145,12 +139,6 @@ describe('Test JSON to Overview', () => { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3 - ]), - [MetricJsonIdentifier.SYMMETRIC]: new Distribution([ - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]) }, _clusters: [ diff --git a/report-viewer/tests/unit/model/factories/ValidComparison.json b/report-viewer/tests/unit/model/factories/ValidComparison.json index 5e3ac8064..d40c4ffa6 100644 --- a/report-viewer/tests/unit/model/factories/ValidComparison.json +++ b/report-viewer/tests/unit/model/factories/ValidComparison.json @@ -7,7 +7,6 @@ "MIN": 0.4, "LONGEST_MATCH": 139, "INTERSECTION": 229, - "SYMMETRIC": 0.5, "OVERALL": 916 }, diff --git a/report-viewer/tests/unit/model/factories/ValidOverview.json b/report-viewer/tests/unit/model/factories/ValidOverview.json index 5b0843d22..0cf779aca 100644 --- a/report-viewer/tests/unit/model/factories/ValidOverview.json +++ b/report-viewer/tests/unit/model/factories/ValidOverview.json @@ -34,44 +34,38 @@ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3 - ], - "SYMMETRIC": [ - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 ] }, "top_comparisons": [ { "first_submission": "A", "second_submission": "C", - "similarities": { "AVG": 0.9960435212660732, "MAX": 0.9960435212660732, "MIN": 0.99, "SYMMETRIC": 0.98, "LONGEST_MATCH": 13.0, "INTERSECTION": 32.0, "OVERALL": 100.0 } + "similarities": { "AVG": 0.9960435212660732, "MAX": 0.9960435212660732, "MIN": 0.99, "LONGEST_MATCH": 13.0, "INTERSECTION": 32.0, "OVERALL": 100.0 } }, { "first_submission": "D", "second_submission": "A", - "similarities": { "AVG": 0.751044776119403, "MAX": 0.947289156626506, "MIN": 0.5, "SYMMETRIC": 0.8, "LONGEST_MATCH": 4.0, "INTERSECTION": 12.0, "OVERALL": 133.0 } + "similarities": { "AVG": 0.751044776119403, "MAX": 0.947289156626506, "MIN": 0.5, "LONGEST_MATCH": 4.0, "INTERSECTION": 12.0, "OVERALL": 133.0 } }, { "first_submission": "D", "second_submission": "C", - "similarities": { "AVG": 0.751044776119403, "MAX": 0.947289156626506, "MIN": 0.46, "SYMMETRIC": 0.78, "LONGEST_MATCH": 12.0, "INTERSECTION": 12.0, "OVERALL": 98.0 } + "similarities": { "AVG": 0.751044776119403, "MAX": 0.947289156626506, "MIN": 0.46, "LONGEST_MATCH": 12.0, "INTERSECTION": 12.0, "OVERALL": 98.0 } }, { "first_submission": "B", "second_submission": "D", - "similarities": { "AVG": 0.28322981366459626, "MAX": 0.8085106382978723, "MIN": 0.1, "SYMMETRIC": 0.456, "LONGEST_MATCH": 5.0, "INTERSECTION": 6.0, "OVERALL": 32.0 } + "similarities": { "AVG": 0.28322981366459626, "MAX": 0.8085106382978723, "MIN": 0.1, "LONGEST_MATCH": 5.0, "INTERSECTION": 6.0, "OVERALL": 32.0 } }, { "first_submission": "B", "second_submission": "A", - "similarities": { "AVG": 0.2378472222222222, "MAX": 0.9716312056737588, "MIN": 0.05, "SYMMETRIC": 0.23, "LONGEST_MATCH": 7.0, "INTERSECTION": 9.0, "OVERALL": 34.0 } + "similarities": { "AVG": 0.2378472222222222, "MAX": 0.9716312056737588, "MIN": 0.05, "LONGEST_MATCH": 7.0, "INTERSECTION": 9.0, "OVERALL": 34.0 } }, { "first_submission": "B", "second_submission": "C", - "similarities": { "AVG": 0.2378472222222222, "MAX": 0.9716312056737588, "MIN": 0.06, "SYMMETRIC": 0.235, "LONGEST_MATCH": 3.0, "INTERSECTION": 6.0, "OVERALL": 134.0 } + "similarities": { "AVG": 0.2378472222222222, "MAX": 0.9716312056737588, "MIN": 0.06, "LONGEST_MATCH": 3.0, "INTERSECTION": 6.0, "OVERALL": 134.0 } } ], "clusters": [