11# Usage
22
3- plagcheck provides the following class constructors
3+ plagcheck provides the following classes:
44
55### check(files, lang, user_id)
66
@@ -17,27 +17,28 @@ plagcheck provides the following class constructors
1717import os
1818import pprint
1919from plagcheck import plagcheck
20+
2021from dotenv import load_dotenv
2122load_dotenv()
2223
23- program_files = [
24- " testfiles/test_python.py" ,
25- " testfiles/test_python3.py" ,
26- " testfiles/test_python2.py"
27- ]
28-
2924language = " python"
3025userid = os.environ[" USER_ID" ]
3126
3227
33- cheat = plagcheck.check(program_files, language, userid)
28+ moss = plagcheck.check(language, userid)
29+
30+ moss.addFilesByWildCard(" testfiles/test_python*.py" )
3431
35- # cheat.addBaseCode("submission/a01 .py")
32+ # or moss.addFile("testfiles/test_python .py")
3633
37- cheat .submit()
34+ moss .submit()
3835
39- print (cheat.getHomePage())
40- pprint.pprint(cheat.getResults())
36+ print (moss.getHomePage())
37+ pprint.pprint(moss.getResults())
38+ # print frequency of each shared solution
39+ pprint.pprint(moss.getShareScores())
40+ # print potential distributor-culprit relationships
41+ pprint.pprint(moss.getInsights())
4142
4243```
4344
@@ -55,7 +56,7 @@ c.submit()
5556### 2. getHomePage()
5657** Parameters** : ` None ` <br >
5758** Return Type** : ` String ` <br >
58- ** Description** : Returns the Moss Result HomePage<br >
59+ ** Description** : Returns the Moss Result HomePage URL <br >
5960** Demo** :
6061``` python
6162
@@ -84,4 +85,98 @@ c.getResults()
8485]
8586"""
8687
87- ```
88+ ```
89+
90+ * getResults()* returns the following list of dictionaries:
91+ ``` json
92+ [
93+ {
94+ "file1" :" filename1.py" ,
95+ "file2" :" filename2.py" ,
96+ "percentage" : 34 ,
97+ "no_of_lines_matched" : 3 ,
98+ "lines_matched" :[[" 2-3" , " 10-11" ]]
99+ },
100+ ....
101+ ]
102+ ```
103+ Each dict item contains the following items:
104+
105+ - ** file1** & ** file2** :
106+ The pair of file names that have similar code.
107+
108+ - ** percentage** :
109+ It is the the percentage of the code in one file considered to match code in the other file.
110+
111+ - ** lines_matched** :
112+ Lines Matched is approximately the number of lines of code that matched between 2 given files.
113+
114+ For example :
115+ If *** lines_matched* is [[ '88-99','119-131']] **
116+
117+ Then the line numbers 88-99 of * file1* matched with lines 119-131 of * file2* .
118+
119+ lines_matched is a list of lists indicating all line number matches between 2 code files.
120+
121+
122+ > For both measures(* lines_matched* & * percentage* ), higher numbers mean more code matches.
123+
124+ ### 4. addFilesByWildCard()
125+ ** Parameters** : ` String ` <br >
126+ ** Return Type** : ` None ` <br >
127+ ** Description** : Add multiple files.<br >
128+ ** Demo** :
129+ ``` python
130+
131+ c.addFilesByWildCard(" testfiles/test_python*.py" )
132+ # This will add all the files having names like, test_python2, test_python5 etc.
133+
134+ ```
135+
136+ ### 5. addFile()
137+ ** Parameters** : ` String ` <br >
138+ ** Return Type** : ` None ` <br >
139+ ** Description** : Add a single file for submission.<br >
140+ ** Demo** :
141+ ``` python
142+
143+ c.addFile(" testfiles/test_python.py" )
144+
145+ ```
146+
147+ ### 6. addBaseCode()
148+ ** Parameters** : ` String ` <br >
149+ ** Return Type** : ` None ` <br >
150+ ** Description** : Add an allowed code file which is use by Moss to ignore results matching with this file<br >
151+ ** Demo** :
152+ ``` python
153+
154+ c.addBaseCode(" /base.py" )
155+
156+ ```
157+
158+ - Moss normally reports all code
159+ that matches in pairs of files. When a base file is supplied,
160+ program code that also appears in the base file is not counted in matches.
161+ - A typical base file will include, for example, the instructor-supplied
162+ code for an assignment. Multiple Base files are allowed.
163+ - You should use a base file if it is convenient; base files improve results, but are not usually necessary for obtaining useful information.
164+
165+ ### 7. getShareScores()
166+ ** Parameters** : ` None ` <br >
167+ ** Return Type** : ` Dict ` <br >
168+ ** Description** : Share Score is a utility which returns frequency of every individual file.<br >
169+ ** Demo** :
170+ ``` python
171+
172+ c.getShareScores()
173+
174+ # Will return
175+ """
176+ {'testfiles/test_python.py': 2,
177+ 'testfiles/test_python2.py': 2,
178+ 'testfiles/test_python3.py': 2}
179+ """
180+ ```
181+ Share Score is basically the frequency of each file appearing in Moss Results.
182+ i.e Higher the frequency, the more is that solution "shared" by different files.
0 commit comments