How architshukla/plagiarism-checker works
Purpose and execution model
This is a server-hosted document plagiarism checker. A PHP/Bootstrap UI accepts a document, invokes a Python analysis pipeline, and exposes persisted output/logs. The standalone analyzer can also run as python scripts/main.py <input> <output>.
User-facing PHP entry points
• index.php is the primary upload/check interface.
• processFile.php handles uploaded-file processing and likely bridges PHP requests to the analysis scripts.
• executeScripts.php is the execution boundary for launching backend work.
• logs.php and readLogs.php expose prior analysis status or results.
The browser layer is static Bootstrap/jQuery assets under assets/css/bootstrap.css, assets/js/bootstrap.js, and assets/js/jquery.js.
Document ingestion and normalization
Uploaded source files are staged in temp/ (represented by temp/Placeholder.md). The Python backend supports text plus office/PDF formats through format-specific tools:
• DOCX extraction: scripts/extractdocx.py
• DOC/PPT conversion binaries: scripts/catdoc.exe, scripts/catppt.exe
• PDF text extraction: scripts/pdftotext32.exe, scripts/pdftotext64.exe
This is a critical trust and process boundary: PHP-provided filenames/paths ultimately feed local command execution and parsers.
Plagiarism-analysis pipeline
scripts/main.py orchestrates the core workflow: derive n-gram queries from extracted source text, search for candidate web pages, compare candidate content to the source/query, and write average similarity results to an output text file. scripts/getq.py is the likely query-generation stage, while scripts/htmlstrip.py converts fetched HTML into comparable text.
Primary flow: uploaded document → extracted plain text → generated n-gram search queries → online search results/URLs → fetched and stripped page text → per-result similarity → aggregated output.
Similarity engine
scripts/cosineSim.py provides the text-comparison mechanism used to score query/source text against web-page content. Similarity is therefore lexical/vector-based rather than a stored corpus or ML service. Intermediate/sample artifacts (scripts/sampleText.txt, scripts/sampleOut.txt) indicate file-oriented input/output contracts between stages.
External services, runtimes, and dependencies
The application requires a PHP-capable web server and a Python runtime (apparently Python 2-era dependencies). The pipeline depends on Google Search APIs for discovery and Internet access to retrieve result pages. DOCX support uses python-docx and its dependencies (PIL, lxml, python-dateutil); Linux deployments may instead rely on installed pdftotext/catdoc.
Windows Python location is configured through config/config.txt, making PHP-to-Python invocation deployment-specific.
Persistence and operational boundaries
temp/ is mutable upload workspace; output and operational history are mediated by the PHP log endpoints (logs.php, readLogs.php). The repository has no database or asynchronous worker structure visible: request handlers likely synchronously start Python and exchange data through filesystem paths/output files. This creates coupling among web-server permissions, executable availability, temp-file lifecycle, and external search/network latency.
Main entry points: main.py Analysis orchestrator · Placeholder.md Temporary workspace · processFile.php Upload processor · executeScripts.php Script launcher
Components 17
PHP web application
- Browser UI
- Upload interface
index.php - Upload processor · Stages uploads and bridges requests to analysis.
processFile.php - Script launcher · Launches local backend work from PHP-provided inputs.
executeScripts.php - Logs and results UI
logs.php - Temporary workspace · Upload staging and file-based pipeline exchange.
temp/Placeholder.md
Python analysis pipeline
- Analysis orchestrator · Runs extraction, discovery, comparison, and output aggregation.
scripts/main.py - Document extraction · Converts supported documents into plain text.
scripts/extractdocx.py - Query generation
scripts/getq.py - Web candidate discovery
- HTML text normalization
scripts/htmlstrip.py - Similarity scoring · Scores source or query text against candidate page text.
scripts/cosineSim.py - Similarity output · Stores aggregated average similarity results.
scripts/sampleOut.txt
External tools and services
- Office/PDF converters · DOC, PPT, and PDF extraction binaries.
scripts/catdoc.exe - Google Search APIs
- Candidate web pages
- Python runtime configuration · Configures deployment-specific Python invocation.
config/config.txt
Connections 21
- Browser UI → Upload interface: uploads document
- Upload interface → Upload processor: submits upload
- Upload processor → Temporary workspace: stages file
- Upload processor → Script launcher: requests analysis
- Script launcher → Python runtime configuration: uses Python path
- Script launcher → Analysis orchestrator: starts CLI pipeline
- Temporary workspace → Analysis orchestrator: input/output paths
- Analysis orchestrator → Document extraction: extracts source text
- Document extraction → Office/PDF converters: uses for DOC/PPT/PDF
- Document extraction → Query generation: plain text
- Query generation → Web candidate discovery: n-gram queries
- Web candidate discovery → Google Search APIs: search requests
- Google Search APIs → Candidate web pages: candidate URLs
- Candidate web pages → HTML text normalization: fetched HTML
- HTML text normalization → Similarity scoring: page text
- Query generation → Similarity scoring: source/query text
- Similarity scoring → Similarity output: per-result scores
- Analysis orchestrator → Similarity output: aggregates averages
- Similarity output → Temporary workspace: persists result file
- Logs and results UI → Temporary workspace: reads status/results
- Browser UI → Logs and results UI: views prior runs