--- license: other language: go pretty_name: go Code Dataset (go-codesearch-dataset-openV2) tags: - code - go - 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: 1017609138 num_examples: 1201339 - name: validation num_bytes: 92999344 num_examples: 121618 - name: test num_bytes: 78035471 num_examples: 102574 download_size: 276080224 dataset_size: 1188643953 --- # go Code Dataset (go-codesearch-dataset-openV2) ## Dataset Description This dataset contains go 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 go 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 `"go"`). - `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`, `go`, or `NO LICENSE`). ## Dataset Structure The dataset is divided into the following splits: - `train`: 1,201,339 examples - `validation`: 121,618 examples - `test`: 102,574 examples **Total Examples:** 1,425,531 ## 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/go-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 go repositories on GitHub. 2. Cloning the repositories (shallow clone). 3. Identifying go files (`.go`). 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, go 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.