Skip to content

Commit

Permalink
remove symmetric similarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Jan 10, 2025
1 parent b22563c commit f643387
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 49 deletions.
1 change: 0 additions & 1 deletion core/src/main/java/de/jplag/options/SimilarityMetric.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public enum SimilarityMetric implements ToDoubleFunction<JPlagComparison> {
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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 0 additions & 1 deletion report-viewer/src/components/ComparisonTableFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ const tableSortingOptions = computed(() => {
const secondaryMetricOptions = [
MetricJsonIdentifier.MAXIMUM_SIMILARITY,
MetricJsonIdentifier.MINIMUM_SIMILARITY,
MetricJsonIdentifier.SYMMETRIC,
MetricJsonIdentifier.INTERSECTION,
MetricJsonIdentifier.LONGEST_MATCH,
MetricJsonIdentifier.OVERALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
</script>
10 changes: 1 addition & 9 deletions report-viewer/src/model/MetricType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export enum MetricJsonIdentifier {
MAXIMUM_SIMILARITY = 'MAX',
MINIMUM_SIMILARITY = 'MIN',
INTERSECTION = 'INTERSECTION',
SYMMETRIC = 'SYMMETRIC',
LONGEST_MATCH = 'LONGEST_MATCH',
OVERALL = 'OVERALL'
}
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -124,7 +118,6 @@ export namespace MetricTypes {
MAXIMUM_SIMILARITY,
MINIMUM_SIMILARITY,
INTERSECTION,
SYMMETRIC,
LONGEST_MATCH,
OVERALL
]
Expand All @@ -141,7 +134,6 @@ export namespace MetricTypes {
MetricJsonIdentifier.MAXIMUM_SIMILARITY,
MetricJsonIdentifier.MINIMUM_SIMILARITY,
MetricJsonIdentifier.INTERSECTION,
MetricJsonIdentifier.SYMMETRIC,
MetricJsonIdentifier.LONGEST_MATCH,
MetricJsonIdentifier.OVERALL
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 0 additions & 12 deletions report-viewer/tests/unit/model/factories/OverviewFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"MIN": 0.4,
"LONGEST_MATCH": 139,
"INTERSECTION": 229,
"SYMMETRIC": 0.5,
"OVERALL": 916

},
Expand Down
18 changes: 6 additions & 12 deletions report-viewer/tests/unit/model/factories/ValidOverview.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down

0 comments on commit f643387

Please sign in to comment.