Skip to content

Commit

Permalink
Merge pull request #2 from BK-SCOSS/CLI
Browse files Browse the repository at this point in the history
Add Command Line Interface for scoss
  • Loading branch information
Dec1mo authored Apr 18, 2021
2 parents a3719b3 + 9a9a140 commit 71f24f8
Show file tree
Hide file tree
Showing 12 changed files with 518 additions and 202 deletions.
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,37 @@ pip install scoss
You can use SCOSS as a Command Line Interface, or a library in your project, or web-app interface

### Command Line Interface (CLI)
See document by passing ```--help``` argument.
```
scoss --help
Usage: scoss [OPTIONS]
Options:
-i, --input-dir TEXT Input directory. [required]
-o, --output-dir TEXT Output directory.
-tc, --threshold-combination [AND|OR]
AND: All metrics are greater than threshold.
OR: At least 1 metric is greater than
threshold.
-mo, --moss FLOAT RANGE Use moss metric and set up moss threshold.
-co, --count-operator FLOAT RANGE
Use count operator metric and set up count
operator threshold.
-so, --set-operator FLOAT RANGE
Use set operator metric and set up set
operator threshold.
-ho, --hash-operator FLOAT RANGE
Use hash operator metric and set up hash
operator threshold.
--help Show this message and exit.
```
To get plagiarism report of a directory containing source code files, add ```-i/ --input-dir``` option. Add at least 1 similarity metric in [```-mo/--moss```, ```-co/--count-operator```, ```-so/--set-operator```, ```-ho/--hash-operator```] and its threshold (in range [0,1]). If using 2 or more metrics, you need to define how they should be combined using ```-tc/--threshold-combination``` (```AND``` will be used by default).

Comming soon...

Basic command: ```scoss -i path/to/source_code_dir/ -tc OR -co 0.1 -ho 0.1 -mo 0.1 -o another_path/to/plagiarism_report/```
### Using as a library

1. Define a `Scoss` object and register some metrics:
Expand Down Expand Up @@ -63,4 +91,4 @@ This project is in development, if you find any issues, please create an issue [
## Acknowledgements
This project is sponsored and led by Prof. Do Phan Thuan, Hanoi University of Science and Technology.

A part of this code adapts this source code https://github.com/soachishti/moss.py as baseline for `SMoss`.
A part of this code adapts this source code https://github.com/soachishti/moss.py as baseline for `SMoss`.
52 changes: 0 additions & 52 deletions scoss/assets/comparison.html

This file was deleted.

50 changes: 0 additions & 50 deletions scoss/assets/smoss_comparison.html

This file was deleted.

72 changes: 0 additions & 72 deletions scoss/assets/summary.html

This file was deleted.

44 changes: 44 additions & 0 deletions scoss/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import scoss

import click

@click.command()
@click.option(
'--input-dir', '-i', required=True,
help='Input directory.'
)
@click.option(
'--output-dir', '-o',
help='Output directory.'
)
@click.option(
'--threshold-combination', '-tc',
type=click.Choice(['AND','OR'], case_sensitive=False),
help='AND: All metrics are greater than threshold.\nOR: At least 1 metric is greater than threshold.'
)
@click.option(
'--moss', '-mo', type=click.FloatRange(0,1),
help='Use moss metric and set up moss threshold.'
)
@click.option(
'--count-operator', '-co', type=click.FloatRange(0,1),
help='Use count operator metric and set up count operator threshold.'
)
@click.option(
'--set-operator', '-so', type=click.FloatRange(0,1),
help='Use set operator metric and set up set operator threshold.'
)
@click.option(
'--hash-operator', '-ho', type=click.FloatRange(0,1),
help='Use hash operator metric and set up hash operator threshold.'
)
def scoss_command(input_dir, output_dir, threshold_combination,\
moss, count_operator, set_operator, hash_operator):
if not output_dir:
output_dir = './'

scoss.get_all_plagiarism(input_dir, output_dir, threshold_combination,
moss, count_operator, set_operator, hash_operator)

if __name__ == '__main__':
scoss_command()
Loading

0 comments on commit 71f24f8

Please sign in to comment.