Giter Club home page Giter Club logo

jplag's Introduction

JPlag logo

JPlag - Detecting Software Plagiarism

CI Build Latest Release Maven Central License Lines of code

Download and Installation

Downloading a release

Via Maven

JPlag is released on Maven Central, it can be included as follows:

<dependency>
  <groupId>de.jplag</groupId>
  <artifactId>jplag</artifactId>
</dependency>

Building from sources

  1. Download or clone the code from this repository.
  2. Run mvn clean package from the root of the repository to compile and build all submodules. Run mvn clean package assembly:single instead if you need the full jar which includes all dependencies.
  3. You will find the generated JARs in the subdirectory jplag/target.

Usage

JPlag can either be used via the CLI or directly via its Java API. For more information, see the usage information in the wiki.

CLI

Note that the legacy CLI is varying slightly.

JPlag - Detecting Software Plagiarism

Usage: JPlag [ options ] [<root-dir> ...]
 <root-dir>        Root-directory that contains submissions

named arguments:
  -h, --help             show this help message and exit
  -l                     {java,python3,cpp,csharp,char,text,scheme} Select the language to parse the submissions (default: java)
  -bc BC                 Path of the directory containing the base code (common framework used in all submissions)
  -v                     {quiet,long} Verbosity of the logging (default: quiet)
  -d                     Debug parser. Non-parsable files will be stored (default false)
  -S S                   Look in directories <root-dir>/*/<dir> for programs
  -p P                   comma-separated list of all filename suffixes that are included
  -x X                   All files named in this file will be ignored in the comparison (line-separated list)
  -t T                   Tunes the comparison sensitivity by adjusting the minimum token required to be counted as a matching section. A smaller <n> increases the sensitivity but might lead to more false-positives
  -m M                   Comparison similarity threshold [0-100]: All comparisons above this threshold will be saved (default: 0.0)
  -n N                   The maximum number of comparisons that will be shown in the generated report, if set to -1 all comparisons will be shown (default: 30)
  -r R                   Name of the directory in which the comparison results will be stored (default: result)
  -c                     {normal,parallel} Comparison mode used to compare the programs (default: normal)

Java API

The new API makes it easy to integrate JPlag's plagiarism detection into external Java projects:

JPlagOptions options = new JPlagOptions(List.of("/path/to/rootDir"), LanguageOption.JAVA);
options.setBaseCodeSubmissionName("template");

JPlag jplag = new JPlag(options);
JPlagResult result = jplag.run();

List<JPlagComparison> comparisons = result.getComparisons();

// Optional
File outputDir = new File("/path/to/output");
Report report = new Report(outputDir);

report.writeResult(result);

Contributing

We're happy to incorporate all improvements to JPlag into this codebase. Feel free to fork the project and send pull requests. Please consider our guidelines for contributions.

Contact

If you encounter bugs or other issues, please report them here. For other purposes, you can contact us at [email protected] . If you are doing research related to JPlag, we would love to know what you are doing. Feel free to contact us!

More information can be found in our Wiki!

jplag's People

Contributors

tsaglam avatar simding avatar dependabot[bot] avatar sebinside avatar alberth289346 avatar lama0206 avatar dfuchss avatar drmichaelpetter avatar waynetee avatar philipphundertmark avatar ov7a avatar sdk2 avatar tobhey avatar gabriell avatar erikmd avatar khumba avatar gsorf avatar dogayalcin avatar mutax avatar jlleitschuh avatar strohgelaender avatar rogerhub avatar krusche avatar glmax avatar

Forkers

abobaki

jplag's Issues

1. How to use

Reporting using the API

Reporting in JPlag can be used to create report files from a JPlagResult, which can then be easily saved, transferred or supplied to an application for displaying. Currently JPlag support reporting in JSON format. Further formats can be specified.
Reporting can be done through the Report interface. It provides two functions - getReportStrings and saveReport.

  • getReportStrings - takes a JPlagResult, converts it to a JPlagReport and returns a list of strings, where
    first string is the overview string and the remaining elements are the strings of
    the comparison reports. The strings rpresent the JSON serialization of the JPlagReport
  • saveReport - uses the getReportString to obtain the JSON strings
    of the report and saves them to JSON files in the provided folder path.

Example:

Report report = new JsonReport();

// Returns JSON strings in a list
List<String> jsonStrings = report.getReporStrings(jplagResult);

// Saves JSON strings of the report in the specified folder
report.saveReport(jPlagResult, "./path/to/destination/folder");

Running the Report Viewer

The JPlag Report Viewer is a Vue 3 + Typescript standalone application which can be used to display the JSON files generated by the JPlag reporting. The application requires Node.js and npm to be installed on the system.

  • Before first run execute: npm i.
  • To start the application, run the npm run serve command in the /report-viewer folder.

After the application has been started the user can select files to display in the following ways:

  • by providing overview.json and comparisons JSON files in the /report-viewer/files folder
  • by dragging and dropping a zip file containing the overview.json and comparisons JSON files
  • by dragging and dropping a single overview.json or a single comparison JSON file

Start page of the application
fileupload

3. Changes to README

Change

File outputDir = new File("/path/to/output");
Report report = new Report(outputDir);

report.writeResult(result);

with

Report report = new JsonReport();
report.saveReport(result, "/path/to/output")

2. Contributing to JPlag

Reporting design

The CLI uses the Report, which takes a JPlagResult in order to create report files. Currently JPlag supports reporting in JSON format. JsonReport implements the Report interface. Upon receiving the JPlagResult, the JsonReport uses the ReportObejctFactory in order to convert the JPlagResult in a simple Java DTO JPlagReport. After that the created JPlagReport is passed to the JsonFactory which converts the Java DTO JPlagReport to JSON strings and saves the files with the JACKSON library. The OverviewReport of the JPlagReport is saved as overveiw.json. Each ComparisonReport is saved as {id1}-{id2}.json where id1 is the name of the first submission in the comparison and id2 is the second submission's name. The class diagram represents the strucutre of the report generation process. The process flow can be observed in the following sequence diagram.

Class Diagram

classDiagram
    class CLI
    class Report
    class JPlagResult
    class JsonReport
    class JsonFactory
    class ReportObjectFactory
    class JPlagReport
    class overview {
    <<json file>>
    }
    class comparison {
        <<json file>>
    }
    
    CLI ..> Report : uses
    Report --> JPlagResult
    JsonReport ..|> Report
    JsonReport ..> JsonFactory
    JsonReport ..> ReportObjectFactory
    ReportObjectFactory --> JPlagReport : creates
    ReportObjectFactory ..> JPlagResult: uses
    JsonFactory --> JPlagReport : uses
    JsonFactory .. "1" overview : creates
    JsonFactory .. "*" comparison : creates
Loading

Sequence Diagram

sequenceDiagram
    CLI ->>+ JsonReport: saveReport(jplagResult)
    JsonReport ->>+ ReportObjectFactory: getReportObejct(jplagResult)
    ReportObjectFactory ->>+ JPlagReport: new JPlagReport()
    JPlagReport ->>+ ReportObjectFactory: jPlagReport
    ReportObjectFactory ->>+ JsonReport: jPlagReport
    JsonReport ->>+ JsonFactory: saveJsonFiles(jPlagReport)
    JsonFactory ->>+ JsonReport: boolean
    JsonReport ->>+ CLI: boolean
Loading

JPlagReport

A report in JPlag is represented by the JPlagReport class, which contains a single overview and a list of comparison reports. The overview encapsulates the main information from a JPlagResult such as base directory path, language, metrics used, etc. The comparison report encapsulates the information about a single comparison such as participating submissions, their files, similarity and matches between them. The full structure of the JPlagReport DTO can be observed in the following class diagram.

JPlagReport report = ReportObjectFactory.getReportObject(jPlagResult);
classDiagram
    class JPlagReport {

    OverviewReport overviewReport;
    List<ComparisonReport> comparisons;

    }
    class OverviewReport {
    
    }

    class ComparisonReport {

    }
    class Metric {

    }
    class Cluster { 

    }
    class Match {
      
    }
    class TopComparison {
        
    }
    class FilesOfSubmission {
        
    }
    JPlagReport --|> OverviewReport
    JPlagReport --|> ComparisonReport
    OverviewReport --|> Metric
    OverviewReport --|> Cluster
    Metric --|> TopComparison
    ComparisonReport --|> Match
    ComparisonReport --|> FilesOfSubmission
Loading

Specifying additional report formats

In order to specify a new report format (example: XML reporting), the report interface needs to be implemented. The existing logic for converting a JPlagResult to JPlagReport can be reused and the created DTO can be used as an input to a factory creating the new report format.

Report viewer

The report viewer accepts JSON files and displays them. When a JSON file is provided, the application uses the OverviewFactory or ComparisonFactory in order to convert the JSON file to a Typescript DTO. The DTOs are then used by the view components to get the needed information.

Adding and displaying new attributes from JPlagResult

The new design of JPlag reporting and viewing enables the easy addition of new attributes. Adding a new attribute follows the pattern:

  1. Introduce new attribute to the Java DTO.
  2. Define how the attribute is obtained from the JPlagResult in the ReportObjectFactory.
  3. Introduce the new attribute to the Typescript DTO.
  4. Define how the attribute is extracted from the JSON file.
  5. Display the attribute in the desired Vue component.

##Example
An example is provided in the following section which explains how new attributes can be introduced to the JPlagReport and then processed in the report viewer. In the following example we add the number of tokens per match to the JPlag report and view.

Task: Adding the number of tokens in a match, which has to be displayed in the MatchesTable in the ComparisonView.

  1. Add private final int tokens; to Match.java [JPlag]
  2. Add a getter for the field in Match.java [JPlag]
  3. Edit the convertMatchToReportMatch in ReportObejctFactory to get then umber of tokens from de.jplag.Match
    and save it in the Match DTO [JPlag]
  4. Add tokens: number to Match.ts [report-viewer]
  5. Edit mapMatch in ComparisonFactory.ts to get the number of tokens from the JSON report file. [report-viewer]
  6. Edit MatchTable.vue to display the tokens number in the ComparisonView.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.