File size: 1,943 Bytes
5653fa3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from datasets import GeneratorBasedBuilder, BuilderConfig, Version, load_dataset

_DESCRIPTION = 'Dataset for {0} repositories...'
_CITATION = '...'

class RepositoryConfig(BuilderConfig):
    """BuilderConfig for Repository."""

    def __init__(self, language, features, data_url, citation, url, **kwargs):
        """
        Args:
            language: name of the programming language
            features: list of the features that will appear in the feature dict. Should not include "label".
            data_url: url to download the zip file from.
            citation: citation for the data set.
            url: url for information about the data set.
            **kwargs: keyword arguments forwarded to super.
        """
        super().__init__(version=Version("1.0.0"), **kwargs)
        self.language = language
        self.features = features
        self.data_url = data_url
        self.citation = citation
        self.url = url

class Repository(GeneratorBasedBuilder):
    """The Repository benchmark."""

    LANGUAGES = [
        'C#', 'C++', 'C', 'Go', 'HTML', 'Haskell', 'Java', 'JavaScript', 
        'Jupyter', 'Kotlin', 'PHP', 'Perl', 'Python', 'Ruby', 'Rust', 
        'Shell', 'Swift', 'TypeScript', 'V'
    ]

    BUILDER_CONFIGS = [
        RepositoryConfig(
            name=lang.lower().replace('+', 'p').replace('#', 'sharp'),
            description=_DESCRIPTION.format(lang),
            language=lang,
            features=["repo_name", "repo_creator", "programming_language", "code", "num_lines"],
            data_url=f"https://example.com/data/{lang.lower().replace('+', 'p').replace('#', 'sharp')}.zip",
            citation=_CITATION,
            url=f"https://example.com/{lang.lower().replace('+', 'p').replace('#', 'sharp')}_dataset",
        ) for lang in LANGUAGES
    ]

# load a specific configuration of the dataset with the configuration name
dataset = load_dataset('repository', 'python')