File size: 6,654 Bytes
cc026a1 11bdf86 be02728 11bdf86 be02728 cc026a1 11bdf86 3a38682 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 11bdf86 be02728 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | ---
license: mit
task_categories:
- text-generation
- text2text-generation
language:
- code
tags:
- code
- programming-languages
- python
- javascript
- nodejs
- java
- c
- cpp
- rust
- sorting-algorithms
- data-structures
- synthetic
pretty_name: Multi-Language Programming Code Dataset
size_categories:
- 1K<n<10K
---
# NOTICE
This was done by me, someone with a learning Disability. So please do bare with me when updating this with more working data.
# Multi-Language Programming Code Dataset
A curated dataset of **original, non-scraped** code examples across 7 programming
environments: **Python, JavaScript, Node.js, Java, C, C++, and Rust**.
The dataset ships in two parts that can be used separately or combined:
| File | Rows | Description |
|---|---|---|
| `code_dataset.jsonl` / `.csv` | 105 | Hand-written "core concepts" set — one clean example per language per concept (Hello World, OOP, error handling, recursion, async, etc.) |
| `code_dataset_large.jsonl` / `.csv` | 2,255 | Template-generated, parameter-varied set covering **sorting algorithms, data structures, and string manipulation** in depth |
> **Note on Node.js:** Node.js is a JavaScript *runtime*, not a separate language.
> It's included as its own split because it exposes different APIs (filesystem,
> `Buffer`, `process`, `http`, CommonJS modules) than browser-context JavaScript —
> which is usually what people actually mean by "Node.js code."
## Dataset Structure
Both files share the same schema:
| Column | Description |
|---|---|
| `id` | Unique row identifier (per file) |
| `language` | One of: Python, JavaScript, Node.js, Java, C, C++, Rust |
| `category` | Concept/topic covered |
| `difficulty` | `beginner`, `intermediate`, or `advanced` |
| `task_description` | Natural-language description of the coding task |
| `code` | The code snippet solving the task |
| `explanation` | A short note on the key language feature/idiom used |
## `code_dataset` (105 rows) — Core Concepts
15 categories × 7 languages, one example each:
Hello World · Variables and Data Types · Control Flow · Loops · Functions ·
Arrays and Lists · Dictionaries and Maps · Classes and OOP · Error Handling ·
File I/O · String Manipulation · Recursion · Sorting Algorithm ·
Async and Concurrency · Data Structures
## `code_dataset_large` (2,255 rows) — Deep Coverage on 3 Categories
Generated by varying real parameters — algorithm choice, data type, sample
values, operation sequences, and identifier names — **not** by duplicating
templates with find-and-replace. Breakdown:
| Category | Rows | What varies |
|---|---|---|
| Sorting Algorithm | 756 | Algorithm (bubble/selection/insertion), data type (int/float), array size (5–20 elements), 3 random samples per config |
| Data Structures | 448 | Stack vs. Queue, data type (int/float), 4 distinct push/pop operation sequences, random values |
| String Manipulation | 1,051 | Operation (palindrome check, reverse, word count, vowel count), 20 distinct test strings, varied function names |
Distribution is balanced across languages (~320–326 rows each) and skews
`intermediate` (1,727) over `beginner` (528), reflecting the algorithmic focus
of this batch. Exact-duplicate rows were checked and removed (~3% collision
rate from small-integer arrays landing on the same random sample).
## Files
- `code_dataset.jsonl` / `code_dataset_large.jsonl` — one JSON object per line (recommended for `datasets.load_dataset("json", ...)`)
- `code_dataset.csv` / `code_dataset_large.csv` — same data, spreadsheet-friendly
- `generate_dataset.py` — generator for the 105-row core set (add more languages/categories by adding `add(...)` calls)
- `generate_batch.py` — generator for the 2,255-row deep-coverage set (add more categories/algorithms by extending the template dicts)
## Provenance & License
All code was **written from scratch** (hand-authored for the core set;
programmatically templated with varied real parameters for the large set) —
nothing was scraped from GitHub or any other source, so there are no
third-party license conflicts. Released under **MIT** — free to use, modify,
and redistribute, including for model training.
## Known Limitations
- The 2,255-row set currently covers only 3 categories in depth (sorting,
data structures, strings). Categories like "Hello World" or "Variables"
don't have enough genuine variation to scale the same way — padding them
would mean shallow repetition rather than useful diversity.
- For large-scale pretraining, pair this with an established corpus like
[The Stack](https://huggingface.co/datasets/bigcode/the-stack) or
[CodeSearchNet](https://huggingface.co/datasets/code_search_net).
- Snippets favor clarity/idiom over production hardening (minimal input
validation) — they teach the *pattern*, not production-ready code.
## Example Rows
**Core set:**
```json
{
"id": 1,
"language": "Python",
"category": "Hello World",
"difficulty": "beginner",
"task_description": "Print 'Hello, World!' to the console.",
"code": "print(\"Hello, World!\")",
"explanation": "Python's print() function writes text to standard output."
}
```
**Large set:**
```json
{
"id": 11,
"language": "Python",
"category": "Sorting Algorithm",
"difficulty": "intermediate",
"task_description": "Sort a 12-element array of ints in ascending order using bubble sort.",
"code": "def bubble_sort(entries):\n n = len(entries)\n ...",
"explanation": "Bubble sort on int data, variable named 'entries', 12 elements."
}
```
## Loading
**Hugging Face `datasets`:**
```python
from datasets import load_dataset
core = load_dataset("json", data_files="code_dataset.jsonl")
large = load_dataset("json", data_files="code_dataset_large.jsonl")
```
**Pandas / Kaggle:**
```python
import pandas as pd
core = pd.read_csv("code_dataset.csv")
large = pd.read_csv("code_dataset_large.csv")
combined = pd.concat([core, large], ignore_index=True)
```
## Suggested Uses
- Fine-tuning a code-explanation or code-generation model
- Few-shot prompting examples for a coding assistant
- Cross-language idiom comparison (e.g., "how does error handling differ
between Python and Rust?")
- Algorithm-variant training data (many sorting/data-structure/string
examples with controlled, labeled variation)
- A regression-test seed set for code-generation model evals
## Roadmap
The large set can be extended the same way to more categories (recursion,
OOP, error handling, file I/O, async) by adding template functions to
`generate_batch.py` — happy to keep scaling this up on request. |