worstkid92 commited on
Commit
ecf2393
1 Parent(s): 00db614

Create unikraft-all-code

Browse files
Files changed (1) hide show
  1. unikraft-all-code +116 -0
unikraft-all-code ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ @author:XuMing(xuming624@qq.com)
3
+ @description:
4
+ """
5
+
6
+ """Code AutoComplete Python dataset Corpus.(code_autocomplete)"""
7
+
8
+ import os
9
+
10
+ import datasets
11
+
12
+ _DESCRIPTION = """纯文本数据,内容:高质量编程源代码,包括Python,Java,CPP源代码"""
13
+
14
+ PYTHON_HOME = "https://github.com/bharathgs/Awesome-pytorch-list"
15
+ JAVA_HOME = "https://github.com/akullpp/awesome-java"
16
+ CPP_HOME = "https://github.com/fffaraz/awesome-cpp"
17
+
18
+ _CITATION = "https://github.com/shibing624/code-autocomplete"
19
+
20
+ _DATA_URL = "https://github.com/worstkid92/unikraft/releases/download/uk-code/source_code.zip"
21
+
22
+
23
+ class SourceCodeConfig(datasets.BuilderConfig):
24
+ """BuilderConfig for NLI_zh"""
25
+
26
+ def __init__(self, features, data_url, citation, url, **kwargs):
27
+ """BuilderConfig for NLI_zh
28
+ Args:
29
+ features: `list[string]`, list of the features that will appear in the
30
+ feature dict. Should not include "label".
31
+ data_url: `string`, url to download the zip file from.
32
+ citation: `string`, citation for the data set.
33
+ url: `string`, url for information about the data set.
34
+ **kwargs: keyword arguments forwarded to super.
35
+ """
36
+ super().__init__(version=datasets.Version("1.0.0"), **kwargs)
37
+ self.features = features
38
+ self.data_url = data_url
39
+ self.citation = citation
40
+ self.url = url
41
+
42
+
43
+ class SourceCode(datasets.GeneratorBasedBuilder):
44
+ """The Natural Language Inference Chinese(NLI_zh) Corpus."""
45
+
46
+ BUILDER_CONFIGS = [
47
+ SourceCodeConfig(
48
+ name="python",
49
+ description=_DESCRIPTION,
50
+ features=["text"],
51
+ data_url=_DATA_URL,
52
+ citation=_CITATION,
53
+ url=PYTHON_HOME,
54
+ ),
55
+ SourceCodeConfig(
56
+ name="java",
57
+ description=_DESCRIPTION,
58
+ features=["text"],
59
+ data_url=_DATA_URL,
60
+ citation=_CITATION,
61
+ url=JAVA_HOME,
62
+ ),
63
+ SourceCodeConfig(
64
+ name="cpp",
65
+ description=_DESCRIPTION,
66
+ features=["text"],
67
+ data_url=_DATA_URL,
68
+ citation=_CITATION,
69
+ url=CPP_HOME,
70
+ ),
71
+ ]
72
+
73
+ def _info(self):
74
+ return datasets.DatasetInfo(
75
+ description=self.config.description,
76
+ features=datasets.Features(
77
+ {
78
+ "text": datasets.Value("string"),
79
+ }
80
+ ),
81
+ homepage=self.config.url,
82
+ citation=self.config.citation,
83
+ )
84
+
85
+ def _split_generators(self, dl_manager):
86
+ dl_dir = dl_manager.download_and_extract(self.config.data_url) or ""
87
+ dl_dir = os.path.join(dl_dir, f"source_code/{self.config.name}")
88
+ return [
89
+ datasets.SplitGenerator(
90
+ name=datasets.Split.TRAIN,
91
+ gen_kwargs={
92
+ "filepath": os.path.join(dl_dir, f"train.txt"),
93
+ },
94
+ ),
95
+ datasets.SplitGenerator(
96
+ name=datasets.Split.VALIDATION,
97
+ gen_kwargs={
98
+ "filepath": os.path.join(dl_dir, f"valid.txt"),
99
+ },
100
+ ),
101
+ datasets.SplitGenerator(
102
+ name=datasets.Split.TEST,
103
+ gen_kwargs={
104
+ "filepath": os.path.join(dl_dir, f"test.txt"),
105
+ },
106
+ ),
107
+ ]
108
+
109
+ def _generate_examples(self, filepath):
110
+ """This function returns the examples in the raw (text) form."""
111
+ with open(filepath, 'r', encoding="utf-8") as f:
112
+ for idx, row in enumerate(f):
113
+ if row.strip():
114
+ yield idx, {"text": row}
115
+ else:
116
+ yield idx, {"text": ""}