|
Download README.md from nexround/PyComp-1K: direct link, hf CLI and curl.
- Browser
- Download file 3.53 kB
-
https://huggingface.co/datasets/nexround/PyComp-1K/resolve/main/README.md
- Command line
-
hf download hf://datasets/nexround/PyComp-1K/README.md
-
curl -L -o README.md https://huggingface.co/datasets/nexround/PyComp-1K/resolve/main/README.md
3.53 kB
| language: | |
| - code | |
| - en | |
| tags: | |
| - code | |
| - python | |
| - comprehension | |
| - the-stack | |
| pretty_name: Python Comprehension Statements 1K | |
| size_categories: | |
| - 1K<n<10K | |
| task_categories: | |
| - text-generation | |
| - fill-mask | |
| license: other | |
| # Python Comprehension Statements 1K | |
| This dataset contains 1,000 Python statements extracted from `bigcode/the-stack` | |
| that include at least one Python comprehension expression: | |
| - list comprehensions | |
| - set comprehensions | |
| - dict comprehensions | |
| - generator expressions | |
| Each row is a nearest enclosing Python statement around one or more | |
| comprehension expressions, along with line number information and source | |
| metadata copied from the original The Stack sample. | |
| ## Dataset Details | |
| - **Dataset name:** `py_comprehension_statements_1k` | |
| - **Rows:** 1,000 | |
| - **Split:** `train` | |
| - **Source dataset:** `bigcode/the-stack`, Python subset | |
| - **Extraction script:** `scripts/collect_stack_comprehension_statements.py` | |
| - **Original local JSONL:** `outputs/the_stack_python_comprehension_statements.jsonl` | |
| ## Schema | |
| | Field | Type | Description | | |
| | --- | --- | --- | | |
| | `index` | `int64` | Zero-based index of the streamed source sample. | | |
| | `statement_id` | `int64` | Statement index within the source sample. | | |
| | `statement` | `string` | Extracted Python statement containing a comprehension. | | |
| | `lineno` | `int64` | Starting line number in the original source file. | | |
| | `end_lineno` | `int64` | Ending line number in the original source file. | | |
| | `comprehension_types` | `list[string]` | AST comprehension node types present in the statement. | | |
| | `metadata.hexsha` | `string` | Source commit hash from The Stack metadata. | | |
| | `metadata.max_stars_repo_name` | `string` | Repository name from The Stack metadata. | | |
| | `metadata.max_stars_repo_path` | `string` | File path from The Stack metadata. | | |
| | `metadata.lang` | `string` | Source language label. | | |
| ## Comprehension Type Counts | |
| The `comprehension_types` field can contain multiple values for a single row. | |
| Across the 1,000 rows, the type occurrences are: | |
| | Type | Count | | |
| | --- | ---: | | |
| | `ListComp` | 754 | | |
| | `GeneratorExp` | 181 | | |
| | `DictComp` | 76 | | |
| | `SetComp` | 9 | | |
| ## Usage | |
| ```python | |
| from datasets import load_dataset | |
| dataset = load_dataset("nexround/py_comprehension_statements_1k") | |
| train = dataset["train"] | |
| print(train[0]["statement"]) | |
| print(train[0]["comprehension_types"]) | |
| ``` | |
| If you have the dataset saved locally with `datasets.save_to_disk`, use: | |
| ```python | |
| from datasets import load_from_disk | |
| dataset = load_from_disk("outputs/the_stack_python_comprehension_statements_hf_dataset") | |
| ``` | |
| ## Construction | |
| The extraction process streamed Python files from The Stack, parsed each source | |
| file with Python's `ast` module, found `ListComp`, `SetComp`, `DictComp`, and | |
| `GeneratorExp` nodes, and saved the nearest enclosing statement for each unique | |
| statement span. | |
| Rows that could not be parsed as Python source were skipped. | |
| ## Intended Uses | |
| This dataset is intended for lightweight analysis and experimentation around | |
| Python comprehension syntax, such as: | |
| - inspecting comprehension usage patterns | |
| - evaluating code models on comprehension-heavy snippets | |
| - constructing small probes or prompts involving Python comprehensions | |
| ## Licensing | |
| This is a derived sample from The Stack. The original source code snippets come | |
| from many upstream repositories with varying licenses. Users should consult and | |
| respect the licensing metadata and terms of the upstream The Stack dataset and | |
| the original repositories when using or redistributing examples. | |