Add dataset card
Browse files
README.md
CHANGED
|
@@ -1,37 +1,112 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
struct:
|
| 18 |
-
- name: hexsha
|
| 19 |
-
dtype: string
|
| 20 |
-
- name: max_stars_repo_name
|
| 21 |
-
dtype: string
|
| 22 |
-
- name: max_stars_repo_path
|
| 23 |
-
dtype: string
|
| 24 |
-
- name: lang
|
| 25 |
-
dtype: string
|
| 26 |
-
splits:
|
| 27 |
-
- name: train
|
| 28 |
-
num_bytes: 266226
|
| 29 |
-
num_examples: 1000
|
| 30 |
-
download_size: 78285
|
| 31 |
-
dataset_size: 266226
|
| 32 |
-
configs:
|
| 33 |
-
- config_name: default
|
| 34 |
-
data_files:
|
| 35 |
-
- split: train
|
| 36 |
-
path: data/train-*
|
| 37 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- code
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- code
|
| 7 |
+
- python
|
| 8 |
+
- comprehension
|
| 9 |
+
- the-stack
|
| 10 |
+
pretty_name: Python Comprehension Statements 1K
|
| 11 |
+
size_categories:
|
| 12 |
+
- 1K<n<10K
|
| 13 |
+
task_categories:
|
| 14 |
+
- text-generation
|
| 15 |
+
- fill-mask
|
| 16 |
+
license: other
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
---
|
| 18 |
+
|
| 19 |
+
# Python Comprehension Statements 1K
|
| 20 |
+
|
| 21 |
+
This dataset contains 1,000 Python statements extracted from `bigcode/the-stack`
|
| 22 |
+
that include at least one Python comprehension expression:
|
| 23 |
+
|
| 24 |
+
- list comprehensions
|
| 25 |
+
- set comprehensions
|
| 26 |
+
- dict comprehensions
|
| 27 |
+
- generator expressions
|
| 28 |
+
|
| 29 |
+
Each row is a nearest enclosing Python statement around one or more
|
| 30 |
+
comprehension expressions, along with line number information and source
|
| 31 |
+
metadata copied from the original The Stack sample.
|
| 32 |
+
|
| 33 |
+
## Dataset Details
|
| 34 |
+
|
| 35 |
+
- **Dataset name:** `py_comprehension_statements_1k`
|
| 36 |
+
- **Rows:** 1,000
|
| 37 |
+
- **Split:** `train`
|
| 38 |
+
- **Source dataset:** `bigcode/the-stack`, Python subset
|
| 39 |
+
- **Extraction script:** `scripts/collect_stack_comprehension_statements.py`
|
| 40 |
+
- **Original local JSONL:** `outputs/the_stack_python_comprehension_statements.jsonl`
|
| 41 |
+
|
| 42 |
+
## Schema
|
| 43 |
+
|
| 44 |
+
| Field | Type | Description |
|
| 45 |
+
| --- | --- | --- |
|
| 46 |
+
| `index` | `int64` | Zero-based index of the streamed source sample. |
|
| 47 |
+
| `statement_id` | `int64` | Statement index within the source sample. |
|
| 48 |
+
| `statement` | `string` | Extracted Python statement containing a comprehension. |
|
| 49 |
+
| `lineno` | `int64` | Starting line number in the original source file. |
|
| 50 |
+
| `end_lineno` | `int64` | Ending line number in the original source file. |
|
| 51 |
+
| `comprehension_types` | `list[string]` | AST comprehension node types present in the statement. |
|
| 52 |
+
| `metadata.hexsha` | `string` | Source commit hash from The Stack metadata. |
|
| 53 |
+
| `metadata.max_stars_repo_name` | `string` | Repository name from The Stack metadata. |
|
| 54 |
+
| `metadata.max_stars_repo_path` | `string` | File path from The Stack metadata. |
|
| 55 |
+
| `metadata.lang` | `string` | Source language label. |
|
| 56 |
+
|
| 57 |
+
## Comprehension Type Counts
|
| 58 |
+
|
| 59 |
+
The `comprehension_types` field can contain multiple values for a single row.
|
| 60 |
+
Across the 1,000 rows, the type occurrences are:
|
| 61 |
+
|
| 62 |
+
| Type | Count |
|
| 63 |
+
| --- | ---: |
|
| 64 |
+
| `ListComp` | 754 |
|
| 65 |
+
| `GeneratorExp` | 181 |
|
| 66 |
+
| `DictComp` | 76 |
|
| 67 |
+
| `SetComp` | 9 |
|
| 68 |
+
|
| 69 |
+
## Usage
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
from datasets import load_dataset
|
| 73 |
+
|
| 74 |
+
dataset = load_dataset("nexround/py_comprehension_statements_1k")
|
| 75 |
+
train = dataset["train"]
|
| 76 |
+
|
| 77 |
+
print(train[0]["statement"])
|
| 78 |
+
print(train[0]["comprehension_types"])
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
If you have the dataset saved locally with `datasets.save_to_disk`, use:
|
| 82 |
+
|
| 83 |
+
```python
|
| 84 |
+
from datasets import load_from_disk
|
| 85 |
+
|
| 86 |
+
dataset = load_from_disk("outputs/the_stack_python_comprehension_statements_hf_dataset")
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
## Construction
|
| 90 |
+
|
| 91 |
+
The extraction process streamed Python files from The Stack, parsed each source
|
| 92 |
+
file with Python's `ast` module, found `ListComp`, `SetComp`, `DictComp`, and
|
| 93 |
+
`GeneratorExp` nodes, and saved the nearest enclosing statement for each unique
|
| 94 |
+
statement span.
|
| 95 |
+
|
| 96 |
+
Rows that could not be parsed as Python source were skipped.
|
| 97 |
+
|
| 98 |
+
## Intended Uses
|
| 99 |
+
|
| 100 |
+
This dataset is intended for lightweight analysis and experimentation around
|
| 101 |
+
Python comprehension syntax, such as:
|
| 102 |
+
|
| 103 |
+
- inspecting comprehension usage patterns
|
| 104 |
+
- evaluating code models on comprehension-heavy snippets
|
| 105 |
+
- constructing small probes or prompts involving Python comprehensions
|
| 106 |
+
|
| 107 |
+
## Licensing
|
| 108 |
+
|
| 109 |
+
This is a derived sample from The Stack. The original source code snippets come
|
| 110 |
+
from many upstream repositories with varying licenses. Users should consult and
|
| 111 |
+
respect the licensing metadata and terms of the upstream The Stack dataset and
|
| 112 |
+
the original repositories when using or redistributing examples.
|