Skip to content

Commit 919f47f

Browse files
committed
build fix and PR feedback
1 parent c6c3bde commit 919f47f

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,14 @@ Subsequence Match Merging
173173
(between 1 and 50, default: 6).
174174
175175
Frequency Analysis
176-
--frequency-strategy=<{COMPLETE_MATCHES, CONTAINED_MATCHES, SUB_MATCHES,
177-
WINDOW_OF_MATCHES}>
176+
--frequency-strategy=<{COMPLETE_MATCHES, CONTAINED_MATCHES, SUB_MATCHES,
177+
WINDOW_OF_MATCHES}>
178178
Strategy for frequency Analysis, one of:
179-
COMPLETE_MATCHES, CONTAINED_MATCHES, SUB_MATCHES,
180-
WINDOW_OF_MATCHES (default: null).
179+
COMPLETE_MATCHES, CONTAINED_MATCHES, SUB_MATCHES,
180+
WINDOW_OF_MATCHES (default: null).
181181
--weighting-strategy=<{PROPORTIONAL, LINEAR, QUADRATIC, SIGMOID}>
182182
Strategy for frequency Weighting, one of: PROPORTIONAL,
183-
LINEAR, QUADRATIC, SIGMOID
184-
(default: null).
183+
LINEAR, QUADRATIC, SIGMOID (default: null).
185184
Languages:
186185
c
187186
cpp

core/src/main/java/de/jplag/JPlagComparison.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public final double minimalSimilarity() {
7171

7272
/**
7373
* Computes the average (or symmetric) similarity between the two submissions. The similarity is adjusted based on
74-
* whether both submissions contain base code matches.
74+
* whether both submissions contain base code matches. Checks if the frequency analysis is used, if it is then a
75+
* frequency based similarity score will be returned.
7576
* @return Average similarity in interval [0, 1]. 0 means zero percent structural similarity, 1 means 100 percent
7677
* structural similarity.
7778
*/

core/src/main/java/de/jplag/highlightextraction/ContainedMatchesStrategy.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ public double calculateMatchFrequency(Match match, Map<List<TokenType>, Integer>
5252
List<List<TokenType>> subSequences = getSubSequences(matchToken, minSubSequenceLength);
5353
List<Integer> frequencies = new ArrayList<>();
5454
for (List<TokenType> subsequence : subSequences) {
55-
frequencies.add(frequencyMap.getOrDefault(subsequence, 0));
55+
Integer subSequenceFrequency = frequencyMap.get(subsequence);
56+
if (subSequenceFrequency != null && subSequenceFrequency != 0) {
57+
frequencies.add(subSequenceFrequency);
58+
}
5659
}
57-
return frequencies.stream().filter(frequency -> frequency > 0).mapToInt(Integer::intValue).average().orElse(0.0);
60+
return frequencies.stream().mapToInt(Integer::intValue).average().orElse(0.0);
5861
}
59-
6062
}

docs/1.-How-to-Use-JPlag.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,14 @@ Subsequence Match Merging
108108
(between 1 and 50, default: 6).
109109
110110
Frequency Analysis
111-
--frequency-strategy=<{COMPLETE_MATCHES,
112-
CONTAINED_MATCHES, SUB_MATCHES, WINDOW_OF_MATCHES}>
113-
Strategy for frequency Analysis, one
114-
of: COMPLETE_MATCHES, CONTAINED_MATCHES, SUB_MATCHES,
111+
--frequency-strategy=<{COMPLETE_MATCHES, CONTAINED_MATCHES, SUB_MATCHES,
112+
WINDOW_OF_MATCHES}>
113+
Strategy for frequency Analysis, one of:
114+
COMPLETE_MATCHES, CONTAINED_MATCHES, SUB_MATCHES,
115115
WINDOW_OF_MATCHES (default: null).
116116
--weighting-strategy=<{PROPORTIONAL, LINEAR, QUADRATIC, SIGMOID}>
117-
Strategy for frequency Weighting, one
118-
of: PROPORTIONAL, LINEAR, QUADRATIC, SIGMOID
119-
(default: null).
117+
Strategy for frequency Weighting, one of: PROPORTIONAL,
118+
LINEAR, QUADRATIC, SIGMOID (default: null).
120119
Languages:
121120
c
122121
cpp

0 commit comments

Comments
 (0)