-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #453 from nestabentum/cluster_in_report
Write Clusters To JSON Report
- Loading branch information
Showing
10 changed files
with
185 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
jplag/src/main/java/de/jplag/reporting/reportobject/mapper/ClusteringResultMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.jplag.reporting.reportobject.mapper; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import de.jplag.JPlagResult; | ||
import de.jplag.Submission; | ||
import de.jplag.clustering.ClusteringResult; | ||
import de.jplag.reporting.reportobject.model.Cluster; | ||
|
||
/** | ||
* Extracts and maps the clusters from the JPlagResult to the corresponding JSON DTO | ||
*/ | ||
public class ClusteringResultMapper { | ||
public List<Cluster> map(JPlagResult result) { | ||
var clusteringResult = result.getClusteringResult(); | ||
return clusteringResult.stream().map(ClusteringResult::getClusters).flatMap(Collection::stream).map(this::convertCluster).toList(); | ||
} | ||
|
||
private Cluster convertCluster(de.jplag.clustering.Cluster<Submission> from) { | ||
var strength = from.getCommunityStrength(); | ||
var avgSimilarity = from.getAverageSimilarity(); | ||
var member = from.getMembers().stream().map(Submission::getName).toList(); | ||
return new Cluster(avgSimilarity, strength, member); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.