metadata
license: apache-2.0
language:
- en
tags:
- python
- code-search
- text-to-code
- code-to-text
- source-code
Python CodeSearch Dataset (Shuu12121/python-treesitter-filtered-datasetsV2)
Dataset Description
This dataset contains Python functions paired with their documentation strings (docstrings), extracted from open-source Python repositories on GitHub. It is formatted similarly to the CodeSearchNet challenge dataset.
Each entry includes:
code
: The source code of a python function or method.docstring
: The docstring or Javadoc associated with the function/method.func_name
: The name of the function/method.language
: The programming language (always "python").repo
: The GitHub repository from which the code was sourced (e.g., "owner/repo").path
: The file path within the repository where the function/method is located.url
: A direct URL to the function/method's source file on GitHub (approximated to master/main branch).license
: The SPDX identifier of the license governing the source repository (e.g., "MIT", "Apache-2.0"). Additional metrics if available (from Lizard tool):ccn
: Cyclomatic Complexity Number.params
: Number of parameters of the function/method.nloc
: Non-commenting lines of code.token_count
: Number of tokens in the function/method.
Dataset Structure
The dataset is divided into the following splits:
train
: 1,083,527 examplesvalidation
: 18,408 examplestest
: 17,552 examples
Data Collection
The data was collected by:
- Identifying popular and relevant Python repositories on GitHub.
- Cloning these repositories.
- Parsing Python files (
.py
) using tree-sitter to extract functions/methods and their docstrings/Javadoc. - Filtering functions/methods based on code length and presence of a non-empty docstring/Javadoc.
- Using the
lizard
tool to calculate code metrics (CCN, NLOC, params). - Storing the extracted data in JSONL format, including repository and license information.
- Splitting the data by repository to ensure no data leakage between train, validation, and test sets.
Intended Use
This dataset can be used for tasks such as:
- Training and evaluating models for code search (natural language to code).
- Code summarization / docstring generation (code to natural language).
- Studies on Python code practices and documentation habits.
Licensing
The code examples within this dataset are sourced from repositories with permissive licenses (typically MIT, Apache-2.0, BSD).
Each sample includes its original license information in the license
field.
The dataset compilation itself is provided under a permissive license (e.g., MIT or CC-BY-SA-4.0),
but users should respect the original licenses of the underlying code.
Example Usage
from datasets import load_dataset
# Load the dataset
dataset = load_dataset("Shuu12121/python-treesitter-filtered-datasetsV2")
# Access a split (e.g., train)
train_data = dataset["train"]
# Print the first example
print(train_data[0])