Datasets:

Modalities:
Text
Languages:
code
ArXiv:
Libraries:
Datasets
License:
Muennighoff commited on
Commit
40a9b2a
·
1 Parent(s): 239b245

Create commitpackft.py

Browse files
Files changed (1) hide show
  1. commitpackft.py +83 -0
commitpackft.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """CommitPackFT"""
2
+
3
+ import json
4
+
5
+ import datasets
6
+
7
+
8
+ logger = datasets.logging.get_logger(__name__)
9
+
10
+
11
+ _CITATION = """\
12
+ TODO
13
+ """
14
+
15
+ _DESCRIPTION = """\
16
+ TODO
17
+ """
18
+ _LANG = ["json", "xml", "text", "javascript", "objective-c++", "python", "c", "c++", "markdown", "java", "html", "yaml", "go", "csv", "php", "jupyter-notebook", "gettext-catalog", "sql", "unity3d-asset", "typescript", "web-ontology-language", "ruby", "c#", "nix", "shell", "perl", "tex", "css", "restructuredtext", "rust", "groff", "ini", "scala", "coffeescript", "haskell", "swift", "lua", "svg", "gas", "ocaml", "erlang", "makefile", "asciidoc", "emacs-lisp", "scss", "clojure", "org", "common-lisp", "diff", "groovy", "html+erb", "nesc", "dart", "powershell", "f#", "dm", "kotlin", "pascal", "jsx", "viml", "actionscript", "cython", "turtle", "less", "mathematica", "xslt", "scheme", "perl6", "edn", "fortran", "java-server-pages", "standard-ml", "cmake", "json5", "vala", "vue", "freemarker", "graphql", "twig", "tcl", "pod", "dockerfile", "yacc", "postscript", "racket", "eagle", "haxe", "julia", "handlebars", "smarty", "visual-basic", "literate-haskell", "smalltalk", "isabelle", "nimrod", "zig", "m4", "max", "elixir", "mako", "arduino", "jade", "haml", "elm", "purebasic", "coldfusion", "lean", "r", "cuda", "textile", "robotframework", "abap", "rdoc", "llvm", "ada", "batchfile", "qml", "jasmin", "assembly", "g-code", "cucumber", "html+php", "kicad", "api-blueprint", "eiffel", "toml", "modelica", "bitbake", "lex", "stylus", "protocol-buffer", "unknown", "nit", "factor", "xs", "sass", "parrot-internal-representation", "html+django", "mediawiki", "logos", "genshi", "coldfusion-cfc", "xtend", "sqf", "vhdl", "antlr", "systemverilog", "hcl", "asp", "nsis", "inform-7", "slim", "groovy-server-pages", "ceylon", "fish", "processing", "component-pascal", "lasso", "glsl", "saltstack", "xbase", "autohotkey", "liquid", "purescript", "agda", "inno-setup", "oz", "chapel", "arc", "opencl", "graphviz-dot", "pawn", "jsoniq", "bluespec", "smali", "krl", "maple", "unrealscript", "ooc", "pure-data", "xquery", "digital-command-language", "moonscript", "awk", "pike", "livescript", "solidity", "monkey", "jsonld", "zephir", "crystal", "rhtml", "stata", "idris", "raml", "openscad", "red", "c2hs-haskell", "cycript", "applescript", "mupad", "literate-agda", "boo", "sourcepawn", "qmake", "ragel-in-ruby-host", "io", "desktop", "propeller-spin", "thrift", "volt", "xproc", "igor-pro", "lolcode", "html+eex", "logtalk", "mirah", "gnuplot", "literate-coffeescript", "jflex", "emberscript", "cobol", "yang", "rebol", "linker-script", "cartocss", "urweb", "rmarkdown", "darcs-patch", "csound", "squirrel", "apl", "hlsl", "latte", "pony", "ioke", "hy", "uno", "pan", "xojo", "papyrus", "stan", "slash", "supercollider", "vcl", "smt", "glyph", "wisp", "renpy", "clips", "dns-zone", "sas", "rouge", "ec", "dylan", "tcsh", "aspectj", "netlogo", "gap", "fancy", "coq", "click", "capn-proto", "flux", "forth", "ats", "netlinx", "clean", "parrot-assembly", "alloy", "lfe", "gdscript", "augeas", "sparql", "lilypond", "scilab", "autoit", "myghty", "blitzmax", "creole", "harbour", "piglatin", "opa", "sage", "ston", "maxscript", "lsl", "gentoo-ebuild", "nu", "bro", "xc", "j", "metal", "module-management-system", "webidl", "tea", "redcode", "shen", "pov-ray-sdl", "x10", "brainfuck", "ninja", "golo", "webassembly", "self", "labview", "octave", "pogoscript", "d", "http", "ecl", "chuck", "gosu", "parrot", "opal", "objective-j", "kit", "gams", "prolog", "clarion", "mask", "brightscript", "scaml", "matlab", "idl", "ags-script", "lookml", "apacheconf", "oxygene", "txl", "grammatical-framework", "renderscript", "mtml", "unified-parallel-c", "dogescript", "gentoo-eclass", "zimpl", "irc-log", "fantom", "numpy", "cirru", "xpages", "nginx", "objdump", "python-traceback", "realbasic", "befunge", "bison", "m", "omgrofl"]
19
+ _URL = "https://huggingface.co/datasets/bigcode/commitpackft/raw/main/data/{lang}/data.jsonl"
20
+ _VERSION = datasets.Version("1.0.0", "")
21
+
22
+
23
+ class CommitPackFT(datasets.GeneratorBasedBuilder):
24
+ BUILDER_CONFIGS = [
25
+ datasets.BuilderConfig(
26
+ name=lang,
27
+ description=f"CommitPackFT in {lang}",
28
+ version=_VERSION,
29
+ )
30
+ for lang in _LANG
31
+ ]
32
+
33
+ def _info(self):
34
+ return datasets.DatasetInfo(
35
+ description=_DESCRIPTION,
36
+ features=datasets.Features(
37
+ {
38
+ "commit": datasets.Value("string"),
39
+ "old_file": datasets.Value("string"),
40
+ "new_file": datasets.Value("string"),
41
+ "old_contents": datasets.Value("string"),
42
+ "new_contents": datasets.Value("string"),
43
+ "subject": datasets.Value("string"),
44
+ "message": datasets.Value("string"),
45
+ "lang": datasets.Value("string"),
46
+ "license": datasets.Value("string"),
47
+ "repos": datasets.Value("string"),
48
+ }
49
+ ),
50
+ supervised_keys=None,
51
+ citation=_CITATION,
52
+ )
53
+
54
+ def _split_generators(self, dl_manager):
55
+
56
+ downloaded_files = dl_manager.download(_URL.format(lang=self.config.name))
57
+ return [
58
+ datasets.SplitGenerator(
59
+ name=datasets.Split.TEST,
60
+ gen_kwargs={'filepath': downloaded_files}
61
+ )
62
+ ]
63
+
64
+ def _generate_examples(self, filepath):
65
+ """This function returns the examples in the raw (text) form."""
66
+ logger.info("Generating examples from = %s", filepath)
67
+
68
+ with open(filepath, encoding="utf-8") as f:
69
+ for id_, row in enumerate(f):
70
+ data = json.loads(row)
71
+
72
+ yield id_, {
73
+ "commit": data["commit"],
74
+ "old_file": data["old_file"],
75
+ "new_file": data["new_file"],
76
+ "old_contents": data["old_contents"],
77
+ "new_contents": data["new_contents"],
78
+ "subject": data["subject"],
79
+ "message": data["message"],
80
+ "lang": data["lang"],
81
+ "license": data["license"],
82
+ "repos": data["repos"],
83
+ }