Shuu12121's picture
Upload dataset splits
269155c verified
metadata
license: other
language: php
pretty_name: php Code Dataset (php-codesearch-dataset-openV2)
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: 865654575
      num_examples: 1326581
    - name: validation
      num_bytes: 8460461
      num_examples: 11192
    - name: test
      num_bytes: 37954919
      num_examples: 60519
  download_size: 155268878
  dataset_size: 912069955

php Code Dataset (php-codesearch-dataset-openV2)

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: 1,326,581 examples
  • validation: 11,192 examples
  • test: 60,519 examples

Total Examples: 1,398,292

Usage

You can load and use this dataset using the datasets library:

from datasets import load_dataset

# Load the dataset from the Hugging Face Hub
dataset = load_dataset("Shuu12121/php-codesearch-dataset-openV2")

# 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.