How sms03/plagiarism-checking-code works
Main Components
• User Interface (CLI): Although simple, the script prompts the user for inputs such as the GitHub Personal Access Token, the repository path, and the number of lines per snippet.
• Input Handler/Controller: A portion of the script responsible for collecting and validating user inputs.
• Snippet Extraction Module: The logic that reads the target repository, splits the files into code snippets (with configurable snippet lengths), and prepares them for matching.
• GitHub API Client: A component that constructs and sends requests to the GitHub API with the provided token to search for similar code snippets.
• Response Processor & Output Generator: The logic that processes the API responses, determines if plagiarism (i.e., matching code) is detected, and outputs the results clearly to the command line.
Relationships and Interactions
• The CLI receives initial inputs from the user.
• The Input Handler processes these inputs and passes them to the Snippet Extraction Module.
• The Snippet Extraction Module identifies potential code snippets from the provided repository.
• For each snippet, the GitHub API Client sends out a search request.
• API responses are returned and processed by the Response Processor, which then routes the results to the Output Generator.
• The output is printed or logged so that the user can see if matches (indicative of potential plagiarism) are found.
Architectural Patterns and Principles
• Even though this is a fairly direct script, it is good practice to employ a modular approach by logically separating responsibilities (input handling, snippet extraction, API handling, and output).
• The design shows a clear separation of concerns and a pipeline-like flow where each module processes and forwards information to the next step.
Relevant Technologies and Frameworks
• Python 3.6+ is the runtime environment.
• The ‘requests’ library is used for interacting with the GitHub API.
• GitHub’s REST API is the external service for code search.
Elements
• Clear labels: Each component (CLI, Input Handler, Snippet Extractor, GitHub API Client, Response Processor, and Output Generator) should be clearly identified.