|
--- |
|
license: other |
|
language: php |
|
pretty_name: php Code Dataset (php-codesearch-dataset-open) |
|
tags: |
|
- code |
|
- php |
|
- codesearchnet-format |
|
- source-code |
|
- documentation |
|
configs: |
|
- config_name: default |
|
data_files: |
|
- split: train |
|
path: data/train-* |
|
- split: validation |
|
path: data/validation-* |
|
- split: test |
|
path: data/test-* |
|
dataset_info: |
|
features: |
|
- name: code |
|
dtype: string |
|
- name: docstring |
|
dtype: string |
|
- name: func_name |
|
dtype: string |
|
- name: language |
|
dtype: string |
|
- name: repo |
|
dtype: string |
|
- name: path |
|
dtype: string |
|
- name: url |
|
dtype: string |
|
- name: license |
|
dtype: string |
|
splits: |
|
- name: train |
|
num_bytes: 239674886 |
|
num_examples: 339995 |
|
- name: validation |
|
num_bytes: 1077889 |
|
num_examples: 1405 |
|
- name: test |
|
num_bytes: 1854579 |
|
num_examples: 2524 |
|
download_size: 47599874 |
|
dataset_size: 242607354 |
|
--- |
|
|
|
# php Code Dataset (php-codesearch-dataset-open) |
|
|
|
## Dataset Description |
|
|
|
This dataset contains php methods (functions) along with their documentation comments (typically `#` comments preceding the `def` line), extracted from various GitHub repositories. It follows a format similar to CodeSearchNet. |
|
|
|
### Features |
|
|
|
The dataset includes the following features for each sample: |
|
|
|
- `code`: The php method's source code (from `def` to `end`). |
|
- `docstring`: The documentation comment associated with the method. |
|
- `func_name`: The name of the method (function). |
|
- `language`: The programming language (always `"php"`). |
|
- `repo`: The full name of the source GitHub repository (e.g., `rails/rails`). |
|
- `path`: The relative file path within the source repository. |
|
- `url`: A GitHub URL pointing to the source file (usually on the master/main branch). |
|
- `license`: The SPDX identifier of the license declared for the source repository (e.g., `MIT`, `Apache-2.0`, `php`, or `NO LICENSE`). |
|
|
|
## Dataset Structure |
|
|
|
The dataset is divided into the following splits: |
|
|
|
- `train`: 339,995 examples |
|
- `validation`: 1,405 examples |
|
- `test`: 2,524 examples |
|
|
|
**Total Examples:** 343,924 |
|
|
|
## Usage |
|
|
|
You can load and use this dataset using the `datasets` library: |
|
|
|
```python |
|
from datasets import load_dataset |
|
|
|
# Load the dataset from the Hugging Face Hub |
|
dataset = load_dataset("Shuu12121/php-codesearch-dataset-open") |
|
|
|
# Access a specific split (e.g., training split) |
|
train_data = dataset["train"] |
|
|
|
# Explore the data |
|
print(f"Number of training samples: {len(train_data):,}") |
|
print("\nFirst training sample:") |
|
print(train_data[0]) |
|
|
|
# Example: Access code and docstring of the first sample |
|
first_sample = train_data[0] |
|
print("\nMethod Name:", first_sample['func_name']) |
|
print("\nDocstring:\n", first_sample['docstring']) |
|
# print("\nCode Snippet:\n", first_sample['code'][:500] + "...") # Print first 500 chars of code |
|
``` |
|
|
|
## Data Collection |
|
|
|
The data was collected by: |
|
1. Searching for popular and recent php repositories on GitHub. |
|
2. Cloning the repositories (shallow clone). |
|
3. Identifying php files (`.php`). |
|
4. Using the `lizard` tool to parse the code and identify method definitions. |
|
5. Extracting the method code and the preceding `#` comment lines as documentation. |
|
6. Filtering out methods without documentation or with very short code. |
|
7. Recording metadata like repository name, file path, and license. |
|
8. Splitting the data by repository (80% train, 10% validation, 10% test) to prevent data leakage between splits. |
|
|
|
## Licensing |
|
|
|
The code snippets included in this dataset are sourced from various GitHub repositories under different licenses (MIT, Apache-2.0, php License, BSD clauses, etc.). **Each data sample contains a `license` field indicating the license of the source repository.** Users of this dataset should be aware of and respect the original licenses when using the code snippets. The dataset itself (the collection and organization) is provided under a permissive license, but the underlying code snippets retain their original licenses. |
|
|
|
## Disclaimer |
|
|
|
This dataset was generated through an automated process. While efforts were made to accurately extract methods and documentation, there might be errors or inaccuracies. |
|
|