jiacheng-ye commited on
Commit
6cf9006
1 Parent(s): e50c887

Create nl2bash.py

Browse files
Files changed (1) hide show
  1. nl2bash.py +72 -0
nl2bash.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import datasets
3
+
4
+
5
+ _CITATION = """\
6
+ @inproceedings{LinWZE2018:NL2Bash,
7
+ author = {Xi Victoria Lin and Chenglong Wang and Luke Zettlemoyer and Michael D. Ernst},
8
+ title = {NL2Bash: A Corpus and Semantic Parser for Natural Language Interface to the Linux Operating System},
9
+ booktitle = {Proceedings of the Eleventh International Conference on Language Resources
10
+ and Evaluation {LREC} 2018, Miyazaki (Japan), 7-12 May, 2018.},
11
+ year = {2018}
12
+ }
13
+ """
14
+
15
+ _DESCRIPTION = """\
16
+ The dataset is constructed from
17
+ https://github.com/TellinaTool/nl2bash
18
+ """
19
+
20
+ _HOMEPAGE = ""
21
+ _LICENSE = ""
22
+
23
+ _URL = "https://www.dropbox.com/s/wy7uahzbir7lrq1/nl2bash.zip?dl=1"
24
+
25
+
26
+ class NL2Bash(datasets.GeneratorBasedBuilder):
27
+ """The NL2Bash dataset"""
28
+
29
+ def _info(self):
30
+ return datasets.DatasetInfo(
31
+ description=_DESCRIPTION,
32
+ features=datasets.Features(
33
+ {
34
+ "nl": datasets.Value("string"),
35
+ "bash": datasets.Value("string")
36
+ }
37
+ ),
38
+ supervised_keys=None,
39
+ homepage=_HOMEPAGE,
40
+ license=_LICENSE,
41
+ citation=_CITATION,
42
+ )
43
+
44
+ def _split_generators(self, dl_manager):
45
+ """Return SplitGenerators"""
46
+ downloaded_files = dl_manager.download_and_extract(_URL)
47
+
48
+ return [
49
+ datasets.SplitGenerator(
50
+ name=datasets.Split.TRAIN,
51
+ gen_kwargs={"filepath": downloaded_files + "/nl2bash/train.json"}
52
+ ),
53
+ datasets.SplitGenerator(
54
+ name=datasets.Split.VALIDATION,
55
+ gen_kwargs={"filepath": downloaded_files + "/nl2bash/dev.json"}
56
+ ),
57
+ datasets.SplitGenerator(
58
+ name=datasets.Split.TEST,
59
+ gen_kwargs={"filepath": downloaded_files + "/nl2bash/test.json"}
60
+ )
61
+ ]
62
+
63
+ def _generate_examples(self, filepath):
64
+ """Yields examples."""
65
+ with open(filepath) as fin:
66
+ data = json.load(fin)
67
+ for i, line in enumerate(data):
68
+ entry = {
69
+ "nl": line["nl"],
70
+ "bash": line["bash"],
71
+ }
72
+ yield i, entry