# MOSS [TOC] ## 前言 MOSS是一個比對code的工具,比對它們之間相似度的工具。MOSS是針對一些抄襲的手法設計,因此像是**更改變數名稱**、**呼叫順序**、**註解**、**簡易的邏輯替換**、**垃圾code**等,都會是被判定為相似喔。使用方式要用 script,我們以下介紹以 Python 為主。可以先進到以下網站瀏覽一下。 MOSS 網站 : https://theory.stanford.edu/~aiken/moss/ ## 使用 <font color=#bf2222>**Step1 申請userid:**</font> 寄信給MOSS,請根據以下格式。 `收件者`填 moss@moss.stanford.edu `標題`可以不用打 `內容`依照底下的打就可以了(email換成自己的) ``` registeruser mail abc1234567@gmail.com ``` 不久後就會收到MOSS寄來的回信囉。 <font color=#bf2222>**Step2 用pip下載模組:**</font> Python Client GitHub : https://github.com/soachishti/moss.py 首先開啟cmd進到pip.exe的資料夾當中,用以下指令下載MOSS的模組: (使用pip下載要先裝pip,沒有的話可以上網查一下如何下載。) ``` pip install mosspy ``` <font color=#bf2222>**Step3 執行:**</font> 首先要知道自己的 userid,這會在MOSS寄的回信當中,打開那封信,直接`Ctrl+F`搜尋 userid 即可找到,後面那串數字就是 userid 喔! |  | | -------- | 可以參考以下模板,記得把 userid 那邊改成自己的: ```python= import mosspy userid = 987654321 m = mosspy.Moss(userid, "python") m.addBaseFile("submission/a01.py") m.addBaseFile("submission/test_student.py") # Submission Files m.addFile("submission/a01-sample.py") m.addFilesByWildcard("submission/a01-*.py") url = m.send() # Submission Report URL print ("Report Url: " + url) # Save report file m.saveWebPage(url, "submission/report.html") # Download whole report locally including code diff links mosspy.download_report(url, "submission/report/", connections=8) ``` 根據需求,更改 Code 的內容: - `mosspy.Moss`宣告。 - `m.addBaseFile`應該是如果你有一個基本的 template 給所有人,就放那個 template。 - `addFile`加入檔案,通常在加入單一檔案使用。 - `addFilesByWildcard`用正規表示式 (Regular Expression) 表示你想選取的所有檔案,通常在加入多個檔案使用。 - `send`送出。 - `print url`它會回傳給你一個 url,把 url 放到瀏覽器上就可以看到結果了。 - `saveWebPage`跟`download_report`下載report的結果。 執行後可以進入回傳的網址,察看結果: |  | | -------- | P.S. 40%以上就算是相似度很高的喔!分享一下去年的實際案例: | LAB4 | LAB5 | | -------- | -------- | |  |  | # [HOMEPAGE](https://hackmd.io/s/HJdaLPTQV)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up