{"id":21588785,"url":"https://github.com/robcyberlab/ngram-similarity-engine","last_synced_at":"2026-05-19T10:37:26.773Z","repository":{"id":263124988,"uuid":"889419965","full_name":"RobCyberLab/Ngram-Similarity-Engine","owner":"RobCyberLab","description":"🤖Ngram Similarity Engine📚","archived":false,"fork":false,"pushed_at":"2024-11-16T20:36:45.000Z","size":3800,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T16:12:10.544Z","etag":null,"topics":["code-analysis","data-filtering","data-science","database-management","feature-extraction","jaccard-similarity","machine-learning","ngrams","plagiarism-detection","similarity-analysis","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobCyberLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-16T10:36:31.000Z","updated_at":"2024-11-16T20:36:48.000Z","dependencies_parsed_at":"2024-11-16T11:39:42.237Z","dependency_job_id":null,"html_url":"https://github.com/RobCyberLab/Ngram-Similarity-Engine","commit_stats":null,"previous_names":["robcyberlab/ngram-similarity-engine"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobCyberLab%2FNgram-Similarity-Engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobCyberLab%2FNgram-Similarity-Engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobCyberLab%2FNgram-Similarity-Engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobCyberLab%2FNgram-Similarity-Engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobCyberLab","download_url":"https://codeload.github.com/RobCyberLab/Ngram-Similarity-Engine/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244197662,"owners_count":20414437,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-analysis","data-filtering","data-science","database-management","feature-extraction","jaccard-similarity","machine-learning","ngrams","plagiarism-detection","similarity-analysis","sqlite"],"created_at":"2024-11-24T16:11:08.746Z","updated_at":"2026-05-19T10:37:26.722Z","avatar_url":"https://github.com/RobCyberLab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖Ngram-Similarity-Engine📚\n\nIn this project, we will use extracted n-grams to build a database of features for a collection of programs.\n\nNote: Due to privacy policies, I am not allowed to post the dataset publicly.\n\n---\n\n## Table of Contents📑\n1. [Introduction](#introduction)\n2. [Building the SQLite Database](#building-the-sqlite-database)\n3. [Filtering Frequent N-Grams](#filtering-frequent-n-grams)\n4. [Implemented Features](#implemented-features)\n5. [Similarity Calculation](#similarity-calculation)\n6. [Analysis and Conclusions](#analysis-and-conclusions)\n\n---\n\n## Introduction📘\n\nIn this project, we will create and analyze SQLite databases that store n-grams extracted from student files. The goal is to apply methods for storage, filtering, and similarity analysis to detect patterns and relationships between programs.\n\n---\n\n## Building the SQLite Database🛠️\n\n1. **SQLite Database `raw.db`**  \n   Contains a `Homeworks` table with the following structure:  \n   - `Hash` - the file hash (MD5, SHA-1, or SHA-256)  \n   - `Assign` - the assignment number  \n   - `Student` - the student's identifier  \n   - `Ngrams` - a blob containing a sorted list of extracted n-grams. Each n-gram is represented as an unsigned 32-bit integer.  \n\n---\n\n## Filtering Frequent N-Grams🗂️\n\n2. **SQLite Database `features.db`**  \n   Based on `raw.db`, this database is built with the same structure but excludes n-grams that appear in more than `T` files (where `T = 30` is suggested).  \n\n---\n\n## Implemented Features🧩\n\n3. **Functions**:  \n   - `sim1(db, h1, h2)`  \n     Calculates the Jaccard similarity based on two provided hashes.  \n   - `sim2(db, assign, s1, s2)`  \n     Calculates the Jaccard similarity based on an assignment number and two student identifiers.  \n     - Returns `0` if one of the students does not exist in the database.  \n\n---\n\n## Similarity Calculation📊\n\n4. **For each assignment**:  \n   - Calculate the similarity between all pairs of submissions.  \n   - Create a top-500 list of the most similar pairs for each of the two databases (`raw.db` and `features.db`).  \n\n5. **Analyze source code**:  \n   - Select 10 pairs of code from each top list for further analysis.  \n\n---\n\n## Analysis and Conclusions🔍\n\n- The analysis of similar pairs provides insights into potential common patterns or plagiarism among students.  \n- Using n-grams and the optimized database (`features.db`) helps reduce noise caused by frequently used elements.  \n\n---\n\n### Instructions for Use💾\n1. Build the `raw.db` database using the initial collection of files.  \n2. Apply filtering to create the `features.db` database.  \n3. Implement the `sim1` and `sim2` functions.  \n4. Calculate and analyze similarities according to the requirements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobcyberlab%2Fngram-similarity-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobcyberlab%2Fngram-similarity-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobcyberlab%2Fngram-similarity-engine/lists"}